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

Remove `extern crate` when migrating to Rust 2018 #52829

Closed
johnthagen opened this Issue Jul 29, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@johnthagen
Copy link
Contributor

johnthagen commented Jul 29, 2018

Migrated from rust-lang/cargo#5829

It's been mentioned/requested multiple times on the internals thread that cargo fix should remove the extern crate statements when moving to Rust 2018.

Motivation

One of the big draws of Rust 2018's module system is that all of the "redundant" extern crate lines can finally be removed. It took some of the excitement away when I went through all of the cargo fix steps and still saw them there. I think it will just be a better experience for users to see one of the tangible benefits of this change. As it is right now, they just see the crate:: in front of all of their local imports and they might not realize what a nice change the module system updates really are.

After I manually removed the extern crate's I did get my satisfying result 😄, but let's give this to users on the first go around.

Implementation

If I understand correctly this should be implemented in the compiler under the #![warn(rust_2018_idioms)] lints, rather than cargo fix itself.

cc @alexcrichton

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Aug 24, 2018

I'm moving this forward up on the milestone list due to just having closed #52451 in favor of this issue, which was itself on the RC milestone.

@alexcrichton alexcrichton self-assigned this Aug 24, 2018

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Aug 24, 2018

Ok so I've some triaging of extern crate related lint issues, and I believe the current work items are:

  • A rustfix-fixable suggestion for removing extern crate needs to be implemented. The implementation would go here.
  • Currently the lint suggests switching to simply use. While technically correct and handles lots of corner cases, this doesn't achieve the desired goal of actually removing annotations.
  • We can't blanket remove all extern crate statements, for example this test case is correctly warned to use a use rather than deleting the statement outright.

I'm testing out some ideas locally as well.

alexcrichton added a commit to alexcrichton/rust that referenced this issue Aug 24, 2018

rustc: Suggest removing `extern crate` in 2018
This commit updates the `unused_extern_crates` lint to make automatic
suggestions about removing `extern crate` annotations in the 2018 edition. This
ended up being a little easier than originally though due to what's likely been
fixed issues in the resolver!

Closes rust-lang#52829
@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Aug 24, 2018

I believe this should be fixed by #53684, I think the naive solution actually works well!

alexcrichton added a commit to alexcrichton/rust that referenced this issue Aug 27, 2018

rustc: Suggest removing `extern crate` in 2018
This commit updates the `unused_extern_crates` lint to make automatic
suggestions about removing `extern crate` annotations in the 2018 edition. This
ended up being a little easier than originally though due to what's likely been
fixed issues in the resolver!

Closes rust-lang#52829

Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Aug 28, 2018

Rollup merge of rust-lang#53684 - alexcrichton:suggest-remove, r=oli-obk
rustc: Suggest removing `extern crate` in 2018

This commit updates the `unused_extern_crates` lint to make automatic
suggestions about removing `extern crate` annotations in the 2018 edition. This
ended up being a little easier than originally though due to what's likely been
fixed issues in the resolver!

Closes rust-lang#52829

bors added a commit that referenced this issue Aug 29, 2018

Auto merge of #53684 - alexcrichton:suggest-remove, r=oli-obk
rustc: Suggest removing `extern crate` in 2018

This commit updates the `unused_extern_crates` lint to make automatic
suggestions about removing `extern crate` annotations in the 2018 edition. This
ended up being a little easier than originally though due to what's likely been
fixed issues in the resolver!

Closes #52829

@bors bors closed this in #53684 Aug 29, 2018

dvc94ch added a commit to dvc94ch/rust that referenced this issue Aug 30, 2018

rustc: Suggest removing `extern crate` in 2018
This commit updates the `unused_extern_crates` lint to make automatic
suggestions about removing `extern crate` annotations in the 2018 edition. This
ended up being a little easier than originally though due to what's likely been
fixed issues in the resolver!

Closes rust-lang#52829
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.