-
Notifications
You must be signed in to change notification settings - Fork 13.5k
parse: fuse associated and extern items up to defaultness #69194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
2fd1544
ast: move Generics into AssocItemKinds
Centril f06df16
ast: colocate AssocItem with ForeignItem
Centril e2ae717
ast: tweak comments of Foreign/AssocItemKind
Centril 95dc9b9
ast: normalize `ForeignItemKind::Ty` & `AssocItemKind::TyAlias`.
Centril f3e9763
ast: make `= <expr>;` optional in free statics/consts.
Centril 1c2906e
ast/parser: fuse `static` & `const` grammars in all contexts.
Centril f8d2264
parse associated statics.
Centril 35884fe
parse extern consts
Centril 91110fd
ast: make ForeignItemKind an alias of AssocItemKind
Centril 0e0c028
fuse extern & associated item parsing up to defaultness
Centril cf87edf
pprust: unify extern & associated item printing
Centril 5abedd8
visit: unify extern & assoc item visiting
Centril d6238bd
reject assoc statics & extern consts during parsing
Centril fe62bed
print_item_const: remove extraneous space
Centril f12ae4a
ast: tweak AssocItemKind::Macro comment
Centril 045b7d5
ast: add a FIXME
Centril File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/test/ui/parser/assoc-const-underscore-semantic-fail.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Semantically, an associated constant cannot use `_` as a name. | ||
|
||
fn main() {} | ||
|
||
const _: () = { | ||
pub trait A { | ||
const _: () = (); //~ ERROR `const` items in this context need a name | ||
} | ||
impl A for () { | ||
const _: () = (); //~ ERROR `const` items in this context need a name | ||
//~^ ERROR const `_` is not a member of trait `A` | ||
} | ||
struct B; | ||
impl B { | ||
const _: () = (); //~ ERROR `const` items in this context need a name | ||
} | ||
}; |
27 changes: 27 additions & 0 deletions
27
src/test/ui/parser/assoc-const-underscore-semantic-fail.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
error: `const` items in this context need a name | ||
--> $DIR/assoc-const-underscore-semantic-fail.rs:7:15 | ||
| | ||
LL | const _: () = (); | ||
| ^ `_` is not a valid name for this `const` item | ||
|
||
error: `const` items in this context need a name | ||
--> $DIR/assoc-const-underscore-semantic-fail.rs:10:15 | ||
| | ||
LL | const _: () = (); | ||
| ^ `_` is not a valid name for this `const` item | ||
|
||
error: `const` items in this context need a name | ||
--> $DIR/assoc-const-underscore-semantic-fail.rs:15:15 | ||
| | ||
LL | const _: () = (); | ||
| ^ `_` is not a valid name for this `const` item | ||
|
||
error[E0438]: const `_` is not a member of trait `A` | ||
--> $DIR/assoc-const-underscore-semantic-fail.rs:10:9 | ||
| | ||
LL | const _: () = (); | ||
| ^^^^^^^^^^^^^^^^^ not a member of trait `A` | ||
|
||
error: aborting due to 4 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0438`. |
18 changes: 18 additions & 0 deletions
18
src/test/ui/parser/assoc-const-underscore-syntactic-pass.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// All constant items (associated or otherwise) may syntactically use `_` as a name. | ||
|
||
// check-pass | ||
|
||
fn main() {} | ||
|
||
#[cfg(FALSE)] | ||
const _: () = { | ||
pub trait A { | ||
const _: () = (); | ||
} | ||
impl A for () { | ||
const _: () = (); | ||
} | ||
impl dyn A { | ||
const _: () = (); | ||
} | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Syntactically, a foreign static may not have a body. | ||
|
||
fn main() {} | ||
|
||
extern { | ||
static X: u8 = 0; //~ ERROR incorrect `static` inside `extern` block | ||
static mut Y: u8 = 0; //~ ERROR incorrect `static` inside `extern` block | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.