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

Don't suggest changing extern crate w/ alias to use. #60252

Merged
merged 2 commits into from May 18, 2019

Conversation

Projects
None yet
6 participants
@davidtwco
Copy link
Member

commented Apr 25, 2019

Fixes #57672.

davidtwco added some commits Apr 25, 2019

Add test for current behaviour.
This commit adds a test that causes a suggestion to replace `extern
crate` with `use` when doing so would cause a compliation error, as the
new name of the import would not be added to the prelude if a `use` was
used.
Do not suggest use over extern crate w/ alias.
This commit stops `unused_extern_crates` lints from occuring on `extern
crate` statements that alias the crate as the suggestion to change to a
`use` statement would result in the aliased name no longer being added
to the prelude, thereby causing compilation errors if other imports
expected this to be the case.
@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented Apr 25, 2019

r? @eddyb

(rust_highfive has picked a reviewer for you, use r? to override)

// expecting it.
if extern_crate.orig_name.is_some() {
continue;
}

This comment has been minimized.

Copy link
@davidtwco

davidtwco Apr 25, 2019

Author Member

I would have liked to come up with a more robust check here that would only omit the lint if there was an instance of the extern crate alias being used from the prelude, but I couldn't work out a nice way to achieve this.

This comment has been minimized.

Copy link
@Mark-Simulacrum

Mark-Simulacrum May 18, 2019

Member

Personally that doesn't seem necessary, and somewhat out of scope for this lint -- that seems more like an "unused extern crate" lint rather than an idiom lint.

@davidtwco

This comment has been minimized.

Copy link
Member Author

commented Apr 25, 2019

@rust-highfive rust-highfive assigned estebank and unassigned eddyb Apr 25, 2019

@Mark-Simulacrum

This comment has been minimized.

Copy link
Member

commented May 18, 2019

@bors r+

This looks fine to me based on the updated tests, so I'm going to approve this. If necessary we can always revert.

r? @Mark-Simulacrum

@bors

This comment has been minimized.

Copy link
Contributor

commented May 18, 2019

📌 Commit 8869bc5 has been approved by Mark-Simulacrum

@bors

This comment has been minimized.

Copy link
Contributor

commented May 18, 2019

⌛️ Testing commit 8869bc5 with merge c6f3bdb...

bors added a commit that referenced this pull request May 18, 2019

Auto merge of #60252 - davidtwco:issue-57672, r=Mark-Simulacrum
Don't suggest changing extern crate w/ alias to use.

Fixes #57672.
@bors

This comment has been minimized.

Copy link
Contributor

commented May 18, 2019

⌛️ Testing commit 8869bc5 with merge 9a9df55...

bors added a commit that referenced this pull request May 18, 2019

Auto merge of #60252 - davidtwco:issue-57672, r=Mark-Simulacrum
Don't suggest changing extern crate w/ alias to use.

Fixes #57672.
@bors

This comment has been minimized.

Copy link
Contributor

commented May 18, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: Mark-Simulacrum
Pushing 9a9df55 to master...

@bors bors added the merged-by-bors label May 18, 2019

@bors bors merged commit 8869bc5 into rust-lang:master May 18, 2019

2 checks passed

Travis CI - Pull Request Build Passed
Details
homu Test successful
Details

@davidtwco davidtwco deleted the davidtwco:issue-57672 branch May 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.