Skip to content

Commit ee06559

Browse files
committed
Tweak presentation on lifetime trait mismatch
1 parent bacb5c5 commit ee06559

File tree

2 files changed

+10
-20
lines changed

2 files changed

+10
-20
lines changed

src/librustc/infer/error_reporting/note.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
2323
if let Some((expected, found)) = self.values_str(&trace.values) {
2424
let expected = expected.content();
2525
let found = found.content();
26-
// FIXME: do we want a "the" here?
27-
err.span_note(trace.cause.span,
28-
&format!("...so that {} (expected {}, found {})",
29-
trace.cause.as_requirement_str(),
30-
expected,
31-
found));
26+
err.note(&format!("...so that the {}:\nexpected {}\n found {}",
27+
trace.cause.as_requirement_str(),
28+
expected,
29+
found));
3230
} else {
3331
// FIXME: this really should be handled at some earlier stage. Our
3432
// handling of region checking when type errors are present is

src/test/ui/in-band-lifetimes/mismatched_trait_impl.stderr

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,19 @@ note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on th
1313
20 | | x
1414
21 | | }
1515
| |_____^
16-
note: ...so that method type is compatible with trait (expected fn(&i32, &'a u32, &u32) -> &'a u32, found fn(&i32, &u32, &u32) -> &u32)
17-
--> $DIR/mismatched_trait_impl.rs:19:5
18-
|
19-
19 | / fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 { //~ ERROR cannot infer
20-
20 | | x
21-
21 | | }
22-
| |_____^
16+
= note: ...so that the method type is compatible with trait:
17+
expected fn(&i32, &'a u32, &u32) -> &'a u32
18+
found fn(&i32, &u32, &u32) -> &u32
2319
note: but, the lifetime must be valid for the lifetime 'a as defined on the method body at 19:5...
2420
--> $DIR/mismatched_trait_impl.rs:19:5
2521
|
2622
19 | / fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 { //~ ERROR cannot infer
2723
20 | | x
2824
21 | | }
2925
| |_____^
30-
note: ...so that method type is compatible with trait (expected fn(&i32, &'a u32, &u32) -> &'a u32, found fn(&i32, &u32, &u32) -> &u32)
31-
--> $DIR/mismatched_trait_impl.rs:19:5
32-
|
33-
19 | / fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 { //~ ERROR cannot infer
34-
20 | | x
35-
21 | | }
36-
| |_____^
26+
= note: ...so that the method type is compatible with trait:
27+
expected fn(&i32, &'a u32, &u32) -> &'a u32
28+
found fn(&i32, &u32, &u32) -> &u32
3729

3830
error: aborting due to previous error
3931

0 commit comments

Comments
 (0)