Skip to content

Commit 9072861

Browse files
author
Jonathan Turner
authored
Rollup merge of #35839 - jonathandturner:error_touchup, r=Aatch
Wording fixes in error messages This PR is largely wording fixes to existing PRs that I found going back through the ones that have already been updated. Sometimes seeing the message in context made me think "oh there's a better wording!" There's one additional fix. This will also prevent the secondary underlining of derive call (since they look like macros to the system in the way I was using): ``` error[E0184]: the trait `Copy` may not be implemented for this type; the type has a destructor --> src/test/compile-fail/E0184.rs:11:10 | 11 | #[derive(Copy)] //~ ERROR E0184 | ^^^^ | | | in this macro invocation ``` Is now just: ``` error[E0184]: the trait `Copy` may not be implemented for this type; the type has a destructor --> src/test/compile-fail/E0184.rs:11:10 | 11 | #[derive(Copy)] //~ ERROR E0184 | ^^^^ ```
2 parents b22352f + 54d0acd commit 9072861

18 files changed

+35
-34
lines changed

src/librustc/ty/error.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ impl<'tcx> fmt::Display for TypeError<'tcx> {
9898
values.expected,
9999
values.found)
100100
}
101-
Mutability => write!(f, "values differ in mutability"),
101+
Mutability => write!(f, "types differ in mutability"),
102102
BoxMutability => {
103-
write!(f, "boxed values differ in mutability")
103+
write!(f, "boxed types differ in mutability")
104104
}
105105
VecMutability => write!(f, "vectors differ in mutability"),
106106
PtrMutability => write!(f, "pointers differ in mutability"),

