Closed
Description
#![feature(associated_consts)]
fn main() {}
pub struct SomeStruct<T: Nameable> {
t: T,
}
impl<T: Nameable> Nameable for SomeStruct<T> {
const NAME: &'static str = T::NAME;
}
pub trait Nameable {
const NAME: &'static str = "generic runnable";
}
Given the code above, it seems to compile on the playpen.
But if I add that same code to the 'script' crate in Servo (as you can see in this branch), I get this error:
error[E0311]: the parameter type `T` may not live long enough
--> /Users/corey/dev/servo/components/script/script_thread.rs:229:32
|
229 | const NAME: &'static str = T::NAME;
| ^^^^^^^
|
= help: consider adding an explicit lifetime bound for `T`
note: the parameter type `T` must be valid for the expression at 229:31...
--> /Users/corey/dev/servo/components/script/script_thread.rs:229:32
|
229 | const NAME: &'static str = T::NAME;
| ^^^^^^^
note: ...so that a type/lifetime parameter is in scope here
--> /Users/corey/dev/servo/components/script/script_thread.rs:229:32
|
229 | const NAME: &'static str = T::NAME;
| ^^^^^^^
error: aborting due to previous error
error: Could not compile `script`.
At the time of writing, Servo is on nightly-2017-06-09, and the code compiles fine when isolated to a single file.