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

Add nested groups in imports #45846

Merged
merged 2 commits into from Dec 1, 2017

Conversation

Projects
None yet
8 participants
@pietroalbini
Member

pietroalbini commented Nov 7, 2017

This PR adds support for nested groups in imports (rust-lang/rfcs#2128, tracking issue #44494).

r? @petrochenkov

@rust-highfive

This comment has been minimized.

Show comment
Hide comment
@rust-highfive

rust-highfive Nov 7, 2017

Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @petrochenkov (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

Collaborator

rust-highfive commented Nov 7, 2017

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @petrochenkov (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@pietroalbini

This comment has been minimized.

Show comment
Hide comment
@pietroalbini

pietroalbini Nov 7, 2017

Member

I know some tests are failing right now, but rustc compiles itself successfully and the actual implementation of the feature is ready.

cc @nikomatsakis @eddyb

Member

pietroalbini commented Nov 7, 2017

I know some tests are failing right now, but rustc compiles itself successfully and the actual implementation of the feature is ready.

cc @nikomatsakis @eddyb

Show outdated Hide outdated src/libsyntax/ast.rs Outdated
Show outdated Hide outdated src/libsyntax/ast.rs Outdated
Show outdated Hide outdated src/libsyntax/ast.rs Outdated
Show outdated Hide outdated src/libsyntax/visit.rs Outdated
self.bump();
Ok(P(respan(lo.to(self.span), ViewPathGlob(prefix))))
// `use path::...;`
let mut parsed = self.parse_path(PathStyle::Mod)?;

This comment has been minimized.

@petrochenkov

petrochenkov Nov 12, 2017

Contributor

This will accept use :: ::a::b; :)
(And also use :: $path::{a::b}.)

You really have to parse the prefix as a whole (including the starting ::) if it's a path, and treat "non-path" prefixes Ø and :: specially.

@petrochenkov

petrochenkov Nov 12, 2017

Contributor

This will accept use :: ::a::b; :)
(And also use :: $path::{a::b}.)

You really have to parse the prefix as a whole (including the starting ::) if it's a path, and treat "non-path" prefixes Ø and :: specially.

}
} else {
// `foo::bar` or `foo::bar as baz`

This comment has been minimized.

@petrochenkov

petrochenkov Nov 12, 2017

Contributor

Argh, deleted comment!

@petrochenkov

petrochenkov Nov 12, 2017

Contributor

Argh, deleted comment!

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Nov 12, 2017

Contributor

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

Contributor

bors commented Nov 12, 2017

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

@shepmaster

This comment has been minimized.

Show comment
Hide comment
@shepmaster

shepmaster Nov 18, 2017

Member

Ping from triage @pietroalbini — it's been a week since we last heard from you! Will you be able to address the issues with this PR soon?

Member

shepmaster commented Nov 18, 2017

Ping from triage @pietroalbini — it's been a week since we last heard from you! Will you be able to address the issues with this PR soon?

@pietroalbini

This comment has been minimized.

Show comment
Hide comment
@pietroalbini

pietroalbini Nov 18, 2017

Member

@shepmaster all the review comments were already fixed, but in other files so github didn't hide them ;)
I plan to continue working on the missing parts of the PR (feature flag and tests) in the next few days.

Member

pietroalbini commented Nov 18, 2017

@shepmaster all the review comments were already fixed, but in other files so github didn't hide them ;)
I plan to continue working on the missing parts of the PR (feature flag and tests) in the next few days.

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Nov 21, 2017

Contributor

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

Contributor

bors commented Nov 21, 2017

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

@nikomatsakis

This comment has been minimized.

Show comment
Hide comment
@nikomatsakis

nikomatsakis Nov 21, 2017

Contributor

@pietroalbini what's the status here? How's it going?

Contributor

nikomatsakis commented Nov 21, 2017

@pietroalbini what's the status here? How's it going?

@nikomatsakis

This comment has been minimized.

Show comment
Hide comment
@nikomatsakis

nikomatsakis Nov 21, 2017

Contributor

Oh, I see your comment from 3 days ago. I assume status is still the same.

Contributor

nikomatsakis commented Nov 21, 2017

Oh, I see your comment from 3 days ago. I assume status is still the same.

@pietroalbini

This comment has been minimized.

Show comment
Hide comment
@pietroalbini

pietroalbini Nov 21, 2017

Member

@nikomatsakis yeah, I didn't have time to do either the new tests or the feature flag (I'll try tomorrow), but I did the changes requested by the review and rebased #45771, fixing compatibility issues between the two.