src/librustc_errors/emitter.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,9 @@ impl EmitterWriter {
426426
continue;
427427
}
428428
// Check to make sure we're not in any <*macros>
429-
if !cm.span_to_filename(def_site).contains("macros>") {
429+
if !cm.span_to_filename(def_site).contains("macros>") &&
430+
!trace.macro_decl_name.starts_with("#[")
431+
{
430432
new_labels.push((trace.call_site,
431433
"in this macro invocation".to_string()));
432434
break;

src/librustc_typeck/check/callee.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use rustc::hir;
2929
pub fn check_legal_trait_for_method_call(ccx: &CrateCtxt, span: Span, trait_id: DefId) {
3030
if ccx.tcx.lang_items.drop_trait() == Some(trait_id) {
3131
struct_span_err!(ccx.tcx.sess, span, E0040, "explicit use of destructor method")
32-
.span_label(span, &format!("call to destructor method"))
32+
.span_label(span, &format!("explicit destructor calls not allowed"))
3333
.emit();
3434
}
3535
}

src/librustc_typeck/check/compare_method.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ pub fn compare_impl_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
402402
infcx.note_type_err(
403403
&mut diag,
404404
origin,
405-
trait_err_span.map(|sp| (sp, format!("original trait requirement"))),
405+
trait_err_span.map(|sp| (sp, format!("type in trait"))),
406406
Some(infer::ValuePairs::Types(ExpectedFound {
407407
expected: trait_fty,
408408
found: impl_fty
@@ -575,7 +575,7 @@ pub fn compare_const_impl<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
575575
infcx.note_type_err(
576576
&mut diag,
577577
origin,
578-
Some((trait_c_span, format!("original trait requirement"))),
578+
Some((trait_c_span, format!("type in trait"))),
579579
Some(infer::ValuePairs::Types(ExpectedFound {
580580
expected: trait_ty,
581581
found: impl_ty

src/librustc_typeck/check/mod.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
10161016
// We can only get the spans from local trait definition
10171017
// Same for E0324 and E0325
10181018
if let Some(trait_span) = tcx.map.span_if_local(ty_trait_item.def_id()) {
1019-
err.span_label(trait_span, &format!("original trait requirement"));
1019+
err.span_label(trait_span, &format!("item in trait"));
10201020
}
10211021
err.emit()
10221022
}
@@ -1044,7 +1044,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
10441044
impl_trait_ref);
10451045
err.span_label(impl_item.span, &format!("does not match trait"));
10461046
if let Some(trait_span) = tcx.map.span_if_local(ty_trait_item.def_id()) {
1047-
err.span_label(trait_span, &format!("original trait requirement"));
1047+
err.span_label(trait_span, &format!("item in trait"));
10481048
}
10491049
err.emit()
10501050
}
@@ -1067,7 +1067,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
10671067
impl_trait_ref);
10681068
err.span_label(impl_item.span, &format!("does not match trait"));
10691069
if let Some(trait_span) = tcx.map.span_if_local(ty_trait_item.def_id()) {
1070-
err.span_label(trait_span, &format!("original trait requirement"));
1070+
err.span_label(trait_span, &format!("item in trait"));
10711071
}
10721072
err.emit()
10731073
}
@@ -4414,8 +4414,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
44144414
expected at most {}, found {}",
44154415
count(type_defs.len()),
44164416
count(types.len()))
4417-
.span_label(span, &format!("expected {}",
4418-
count(type_defs.len()))).emit();
4417+
.span_label(span, &format!("too many type parameters")).emit();
44194418

44204419
// To prevent derived errors to accumulate due to extra
44214420
// type parameters, we force instantiate_value_path to

src/librustc_typeck/coherence/orphan.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> {
3737
"cannot define inherent `impl` for a type outside of the \
3838
crate where the type is defined")
3939
.span_label(item.span, &format!("impl for type defined outside of crate."))
40-
.span_note(item.span, &format!("define and implement a trait or new type instead"))
40+
.note("define and implement a trait or new type instead")
4141
.emit();
4242
}
4343
}

src/librustc_typeck/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ impl Foo for Bar {
572572
// error, expected u16, found i16
573573
fn foo(x: i16) { }
574574
575-
// error, values differ in mutability
575+
// error, types differ in mutability
576576
fn bar(&mut self) { }
577577
}
578578
```

src/test/compile-fail/E0040.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ fn main() {
2222
let mut x = Foo { x: -7 };
2323
x.drop();
2424
//~^ ERROR E0040
25-
//~| NOTE call to destructor method
25+
//~| NOTE explicit destructor calls not allowed
2626
}

src/test/compile-fail/E0053.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
// except according to those terms.
1010

1111
trait Foo {
12-
fn foo(x: u16); //~ NOTE original trait requirement
13-
fn bar(&self); //~ NOTE original trait requirement
12+
fn foo(x: u16); //~ NOTE type in trait
13+
fn bar(&self); //~ NOTE type in trait
1414
}
1515

1616
struct Bar;
@@ -21,7 +21,7 @@ impl Foo for Bar {
2121
//~| NOTE expected u16
2222
fn bar(&mut self) { }
2323
//~^ ERROR method `bar` has an incompatible type for trait
24-
//~| NOTE values differ in mutability
24+
//~| NOTE types differ in mutability
2525
//~| NOTE expected type `fn(&Bar)`
2626
//~| NOTE found type `fn(&mut Bar)`
2727
}

src/test/compile-fail/E0087.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ fn foo<T>() {}
1212

1313
fn main() {
1414
foo::<f64, bool>(); //~ ERROR E0087
15-
//~^ NOTE expected
15+
//~^ NOTE too many type parameters
1616
}

src/test/compile-fail/associated-const-impl-wrong-type.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#![feature(associated_consts)]
1212

1313
trait Foo {
14-
const BAR: u32; //~ NOTE original trait requirement
14+
const BAR: u32; //~ NOTE type in trait
1515
}
1616

1717
struct SignedBar;

src/test/compile-fail/coerce-mut.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ fn main() {
1616
//~^ ERROR mismatched types
1717
//~| expected type `&mut i32`
1818
//~| found type `&{integer}`
19-
//~| values differ in mutability
19+
//~| types differ in mutability
2020
}

src/test/compile-fail/fn-variance-1.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ fn apply<T, F>(t: T, f: F) where F: FnOnce(T) {
1919
fn main() {
2020
apply(&3, takes_imm);
2121
apply(&3, takes_mut);
22-
//~^ ERROR (values differ in mutability)
22+
//~^ ERROR (types differ in mutability)
2323

2424
apply(&mut 3, takes_mut);
2525
apply(&mut 3, takes_imm);
26-
//~^ ERROR (values differ in mutability)
26+
//~^ ERROR (types differ in mutability)
2727
}

src/test/compile-fail/impl-wrong-item-for-trait.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
trait Foo {
1414
fn bar(&self);
15-
//~^ NOTE original trait requirement
16-
//~| NOTE original trait requirement
17-
const MY_CONST: u32; //~ NOTE original trait requirement
15+
//~^ NOTE item in trait
16+
//~| NOTE item in trait
17+
const MY_CONST: u32; //~ NOTE item in trait
1818
}
1919

2020
pub struct FooConstForMethod;

src/test/compile-fail/mut-pattern-mismatched.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fn main() {
1616
let &_ //~ ERROR mismatched types
1717
//~| expected type `&mut {integer}`
1818
//~| found type `&_`
19-
//~| values differ in mutability
19+
//~| types differ in mutability
2020
= foo;
2121
let &mut _ = foo;
2222

@@ -25,6 +25,6 @@ fn main() {
2525
let &mut _ //~ ERROR mismatched types
2626
//~| expected type `&{integer}`
2727
//~| found type `&mut _`
28-
//~| values differ in mutability
28+
//~| types differ in mutability
2929
= bar;
3030
}

src/test/compile-fail/ptr-coercion.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ pub fn main() {
1717
let x: *mut isize = x; //~ ERROR mismatched types
1818
//~| expected type `*mut isize`
1919
//~| found type `*const isize`
20-
//~| values differ in mutability
20+
//~| types differ in mutability
2121

2222
// & -> *mut
2323
let x: *mut isize = &42; //~ ERROR mismatched types
2424
//~| expected type `*mut isize`
2525
//~| found type `&isize`
26-
//~| values differ in mutability
26+
//~| types differ in mutability
2727

2828
let x: *const isize = &42;
2929
let x: *mut isize = x; //~ ERROR mismatched types
3030
//~| expected type `*mut isize`
3131
//~| found type `*const isize`
32-
//~| values differ in mutability
32+
//~| types differ in mutability
3333
}

src/test/compile-fail/slice-mut.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ fn main() {
1818
//~^ ERROR mismatched types
1919
//~| expected type `&mut [_]`
2020
//~| found type `&[isize]`
21-
//~| values differ in mutability
21+
//~| types differ in mutability
2222
}

src/test/ui/mismatched_types/trait-impl-fn-incompatibility.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0053]: method `foo` has an incompatible type for trait
22
--> $DIR/trait-impl-fn-incompatibility.rs:21:15
33
|
44
14 | fn foo(x: u16);
5-
| --- original trait requirement
5+
| --- type in trait
66
...
77
21 | fn foo(x: i16) { }
88
| ^^^ expected u16, found i16
@@ -11,10 +11,10 @@ error[E0053]: method `bar` has an incompatible type for trait
1111
--> $DIR/trait-impl-fn-incompatibility.rs:22:28
1212
|
1313
15 | fn bar(&mut self, bar: &mut Bar);
14-
| -------- original trait requirement
14+
| -------- type in trait
1515
...
1616
22 | fn bar(&mut self, bar: &Bar) { }
17-
| ^^^^ values differ in mutability
17+
| ^^^^ types differ in mutability
1818
|
1919
= note: expected type `fn(&mut Bar, &mut Bar)`
2020
= note: found type `fn(&mut Bar, &Bar)`

0 commit comments

Comments
 (0)