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

davidtwco
Copy link
Member

Fixes #57672.

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.
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
Copy link
Collaborator

r? @eddyb

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 25, 2019
// expecting it.
if extern_crate.orig_name.is_some() {
continue;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member Author

r? @estebank

@rust-highfive rust-highfive assigned estebank and unassigned eddyb Apr 25, 2019
@Mark-Simulacrum
Copy link
Member

@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
Copy link
Contributor

bors commented May 18, 2019

📌 Commit 8869bc5 has been approved by Mark-Simulacrum

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 18, 2019
@bors
Copy link
Contributor

bors commented May 18, 2019

⌛ Testing commit 8869bc5 with merge c6f3bdb8eefd2ad16b4820121b323d6d4e7bce6c...

@bors
Copy link
Contributor

bors commented May 18, 2019

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

bors added a commit that referenced this pull request May 18, 2019
Don't suggest changing extern crate w/ alias to use.

Fixes #57672.
@bors
Copy link
Contributor

bors 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 This PR was explicitly merged by bors. label May 18, 2019
@bors bors merged commit 8869bc5 into rust-lang:master May 18, 2019
@davidtwco davidtwco deleted the issue-57672 branch May 20, 2019 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unused_extern_crates: wrong suggestion for aliased crate
6 participants