From 54d0acd2fc6414930ff27c01c8640f4e9c666ad5 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Fri, 19 Aug 2016 16:05:37 -0700 Subject: [PATCH] wording fixes in error messages --- src/librustc/ty/error.rs | 4 ++-- src/librustc_errors/emitter.rs | 4 +++- src/librustc_typeck/check/callee.rs | 2 +- src/librustc_typeck/check/compare_method.rs | 4 ++-- src/librustc_typeck/check/mod.rs | 9 ++++----- src/librustc_typeck/coherence/orphan.rs | 2 +- src/librustc_typeck/diagnostics.rs | 2 +- src/test/compile-fail/E0040.rs | 2 +- src/test/compile-fail/E0053.rs | 6 +++--- src/test/compile-fail/E0087.rs | 2 +- .../compile-fail/associated-const-impl-wrong-type.rs | 2 +- src/test/compile-fail/coerce-mut.rs | 2 +- src/test/compile-fail/fn-variance-1.rs | 4 ++-- src/test/compile-fail/impl-wrong-item-for-trait.rs | 6 +++--- src/test/compile-fail/mut-pattern-mismatched.rs | 4 ++-- src/test/compile-fail/ptr-coercion.rs | 6 +++--- src/test/compile-fail/slice-mut.rs | 2 +- .../trait-impl-fn-incompatibility.stderr | 6 +++--- 18 files changed, 35 insertions(+), 34 deletions(-) diff --git a/src/librustc/ty/error.rs b/src/librustc/ty/error.rs index 17f9b6c2599..32c87fb615a 100644 --- a/src/librustc/ty/error.rs +++ b/src/librustc/ty/error.rs @@ -98,9 +98,9 @@ fn report_maybe_different(f: &mut fmt::Formatter, values.expected, values.found) } - Mutability => write!(f, "values differ in mutability"), + Mutability => write!(f, "types differ in mutability"), BoxMutability => { - write!(f, "boxed values differ in mutability") + write!(f, "boxed types differ in mutability") } VecMutability => write!(f, "vectors differ in mutability"), PtrMutability => write!(f, "pointers differ in mutability"), diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index 5fd9226aba9..793155cfa8f 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -426,7 +426,9 @@ fn fix_multispan_in_std_macros(&mut self, span: &mut MultiSpan) -> bool { continue; } // Check to make sure we're not in any <*macros> - if !cm.span_to_filename(def_site).contains("macros>") { + if !cm.span_to_filename(def_site).contains("macros>") && + !trace.macro_decl_name.starts_with("#[") + { new_labels.push((trace.call_site, "in this macro invocation".to_string())); break; diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index 985c3be1496..acb6653214d 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -29,7 +29,7 @@ pub fn check_legal_trait_for_method_call(ccx: &CrateCtxt, span: Span, trait_id: DefId) { if ccx.tcx.lang_items.drop_trait() == Some(trait_id) { struct_span_err!(ccx.tcx.sess, span, E0040, "explicit use of destructor method") - .span_label(span, &format!("call to destructor method")) + .span_label(span, &format!("explicit destructor calls not allowed")) .emit(); } } diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index 043883df035..0e42990a337 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -402,7 +402,7 @@ pub fn compare_impl_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, infcx.note_type_err( &mut diag, origin, - trait_err_span.map(|sp| (sp, format!("original trait requirement"))), + trait_err_span.map(|sp| (sp, format!("type in trait"))), Some(infer::ValuePairs::Types(ExpectedFound { expected: trait_fty, found: impl_fty @@ -575,7 +575,7 @@ pub fn compare_const_impl<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, infcx.note_type_err( &mut diag, origin, - Some((trait_c_span, format!("original trait requirement"))), + Some((trait_c_span, format!("type in trait"))), Some(infer::ValuePairs::Types(ExpectedFound { expected: trait_ty, found: impl_ty diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index ff0b86aa595..ca783455569 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1013,7 +1013,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, // We can only get the spans from local trait definition // Same for E0324 and E0325 if let Some(trait_span) = tcx.map.span_if_local(ty_trait_item.def_id()) { - err.span_label(trait_span, &format!("original trait requirement")); + err.span_label(trait_span, &format!("item in trait")); } err.emit() } @@ -1041,7 +1041,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, impl_trait_ref); err.span_label(impl_item.span, &format!("does not match trait")); if let Some(trait_span) = tcx.map.span_if_local(ty_trait_item.def_id()) { - err.span_label(trait_span, &format!("original trait requirement")); + err.span_label(trait_span, &format!("item in trait")); } err.emit() } @@ -1064,7 +1064,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, impl_trait_ref); err.span_label(impl_item.span, &format!("does not match trait")); if let Some(trait_span) = tcx.map.span_if_local(ty_trait_item.def_id()) { - err.span_label(trait_span, &format!("original trait requirement")); + err.span_label(trait_span, &format!("item in trait")); } err.emit() } @@ -4408,8 +4408,7 @@ fn check_path_parameter_count(&self, expected at most {}, found {}", count(type_defs.len()), count(types.len())) - .span_label(span, &format!("expected {}", - count(type_defs.len()))).emit(); + .span_label(span, &format!("too many type parameters")).emit(); // To prevent derived errors to accumulate due to extra // type parameters, we force instantiate_value_path to diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs index 7578ec3d813..a3c043fe7cb 100644 --- a/src/librustc_typeck/coherence/orphan.rs +++ b/src/librustc_typeck/coherence/orphan.rs @@ -37,7 +37,7 @@ fn check_def_id(&self, item: &hir::Item, def_id: DefId) { "cannot define inherent `impl` for a type outside of the \ crate where the type is defined") .span_label(item.span, &format!("impl for type defined outside of crate.")) - .span_note(item.span, &format!("define and implement a trait or new type instead")) + .note("define and implement a trait or new type instead") .emit(); } } diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index fe1cb3d6bad..8bb5efdcad2 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -572,7 +572,7 @@ impl Foo for Bar { // error, expected u16, found i16 fn foo(x: i16) { } - // error, values differ in mutability + // error, types differ in mutability fn bar(&mut self) { } } ``` diff --git a/src/test/compile-fail/E0040.rs b/src/test/compile-fail/E0040.rs index 80ff57c3635..edfe22186e1 100644 --- a/src/test/compile-fail/E0040.rs +++ b/src/test/compile-fail/E0040.rs @@ -22,5 +22,5 @@ fn main() { let mut x = Foo { x: -7 }; x.drop(); //~^ ERROR E0040 - //~| NOTE call to destructor method + //~| NOTE explicit destructor calls not allowed } diff --git a/src/test/compile-fail/E0053.rs b/src/test/compile-fail/E0053.rs index 7022010714a..933462e553e 100644 --- a/src/test/compile-fail/E0053.rs +++ b/src/test/compile-fail/E0053.rs @@ -9,8 +9,8 @@ // except according to those terms. trait Foo { - fn foo(x: u16); //~ NOTE original trait requirement - fn bar(&self); //~ NOTE original trait requirement + fn foo(x: u16); //~ NOTE type in trait + fn bar(&self); //~ NOTE type in trait } struct Bar; @@ -21,7 +21,7 @@ fn foo(x: i16) { } //~| NOTE expected u16 fn bar(&mut self) { } //~^ ERROR method `bar` has an incompatible type for trait - //~| NOTE values differ in mutability + //~| NOTE types differ in mutability //~| NOTE expected type `fn(&Bar)` //~| NOTE found type `fn(&mut Bar)` } diff --git a/src/test/compile-fail/E0087.rs b/src/test/compile-fail/E0087.rs index 437ad3698a2..7c98de59e27 100644 --- a/src/test/compile-fail/E0087.rs +++ b/src/test/compile-fail/E0087.rs @@ -12,5 +12,5 @@ fn foo() {} fn main() { foo::(); //~ ERROR E0087 - //~^ NOTE expected + //~^ NOTE too many type parameters } diff --git a/src/test/compile-fail/associated-const-impl-wrong-type.rs b/src/test/compile-fail/associated-const-impl-wrong-type.rs index b3776091682..ec495c87b1a 100644 --- a/src/test/compile-fail/associated-const-impl-wrong-type.rs +++ b/src/test/compile-fail/associated-const-impl-wrong-type.rs @@ -11,7 +11,7 @@ #![feature(associated_consts)] trait Foo { - const BAR: u32; //~ NOTE original trait requirement + const BAR: u32; //~ NOTE type in trait } struct SignedBar; diff --git a/src/test/compile-fail/coerce-mut.rs b/src/test/compile-fail/coerce-mut.rs index 86702a7463f..bc3d58ef33d 100644 --- a/src/test/compile-fail/coerce-mut.rs +++ b/src/test/compile-fail/coerce-mut.rs @@ -16,5 +16,5 @@ fn main() { //~^ ERROR mismatched types //~| expected type `&mut i32` //~| found type `&{integer}` - //~| values differ in mutability + //~| types differ in mutability } diff --git a/src/test/compile-fail/fn-variance-1.rs b/src/test/compile-fail/fn-variance-1.rs index e9dd1cb719d..d0d911b6eb9 100644 --- a/src/test/compile-fail/fn-variance-1.rs +++ b/src/test/compile-fail/fn-variance-1.rs @@ -19,9 +19,9 @@ fn apply(t: T, f: F) where F: FnOnce(T) { fn main() { apply(&3, takes_imm); apply(&3, takes_mut); - //~^ ERROR (values differ in mutability) + //~^ ERROR (types differ in mutability) apply(&mut 3, takes_mut); apply(&mut 3, takes_imm); - //~^ ERROR (values differ in mutability) + //~^ ERROR (types differ in mutability) } diff --git a/src/test/compile-fail/impl-wrong-item-for-trait.rs b/src/test/compile-fail/impl-wrong-item-for-trait.rs index e0ea1a4cac5..388c9a1729c 100644 --- a/src/test/compile-fail/impl-wrong-item-for-trait.rs +++ b/src/test/compile-fail/impl-wrong-item-for-trait.rs @@ -12,9 +12,9 @@ trait Foo { fn bar(&self); - //~^ NOTE original trait requirement - //~| NOTE original trait requirement - const MY_CONST: u32; //~ NOTE original trait requirement + //~^ NOTE item in trait + //~| NOTE item in trait + const MY_CONST: u32; //~ NOTE item in trait } pub struct FooConstForMethod; diff --git a/src/test/compile-fail/mut-pattern-mismatched.rs b/src/test/compile-fail/mut-pattern-mismatched.rs index 318d121e4c2..7685a5c0808 100644 --- a/src/test/compile-fail/mut-pattern-mismatched.rs +++ b/src/test/compile-fail/mut-pattern-mismatched.rs @@ -16,7 +16,7 @@ fn main() { let &_ //~ ERROR mismatched types //~| expected type `&mut {integer}` //~| found type `&_` - //~| values differ in mutability + //~| types differ in mutability = foo; let &mut _ = foo; @@ -25,6 +25,6 @@ fn main() { let &mut _ //~ ERROR mismatched types //~| expected type `&{integer}` //~| found type `&mut _` - //~| values differ in mutability + //~| types differ in mutability = bar; } diff --git a/src/test/compile-fail/ptr-coercion.rs b/src/test/compile-fail/ptr-coercion.rs index ff627e69d4c..1390c9507c1 100644 --- a/src/test/compile-fail/ptr-coercion.rs +++ b/src/test/compile-fail/ptr-coercion.rs @@ -17,17 +17,17 @@ pub fn main() { let x: *mut isize = x; //~ ERROR mismatched types //~| expected type `*mut isize` //~| found type `*const isize` - //~| values differ in mutability + //~| types differ in mutability // & -> *mut let x: *mut isize = &42; //~ ERROR mismatched types //~| expected type `*mut isize` //~| found type `&isize` - //~| values differ in mutability + //~| types differ in mutability let x: *const isize = &42; let x: *mut isize = x; //~ ERROR mismatched types //~| expected type `*mut isize` //~| found type `*const isize` - //~| values differ in mutability + //~| types differ in mutability } diff --git a/src/test/compile-fail/slice-mut.rs b/src/test/compile-fail/slice-mut.rs index 874cca8cb3f..bee3704a353 100644 --- a/src/test/compile-fail/slice-mut.rs +++ b/src/test/compile-fail/slice-mut.rs @@ -18,5 +18,5 @@ fn main() { //~^ ERROR mismatched types //~| expected type `&mut [_]` //~| found type `&[isize]` - //~| values differ in mutability + //~| types differ in mutability } diff --git a/src/test/ui/mismatched_types/trait-impl-fn-incompatibility.stderr b/src/test/ui/mismatched_types/trait-impl-fn-incompatibility.stderr index e5dfdc8e910..4a0ccc46525 100644 --- a/src/test/ui/mismatched_types/trait-impl-fn-incompatibility.stderr +++ b/src/test/ui/mismatched_types/trait-impl-fn-incompatibility.stderr @@ -2,7 +2,7 @@ error[E0053]: method `foo` has an incompatible type for trait --> $DIR/trait-impl-fn-incompatibility.rs:21:15 | 14 | fn foo(x: u16); - | --- original trait requirement + | --- type in trait ... 21 | fn foo(x: i16) { } | ^^^ expected u16, found i16 @@ -11,10 +11,10 @@ error[E0053]: method `bar` has an incompatible type for trait --> $DIR/trait-impl-fn-incompatibility.rs:22:28 | 15 | fn bar(&mut self, bar: &mut Bar); - | -------- original trait requirement + | -------- type in trait ... 22 | fn bar(&mut self, bar: &Bar) { } - | ^^^^ values differ in mutability + | ^^^^ types differ in mutability | = note: expected type `fn(&mut Bar, &mut Bar)` = note: found type `fn(&mut Bar, &Bar)`