-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-edition-2018Area: The 2018 editionArea: The 2018 editionA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.A-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.WG-epochWorking group: Epoch (2018) managementWorking group: Epoch (2018) managementregression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
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.
kennytm
Metadata
Metadata
Assignees
Labels
A-edition-2018Area: The 2018 editionArea: The 2018 editionA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.A-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.WG-epochWorking group: Epoch (2018) managementWorking group: Epoch (2018) managementregression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.