From ee065595767a7e024f1933e175dd52936f0f1b10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 26 Jan 2018 16:38:07 -0800 Subject: [PATCH] Tweak presentation on lifetime trait mismatch --- src/librustc/infer/error_reporting/note.rs | 10 ++++------ .../mismatched_trait_impl.stderr | 20 ++++++------------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/librustc/infer/error_reporting/note.rs b/src/librustc/infer/error_reporting/note.rs index e46613b3e4d..02ec9fe74c1 100644 --- a/src/librustc/infer/error_reporting/note.rs +++ b/src/librustc/infer/error_reporting/note.rs @@ -23,12 +23,10 @@ pub(super) fn note_region_origin(&self, if let Some((expected, found)) = self.values_str(&trace.values) { let expected = expected.content(); let found = found.content(); - // FIXME: do we want a "the" here? - err.span_note(trace.cause.span, - &format!("...so that {} (expected {}, found {})", - trace.cause.as_requirement_str(), - expected, - found)); + err.note(&format!("...so that the {}:\nexpected {}\n found {}", + trace.cause.as_requirement_str(), + expected, + found)); } else { // FIXME: this really should be handled at some earlier stage. Our // handling of region checking when type errors are present is diff --git a/src/test/ui/in-band-lifetimes/mismatched_trait_impl.stderr b/src/test/ui/in-band-lifetimes/mismatched_trait_impl.stderr index e96f7181a6d..e559405dbd8 100644 --- a/src/test/ui/in-band-lifetimes/mismatched_trait_impl.stderr +++ b/src/test/ui/in-band-lifetimes/mismatched_trait_impl.stderr @@ -13,13 +13,9 @@ note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on th 20 | | x 21 | | } | |_____^ -note: ...so that method type is compatible with trait (expected fn(&i32, &'a u32, &u32) -> &'a u32, found fn(&i32, &u32, &u32) -> &u32) - --> $DIR/mismatched_trait_impl.rs:19:5 - | -19 | / fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 { //~ ERROR cannot infer -20 | | x -21 | | } - | |_____^ + = note: ...so that the method type is compatible with trait: + expected fn(&i32, &'a u32, &u32) -> &'a u32 + found fn(&i32, &u32, &u32) -> &u32 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 | @@ -27,13 +23,9 @@ note: but, the lifetime must be valid for the lifetime 'a as defined on the meth 20 | | x 21 | | } | |_____^ -note: ...so that method type is compatible with trait (expected fn(&i32, &'a u32, &u32) -> &'a u32, found fn(&i32, &u32, &u32) -> &u32) - --> $DIR/mismatched_trait_impl.rs:19:5 - | -19 | / fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 { //~ ERROR cannot infer -20 | | x -21 | | } - | |_____^ + = note: ...so that the method type is compatible with trait: + expected fn(&i32, &'a u32, &u32) -> &'a u32 + found fn(&i32, &u32, &u32) -> &u32 error: aborting due to previous error