-
-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Rust 2015 type dyn + dyn wrongly rejected by the parser due to "helpful" diagnostic #157565
Copy link
Copy link
Open
Labels
A-dyn-traitArea: trait objects, vtable layoutArea: trait objects, vtable layoutA-edition-2015Area: The 2015 edition (the first edition)Area: The 2015 edition (the first edition)A-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTC-bugCategory: This is a bug.Category: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.P-lowLow priorityLow priorityS-has-bisectionStatus: A bisection has been found for this issueStatus: A bisection has been found for this issueT-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.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Metadata
Metadata
Assignees
Labels
A-dyn-traitArea: trait objects, vtable layoutArea: trait objects, vtable layoutA-edition-2015Area: The 2015 edition (the first edition)Area: The 2015 edition (the first edition)A-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTC-bugCategory: This is a bug.Category: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.P-lowLow priorityLow priorityS-has-bisectionStatus: A bisection has been found for this issueStatus: A bisection has been found for this issueT-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.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Type
Fields
Give feedbackNo fields configured for issues without a type.
In Rust 2015,
dynis only a contextual keyword. It is only meant to be active if it appears in a type context and is followed by a token in the following set: {PathIdentSegment, LIFETIME_OR_LABEL,for,(,?} as dictated bycan_begin_dyn_bound_in_edition_2015(cc rust-lang/reference#2257) (side note: RFC 2113 doesn't actually define the rules).Despite that fact, since 1.54 rustc rejects the following Rust 2015 program:
More concretely, rustc erroneously rejects this code since PR #84896 which only meant to improve diagnostics, not alter the stable grammar of Rust.
Note that
dyn + dyncan be semantically well-formed, too (assuming this parser bug has been fixed). Consider the following contrived Rust 2015 code: