From 00fe97ad0e440d78a3dbf8df77ac5192ca6d6403 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 25 Nov 2019 12:26:32 -0800 Subject: [PATCH] Fix capitalization when mentioning different crate versions in E0308 --- src/librustc/infer/error_reporting/mod.rs | 15 +++++---------- src/test/ui/type/type-mismatch-same-crate-name.rs | 4 ++-- .../ui/type/type-mismatch-same-crate-name.stderr | 12 ++---------- 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index 0f93ef6b1a9e..3ff5b2521ae8 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -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 diff --git a/src/test/ui/type/type-mismatch-same-crate-name.rs b/src/test/ui/type/type-mismatch-same-crate-name.rs index b1f9a28e16d5..eeda5460ac36 100644 --- a/src/test/ui/type/type-mismatch-same-crate-name.rs +++ b/src/test/ui/type/type-mismatch-same-crate-name.rs @@ -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` diff --git a/src/test/ui/type/type-mismatch-same-crate-name.stderr b/src/test/ui/type/type-mismatch-same-crate-name.stderr index 91bbe9c1fbe2..be5406696b7d 100644 --- a/src/test/ui/type/type-mismatch-same-crate-name.stderr +++ b/src/test/ui/type/type-mismatch-same-crate-name.stderr @@ -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` -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