From ddee9fbc998e345e9a36f2066d51d389aa31a632 Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Fri, 22 Sep 2017 19:13:19 -0700 Subject: Point at parameter type on E0301 On "the parameter type `T` may not live long enough" error, point to the parameter type suggesting lifetime bindings: ``` error[E0310]: the parameter type `T` may not live long enough --> $DIR/lifetime-doesnt-live-long-enough.rs:28:5 | 27 | struct Foo { | - help: consider adding an explicit lifetime bound `T: 'static`... 28 | foo: &'static T | ^^^^^^^^^^^^^^^ | note: ...so that the reference type `&'static T` does not outlive the data it points at --> $DIR/lifetime-doesnt-live-long-enough.rs:28:5 | 28 | foo: &'static T | ^^^^^^^^^^^^^^^ ``` --- src/test/compile-fail/issue-16747.rs | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 src/test/compile-fail/issue-16747.rs (limited to 'src/test/compile-fail') diff --git a/src/test/compile-fail/issue-16747.rs b/src/test/compile-fail/issue-16747.rs deleted file mode 100644 index dd7e8a869ec..00000000000 --- a/src/test/compile-fail/issue-16747.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait ListItem<'a> { - fn list_name() -> &'a str; -} - -trait Collection { fn len(&self) -> usize; } - -struct List<'a, T: ListItem<'a>> { - slice: &'a [T] -//~^ ERROR the parameter type `T` may not live long enough -//~| HELP consider adding an explicit lifetime bound -//~| NOTE ...so that the reference type `&'a [T]` does not outlive the data it points at -} -impl<'a, T: ListItem<'a>> Collection for List<'a, T> { - fn len(&self) -> usize { - 0 - } -} - -fn main() {} -- cgit 1.4.1-3-g733a5