Fix capitalization when mentioning different crate versions in E0308

This commit is contained in:
Esteban Küber 2019-11-25 12:26:32 -08:00
parent e5816a75cc
commit 00fe97ad0e
3 changed files with 9 additions and 22 deletions

View File

@ -463,7 +463,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
&self,
err: &mut DiagnosticBuilder<'_>,
terr: &TypeError<'tcx>,
sp: Span,
) {
use hir::def_id::CrateNum;
use hir::map::DisambiguatedDefPathData;
@ -577,14 +576,10 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
};
if same_path().unwrap_or(false) {
let crate_name = self.tcx.crate_name(did1.krate);
err.span_note(
sp,
&format!(
"Perhaps two different versions \
of crate `{}` are being used?",
crate_name
),
);
err.note(&format!(
"perhaps two different versions of crate `{}` are being used?",
crate_name
));
}
}
};
@ -1263,7 +1258,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
.unwrap_or_else(|| {
self.tcx.hir().body_owner_def_id(hir::BodyId { hir_id: cause.body_id })
});
self.check_and_note_conflicting_crates(diag, terr, span);
self.check_and_note_conflicting_crates(diag, terr);
self.tcx.note_and_explain_type_err(diag, terr, span, body_owner_def_id);
// It reads better to have the error origin as the final

View File

@ -15,11 +15,11 @@ fn main() {
extern crate crate_a1 as a;
a::try_foo(foo2);
//~^ ERROR mismatched types
//~| Perhaps two different versions of crate `crate_a1`
//~| perhaps two different versions of crate `crate_a1`
//~| expected struct `main::a::Foo`
a::try_bar(bar2);
//~^ ERROR mismatched types
//~| Perhaps two different versions of crate `crate_a1`
//~| perhaps two different versions of crate `crate_a1`
//~| expected trait `main::a::Bar`
//~| expected struct `std::boxed::Box<(dyn main::a::Bar + 'static)>`
//~| found struct `std::boxed::Box<dyn main::a::Bar>`

View File

@ -4,11 +4,7 @@ error[E0308]: mismatched types
LL | a::try_foo(foo2);
| ^^^^ expected struct `main::a::Foo`, found a different struct `main::a::Foo`
|
note: Perhaps two different versions of crate `crate_a1` are being used?
--> $DIR/type-mismatch-same-crate-name.rs:16:20
|
LL | a::try_foo(foo2);
| ^^^^
= note: perhaps two different versions of crate `crate_a1` are being used?
error[E0308]: mismatched types
--> $DIR/type-mismatch-same-crate-name.rs:20:20
@ -18,11 +14,7 @@ LL | a::try_bar(bar2);
|
= note: expected struct `std::boxed::Box<(dyn main::a::Bar + 'static)>`
found struct `std::boxed::Box<dyn main::a::Bar>`
note: Perhaps two different versions of crate `crate_a1` are being used?
--> $DIR/type-mismatch-same-crate-name.rs:20:20
|
LL | a::try_bar(bar2);
| ^^^^
= note: perhaps two different versions of crate `crate_a1` are being used?
error: aborting due to 2 previous errors