Member

pietroalbini commented Nov 21, 2017

@nikomatsakis yeah, I didn't have time to do either the new tests or the feature flag (I'll try tomorrow), but I did the changes requested by the review and rebased #45771, fixing compatibility issues between the two.

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Nov 23, 2017

Contributor

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

Contributor

bors commented Nov 23, 2017

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

@pietroalbini

This comment has been minimized.

Show comment
Hide comment
@pietroalbini

pietroalbini Nov 23, 2017

Member

Ok, I did a bit more work on this PR today:

  • The feature is now correctly gated (with a test), and I should have blocked every way to use it without the #![feature]
  • I added two tests (one run-pass for the functionality, and a compile-fail for use ::foo::{::bar}). I don't think there are important things not covered by the tests now, but any idea is welcome :)
  • I wrote a page for the unstable book: the page contains both a basic description, and a few snippets I prepared to be added to the book and the reference after the stabilization of the feature

I feel like the PR is almost ready to be fully reviewed and merged now. The only thing missing is that nasty failing test about proc macros, but I can't seem to find out why it fails...

Member

pietroalbini commented Nov 23, 2017

Ok, I did a bit more work on this PR today:

  • The feature is now correctly gated (with a test), and I should have blocked every way to use it without the #![feature]
  • I added two tests (one run-pass for the functionality, and a compile-fail for use ::foo::{::bar}). I don't think there are important things not covered by the tests now, but any idea is welcome :)
  • I wrote a page for the unstable book: the page contains both a basic description, and a few snippets I prepared to be added to the book and the reference after the stabilization of the feature

I feel like the PR is almost ready to be fully reviewed and merged now. The only thing missing is that nasty failing test about proc macros, but I can't seem to find out why it fails...

}
}
use a::{B, d::{self, *, g::H}};

This comment has been minimized.

@petrochenkov

petrochenkov Nov 23, 2017

Contributor

Could you add a test that an "owl import" use ::{*, *}; produces an "unused import" warning pointing to the owl's left eye.

@petrochenkov

petrochenkov Nov 23, 2017

Contributor

Could you add a test that an "owl import" use ::{*, *}; produces an "unused import" warning pointing to the owl's left eye.

@pietroalbini

This comment has been minimized.

Show comment
Hide comment
@pietroalbini

pietroalbini Nov 29, 2017

Member

@bors r=petrochenkov

Member

pietroalbini commented Nov 29, 2017

@bors r=petrochenkov

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Nov 29, 2017

Contributor

📌 Commit cb213ef has been approved by petrochenkov

Contributor

bors commented Nov 29, 2017

📌 Commit cb213ef has been approved by petrochenkov

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Nov 30, 2017

Contributor

⌛️ Testing commit cb213ef with merge b48013c...

Contributor

bors commented Nov 30, 2017

⌛️ Testing commit cb213ef with merge b48013c...

bors added a commit that referenced this pull request Nov 30, 2017

Auto merge of #45846 - pietroalbini:use-nested-groups, r=petrochenkov
Add nested groups in imports

