Tweak presentation on lifetime trait mismatch

This commit is contained in:
Esteban Küber 2018-01-26 16:38:07 -08:00
parent bacb5c58df
commit ee06559576
2 changed files with 10 additions and 20 deletions

View File

@ -23,12 +23,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
if let Some((expected, found)) = self.values_str(&trace.values) { if let Some((expected, found)) = self.values_str(&trace.values) {
let expected = expected.content(); let expected = expected.content();
let found = found.content(); let found = found.content();
// FIXME: do we want a "the" here? err.note(&format!("...so that the {}:\nexpected {}\n found {}",
err.span_note(trace.cause.span, trace.cause.as_requirement_str(),
&format!("...so that {} (expected {}, found {})", expected,
trace.cause.as_requirement_str(), found));
expected,
found));
} else { } else {
// FIXME: this really should be handled at some earlier stage. Our // FIXME: this really should be handled at some earlier stage. Our
// handling of region checking when type errors are present is // handling of region checking when type errors are present is

View File

@ -13,13 +13,9 @@ note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on th
20 | | x 20 | | x
21 | | } 21 | | }
| |_____^ | |_____^
note: ...so that method type is compatible with trait (expected fn(&i32, &'a u32, &u32) -> &'a u32, found fn(&i32, &u32, &u32) -> &u32) = note: ...so that the method type is compatible with trait:
--> $DIR/mismatched_trait_impl.rs:19:5 expected fn(&i32, &'a u32, &u32) -> &'a u32
| found fn(&i32, &u32, &u32) -> &u32
19 | / fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 { //~ ERROR cannot infer
20 | | x
21 | | }
| |_____^
note: but, the lifetime must be valid for the lifetime 'a as defined on the method body at 19:5... note: but, the lifetime must be valid for the lifetime 'a as defined on the method body at 19:5...
--> $DIR/mismatched_trait_impl.rs:19:5 --> $DIR/mismatched_trait_impl.rs:19:5
| |
@ -27,13 +23,9 @@ note: but, the lifetime must be valid for the lifetime 'a as defined on the meth
20 | | x 20 | | x
21 | | } 21 | | }
| |_____^ | |_____^
note: ...so that method type is compatible with trait (expected fn(&i32, &'a u32, &u32) -> &'a u32, found fn(&i32, &u32, &u32) -> &u32) = note: ...so that the method type is compatible with trait:
--> $DIR/mismatched_trait_impl.rs:19:5 expected fn(&i32, &'a u32, &u32) -> &'a u32
| found fn(&i32, &u32, &u32) -> &u32
19 | / fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 { //~ ERROR cannot infer
20 | | x
21 | | }
| |_____^
error: aborting due to previous error error: aborting due to previous error