Skip to content

Commit 3480f6f

Browse files
committed
Closure type error ui tweak
Do not point at the same span on all notes/help messages, and instead show them without a span.
1 parent b39c4bc commit 3480f6f

File tree

3 files changed

+7
-37
lines changed

3 files changed

+7
-37
lines changed

src/librustc/middle/entry.rs

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

src/librustc/ty/error.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
260260
let expected_str = values.expected.sort_string(self);
261261
let found_str = values.found.sort_string(self);
262262
if expected_str == found_str && expected_str == "closure" {
263-
db.span_note(sp,
264-
"no two closures, even if identical, have the same type");
265-
db.span_help(sp,
266-
"consider boxing your closure and/or using it as a trait object");
263+
db.note("no two closures, even if identical, have the same type");
264+
db.help("consider boxing your closure and/or using it as a trait object");
267265
}
268266
},
269267
TyParamDefaultMismatch(values) => {

src/test/ui/issue-24036.stderr

+4-32
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,8 @@ error[E0308]: mismatched types
66
|
77
= note: expected type `[closure@$DIR/issue-24036.rs:12:17: 12:26]`
88
found type `[closure@$DIR/issue-24036.rs:13:9: 13:18]`
9-
note: no two closures, even if identical, have the same type
10-
--> $DIR/issue-24036.rs:13:9
11-
|
12-
13 | x = |c| c + 1;
13-
| ^^^^^^^^^
14-
help: consider boxing your closure and/or using it as a trait object
15-
--> $DIR/issue-24036.rs:13:9
16-
|
17-
13 | x = |c| c + 1;
18-
| ^^^^^^^^^
9+
= note: no two closures, even if identical, have the same type
10+
= help: consider boxing your closure and/or using it as a trait object
1911

2012
error[E0308]: match arms have incompatible types
2113
--> $DIR/issue-24036.rs:18:13
@@ -31,28 +23,8 @@ error[E0308]: match arms have incompatible types
3123
|
3224
= note: expected type `[closure@$DIR/issue-24036.rs:20:14: 20:23]`
3325
found type `[closure@$DIR/issue-24036.rs:21:14: 21:23]`
34-
note: no two closures, even if identical, have the same type
35-
--> $DIR/issue-24036.rs:18:13
36-
|
37-
18 | let x = match 1usize {
38-
| _____________^
39-
19 | | //~^ ERROR match arms have incompatible types
40-
20 | | 1 => |c| c + 1,
41-
21 | | 2 => |c| c - 1,
42-
22 | | _ => |c| c - 1
43-
23 | | };
44-
| |_____^
45-
help: consider boxing your closure and/or using it as a trait object
46-
--> $DIR/issue-24036.rs:18:13
47-
|
48-
18 | let x = match 1usize {
49-
| _____________^
50-
19 | | //~^ ERROR match arms have incompatible types
51-
20 | | 1 => |c| c + 1,
52-
21 | | 2 => |c| c - 1,
53-
22 | | _ => |c| c - 1
54-
23 | | };
55-
| |_____^
26+
= note: no two closures, even if identical, have the same type
27+
= help: consider boxing your closure and/or using it as a trait object
5628
note: match arm with an incompatible type
5729
--> $DIR/issue-24036.rs:21:14
5830
|

0 commit comments

Comments
 (0)