This PR adds support for nested groups in imports (rust-lang/rfcs#2128, tracking issue #44494).

r? @petrochenkov

### Todo

- [x] Fix existing tests failing
- [x] Add new tests to cover the feature
- [x] Put the new behavior behind a feature flag
- [x] Write something for the unstable book
@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Nov 30, 2017

Contributor

💔 Test failed - status-travis

Contributor

bors commented Nov 30, 2017

💔 Test failed - status-travis

@petrochenkov

This comment has been minimized.

Show comment
Hide comment
@petrochenkov

petrochenkov Nov 30, 2017

Contributor

Of course, rustfmt is broken.
This can be fixed by setting rustfmt and rls to "Broken" in https://github.com/rust-lang/rust/blob/master/src/tools/toolstate.toml

It's also desirable to send a PR to rustfmt fixing the breakage.

Contributor

petrochenkov commented Nov 30, 2017

Of course, rustfmt is broken.
This can be fixed by setting rustfmt and rls to "Broken" in https://github.com/rust-lang/rust/blob/master/src/tools/toolstate.toml

It's also desirable to send a PR to rustfmt fixing the breakage.

pietroalbini added some commits Sep 26, 2017

Implement RFC 2128 (use_nested_groups)
This commit adds support for nested groups inside `use` declarations,
such as `use foo::{bar, sub::{baz::Foo, *}};`.
@pietroalbini

This comment has been minimized.

Show comment
Hide comment
@pietroalbini

pietroalbini Nov 30, 2017

Member

Ok, marked rustfmt and rls as broken. I'll look into sending a PR to rustfmt.

@bors r=petrochenkov

Member

pietroalbini commented Nov 30, 2017

Ok, marked rustfmt and rls as broken. I'll look into sending a PR to rustfmt.

@bors r=petrochenkov

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Nov 30, 2017

Contributor

📌 Commit f7f6951 has been approved by petrochenkov

Contributor

bors commented Nov 30, 2017

📌 Commit f7f6951 has been approved by petrochenkov

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Dec 1, 2017

Contributor

⌛️ Testing commit f7f6951 with merge 804b15b...

Contributor

bors commented Dec 1, 2017

⌛️ Testing commit f7f6951 with merge 804b15b...

bors added a commit that referenced this pull request Dec 1, 2017

Auto merge of #45846 - pietroalbini:use-nested-groups, r=petrochenkov
Add nested groups in imports

This PR adds support for nested groups in imports (rust-lang/rfcs#2128, tracking issue #44494).

r? @petrochenkov
@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Dec 1, 2017

Contributor

☀️ Test successful - status-appveyor, status-travis
Approved by: petrochenkov
Pushing 804b15b to master...

Contributor

bors commented Dec 1, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: petrochenkov
Pushing 804b15b to master...

@bors bors merged commit f7f6951 into rust-lang:master Dec 1, 2017

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details

@bors bors referenced this pull request Dec 1, 2017

Merged

Generic Associated Types Parsing & Name Resolution #45904

1 of 3 tasks complete
@theduke

This comment has been minimized.

Show comment
Hide comment
@theduke

theduke Dec 1, 2017

Contributor

@pietroalbini thanks for working on this, I've been waiting for the feature.

Contributor

theduke commented Dec 1, 2017

@pietroalbini thanks for working on this, I've been waiting for the feature.

@pietroalbini pietroalbini deleted the pietroalbini:use-nested-groups branch Dec 1, 2017

@pietroalbini

This comment has been minimized.

Show comment
Hide comment
@pietroalbini

pietroalbini Dec 1, 2017

Member

🎉 🎉 🎉 🎉

Thank you @eddyb, @petrochenkov and @nikomatsakis for helping me during the implementation!

Member

pietroalbini commented Dec 1, 2017

🎉 🎉 🎉 🎉

Thank you @eddyb, @petrochenkov and @nikomatsakis for helping me during the implementation!

bors added a commit that referenced this pull request Mar 17, 2018

Auto merge of #48917 - petrochenkov:import, r=oli-obk
syntax: Make imports in AST closer to the source and cleanup their parsing

This is a continuation of #45846 in some sense.

bors added a commit that referenced this pull request Mar 18, 2018

Auto merge of #48917 - petrochenkov:import, r=oli-obk
syntax: Make imports in AST closer to the source and cleanup their parsing

This is a continuation of #45846 in some sense.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment