Closed
Description
fn main() {
let s = Box::new(S);
let d = s as Box<dyn dyn>;
d.say();
}
trait dyn {
fn say(&self) -> &'static str;
}
struct S;
impl dyn for S {
fn say(&self) -> &'static str { "I'm S!" }
}
Expected: Program outputs "I'm S!" (missed a println) compiles.
Actual:
Compiling playground v0.0.1 (file:///playground)
error: expected `<`, found `S`
--> src/main.rs:13:14
|
13 | impl dyn for S {
| ^ expected `<` here
error: aborting due to previous error
error: Could not compile `playground`.
Since dyn
is a contextual keyword and still allowed as an identifier, I expect to still be able to implement a trait named "dyn" for various structs. And indeed, if I change the trait name to "dyna", it works.
Metadata
Metadata
Assignees
Labels
Area: The 2018 editionArea: Lints (warnings about flaws in source code) such as unused_mut.Area: The lexing & parsing of Rust source code to an ASTRelevant to the compiler team, which will review and decide on the PR/issue.Working group: Epoch (2018) managementPerformance or correctness regression from one stable version to another.