Closure type error ui tweak

Do not point at the same span on all notes/help messages, and instead
show them without a span.
This commit is contained in:
Esteban Küber 2017-12-19 19:04:09 -08:00
parent b39c4bc123
commit 3480f6f068
3 changed files with 7 additions and 37 deletions

View File

@ -170,7 +170,7 @@ fn configure_main(this: &mut EntryContext) {
defined at the crate level. Either move the definition or \
attach the `#[main]` attribute to override this behavior.");
for &(_, span) in &this.non_main_fns {
err.span_note(span, "here is a function named 'main'");
err.span_label(span, "here is a function named 'main'");
}
err.emit();
this.session.abort_if_errors();

View File

@ -260,10 +260,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
let expected_str = values.expected.sort_string(self);
let found_str = values.found.sort_string(self);
if expected_str == found_str && expected_str == "closure" {
db.span_note(sp,
"no two closures, even if identical, have the same type");
db.span_help(sp,
"consider boxing your closure and/or using it as a trait object");
db.note("no two closures, even if identical, have the same type");
db.help("consider boxing your closure and/or using it as a trait object");
}
},
TyParamDefaultMismatch(values) => {

View File

@ -6,16 +6,8 @@ error[E0308]: mismatched types
|
= note: expected type `[closure@$DIR/issue-24036.rs:12:17: 12:26]`
found type `[closure@$DIR/issue-24036.rs:13:9: 13:18]`
note: no two closures, even if identical, have the same type
--> $DIR/issue-24036.rs:13:9
|
13 | x = |c| c + 1;
| ^^^^^^^^^
help: consider boxing your closure and/or using it as a trait object
--> $DIR/issue-24036.rs:13:9
|
13 | x = |c| c + 1;
| ^^^^^^^^^
= note: no two closures, even if identical, have the same type
= help: consider boxing your closure and/or using it as a trait object
error[E0308]: match arms have incompatible types
--> $DIR/issue-24036.rs:18:13
@ -31,28 +23,8 @@ error[E0308]: match arms have incompatible types
|
= note: expected type `[closure@$DIR/issue-24036.rs:20:14: 20:23]`
found type `[closure@$DIR/issue-24036.rs:21:14: 21:23]`
note: no two closures, even if identical, have the same type
--> $DIR/issue-24036.rs:18:13
|
18 | let x = match 1usize {
| _____________^
19 | | //~^ ERROR match arms have incompatible types
20 | | 1 => |c| c + 1,
21 | | 2 => |c| c - 1,
22 | | _ => |c| c - 1
23 | | };
| |_____^
help: consider boxing your closure and/or using it as a trait object
--> $DIR/issue-24036.rs:18:13
|
18 | let x = match 1usize {
| _____________^
19 | | //~^ ERROR match arms have incompatible types
20 | | 1 => |c| c + 1,
21 | | 2 => |c| c - 1,
22 | | _ => |c| c - 1
23 | | };
| |_____^
= note: no two closures, even if identical, have the same type
= help: consider boxing your closure and/or using it as a trait object
note: match arm with an incompatible type
--> $DIR/issue-24036.rs:21:14
|