From bc258791eb4cc5802c261afc2b923b2875c0736d Mon Sep 17 00:00:00 2001 From: Shantanu Raj Date: Fri, 5 Aug 2016 17:14:47 +0530 Subject: [PATCH 1/2] Update E0207 to use struct_span_err, add span_label --- src/librustc_typeck/collect.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 4486748a1f05..dfffe3a4a905 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -2314,8 +2314,12 @@ fn report_unused_parameter(ccx: &CrateCtxt, kind: &str, name: &str) { - span_err!(ccx.tcx.sess, span, E0207, - "the {} parameter `{}` is not constrained by the \ - impl trait, self type, or predicates", - kind, name); + struct_span_err!( + ccx.tcx.sess, span, E0207, + "the {} parameter `{}` is not constrained by the \ + impl trait, self type, or predicates", + kind, name) + .span_label(span, &format!("unconstrained lifetime parameter")) + .emit(); + } From 58b618e5270a1bef26ad1ed95820c22e09b24ec5 Mon Sep 17 00:00:00 2001 From: Shantanu Raj Date: Sat, 6 Aug 2016 00:04:27 +0530 Subject: [PATCH 2/2] Update unit tests to accord for label in E0207 --- src/test/compile-fail/E0207.rs | 1 + src/test/compile-fail/impl-unused-rps-in-assoc-type.rs | 1 + src/test/compile-fail/issue-22886.rs | 1 + src/test/compile-fail/issue-35139.rs | 1 + 4 files changed, 4 insertions(+) diff --git a/src/test/compile-fail/E0207.rs b/src/test/compile-fail/E0207.rs index bd87dbaf786a..43ff085a4fa8 100644 --- a/src/test/compile-fail/E0207.rs +++ b/src/test/compile-fail/E0207.rs @@ -11,6 +11,7 @@ struct Foo; impl Foo { //~ ERROR E0207 + //~| NOTE unconstrained lifetime parameter fn get(&self) -> T { ::default() } diff --git a/src/test/compile-fail/impl-unused-rps-in-assoc-type.rs b/src/test/compile-fail/impl-unused-rps-in-assoc-type.rs index 23401db21d89..d48433ee928f 100644 --- a/src/test/compile-fail/impl-unused-rps-in-assoc-type.rs +++ b/src/test/compile-fail/impl-unused-rps-in-assoc-type.rs @@ -19,6 +19,7 @@ trait Fun { struct Holder { x: String } impl<'a> Fun for Holder { //~ ERROR E0207 + //~| NOTE unconstrained lifetime parameter type Output = &'a str; fn call<'b>(&'b self) -> &'b str { &self.x[..] diff --git a/src/test/compile-fail/issue-22886.rs b/src/test/compile-fail/issue-22886.rs index 4aa2571cad0c..d258a4a8b332 100644 --- a/src/test/compile-fail/issue-22886.rs +++ b/src/test/compile-fail/issue-22886.rs @@ -21,6 +21,7 @@ fn crash_please() { struct Newtype(Option>); impl<'a> Iterator for Newtype { //~ ERROR E0207 + //~| NOTE unconstrained lifetime parameter type Item = &'a Box; fn next(&mut self) -> Option<&Box> { diff --git a/src/test/compile-fail/issue-35139.rs b/src/test/compile-fail/issue-35139.rs index 67f0e7aaf971..5c4f161a5004 100644 --- a/src/test/compile-fail/issue-35139.rs +++ b/src/test/compile-fail/issue-35139.rs @@ -17,6 +17,7 @@ pub trait MethodType { pub struct MTFn; impl<'a> MethodType for MTFn { //~ ERROR E0207 + //~| NOTE unconstrained lifetime parameter type GetProp = fmt::Debug + 'a; }