Skip to content
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

parse: unify item parsing & filter illegal item kinds #69366

Merged
merged 17 commits into from Feb 24, 2020

Conversation

@Centril
Copy link
Member

Centril commented Feb 22, 2020

This PR fully unifies item parsing into a single fn parse_item_common method which produces Option<Item>. The Item is then mapped into ForeignItem and AssocItem as necessary by transforming the *Kind and converting contextually bad variants into None, thereby filtering them away.

The PR does not yet unmerge the definition of ForeignItemKind from AssocItemKind. I've left that as future work as it didn't feel like this parser-focused PR would be the best one to deal with it. Changes to the AST data structures are instead kept to a reasonable minimum.

Based on #69361.

Fixes #48137.
RELNOTES: Now, item macro fragments can be interpolated into impl, trait, and extern contexts. See src/test/ui/parser/issue-48137-macros-cannot-interpolate-impl-items.rs for the relevant test.

r? @petrochenkov
cc @estebank

src/libsyntax/ast.rs Outdated Show resolved Hide resolved
src/librustc_parse/parser/item.rs Outdated Show resolved Hide resolved
src/librustc_parse/parser/item.rs Outdated Show resolved Hide resolved
src/librustc_parse/parser/item.rs Outdated Show resolved Hide resolved
src/test/ui/parser/default-on-wrong-item-kind.stderr Outdated Show resolved Hide resolved
@petrochenkov

This comment has been minimized.

Copy link
Contributor

petrochenkov commented Feb 22, 2020

This almost fixes #48137 (which is the end goal here), except that #69366 (comment) needs to be fixed and maybe_whole!(NtItem) needs to be moved inside parse_item_common.

@petrochenkov

This comment has been minimized.

Copy link
Contributor

petrochenkov commented Feb 22, 2020

LGTM in general, except I disagree with placing Defaultness into Item and the defaultness parsing rules not aligning with #69366 (comment).

@petrochenkov

This comment has been minimized.

Copy link
Contributor

petrochenkov commented Feb 22, 2020

The super-goal is making parse_stmt the basic routine instead of parse_item and handling stuff like lets and other copypaste from function bodies at module level gracefully :)

@bors

This comment was marked as resolved.

Copy link
Contributor

bors commented Feb 23, 2020

☔️ The latest upstream changes (presumably #69334) made this pull request unmergeable. Please resolve the merge conflicts.

@petrochenkov

This comment has been minimized.

Copy link
Contributor

petrochenkov commented Feb 23, 2020

Left a few wording nits regarding incomplete sentences in primary messages.

@Centril Centril force-pushed the Centril:unified-items branch from 8f215bf to 0564b71 Feb 23, 2020
@Centril

This comment has been minimized.

Copy link
Member Author

Centril commented Feb 23, 2020

Also, I threw in a small refactoring 0564b71 which I had not pushed yet.

@petrochenkov

This comment has been minimized.

Copy link
Contributor

petrochenkov commented Feb 23, 2020

Also, I threw in a small refactoring 0564b71 which I had not pushed yet.

Yeah, I've seen it.

@petrochenkov

This comment has been minimized.

Copy link
Contributor

petrochenkov commented Feb 23, 2020

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 23, 2020

📌 Commit d7f39d5 has been approved by petrochenkov

@bors

This comment was marked as resolved.

Copy link
Contributor

bors commented Feb 23, 2020

☔️ The latest upstream changes (presumably #69393) made this pull request unmergeable. Please resolve the merge conflicts.

@Centril Centril force-pushed the Centril:unified-items branch from d7f39d5 to 1c75f5a Feb 24, 2020
@Centril

This comment has been minimized.

Copy link
Member Author

Centril commented Feb 24, 2020

@bors r=petrochenkov

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 24, 2020

📌 Commit 1c75f5a has been approved by petrochenkov

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 24, 2020

⌛️ Testing commit 1c75f5a with merge 79cd224...

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 24, 2020

☀️ Test successful - checks-azure
Approved by: petrochenkov
Pushing 79cd224 to master...

@bors bors added the merged-by-bors label Feb 24, 2020
@bors bors merged commit 79cd224 into rust-lang:master Feb 24, 2020
5 checks passed
5 checks passed
homu Test successful
Details
pr Build #20200224.1 succeeded
Details
pr (Linux mingw-check) Linux mingw-check succeeded
Details
pr (Linux x86_64-gnu-llvm-7) Linux x86_64-gnu-llvm-7 succeeded
Details
pr (Linux x86_64-gnu-tools) Linux x86_64-gnu-tools succeeded
Details
@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Feb 24, 2020

📣 Toolstate changed by #69366!

Tested on commit 79cd224.
Direct link to PR: #69366

💔 clippy-driver on windows: test-pass → build-fail (cc @mcarton @oli-obk @Manishearth @flip1995 @yaahc @phansch @llogiq).
💔 clippy-driver on linux: test-pass → build-fail (cc @mcarton @oli-obk @Manishearth @flip1995 @yaahc @phansch @llogiq).

rust-highfive added a commit to rust-lang-nursery/rust-toolstate that referenced this pull request Feb 24, 2020
Tested on commit rust-lang/rust@79cd224.
Direct link to PR: <rust-lang/rust#69366>

💔 clippy-driver on windows: test-pass → build-fail (cc @mcarton @oli-obk @Manishearth @flip1995 @yaahc @phansch @llogiq).
💔 clippy-driver on linux: test-pass → build-fail (cc @mcarton @oli-obk @Manishearth @flip1995 @yaahc @phansch @llogiq).
JohnTitor added a commit to JohnTitor/rust-clippy that referenced this pull request Feb 24, 2020
bors added a commit to rust-lang/rust-clippy that referenced this pull request Feb 24, 2020
Rustup to rust-lang/rust#69366

changelog: none
@Centril Centril deleted the Centril:unified-items branch Feb 24, 2020
bors added a commit that referenced this pull request Feb 24, 2020
Update Clippy from 8fbb23f to fc5d0cc

Fixes #69419

```
Fix false positive in `missing_const_for_fn`
Rustup to #69366
Add new lint [`wildcard imports`]. Add suggestion to [`enum_glob_use`]
Add new lint `lossy_float_literal` to detect lossy whole number float literals
```
bors added a commit that referenced this pull request Feb 25, 2020
Update Clippy from 8fbb23f to fc5d0cc

Fixes #69419

```
Fix false positive in `missing_const_for_fn`
Rustup to #69366
Add new lint [`wildcard imports`]. Add suggestion to [`enum_glob_use`]
Add new lint `lossy_float_literal` to detect lossy whole number float literals
```
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Feb 25, 2020
syntax: Remove `Nt(Impl,Trait,Foreign)Item`

Follow-up to rust-lang#69366.
r? @Centril
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Feb 26, 2020
syntax: Remove `Nt(Impl,Trait,Foreign)Item`

Follow-up to rust-lang#69366.
r? @Centril
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

4 participants
You can’t perform that action at this time.