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

edition idioms: Incorrect suggestion for removing extern crate ignore; #56326

Closed
alexcrichton opened this issue Nov 28, 2018 · 0 comments · Fixed by #56759
Closed

edition idioms: Incorrect suggestion for removing extern crate ignore; #56326

alexcrichton opened this issue Nov 28, 2018 · 0 comments · Fixed by #56759
Labels
A-edition-2018-lints Area: lints supporting the 2018 edition A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`.

Comments

@alexcrichton
Copy link
Member

Given this code:

$ cat ignore.rs
#![crate_type = "lib"]

pub fn foo() {}
$ cat foo.rs
#![warn(rust_2018_idioms)]

extern crate ignore;

fn main() {
    ignore::foo();
}
$ rustc +beta ignore.rs
$ rustc +beta foo.rs --extern ignore=./libignore.rlib --edition 2018
warning: `extern crate` is not idiomatic in the new edition
 --> foo.rs:3:1
  |
3 | extern crate ignore;
  | ^^^^^^^^^^^^^^^^^^^^ help: convert it to a `use`
  |
note: lint level defined here
 --> foo.rs:1:9
  |
1 | #![warn(rust_2018_idioms)]
  |         ^^^^^^^^^^^^^^^^
  = note: #[warn(unused_extern_crates)] implied by #[warn(rust_2018_idioms)]

If applied, though, the suggestion yields:

$ rustc +beta foo.rs --extern ignore=./libignore.rlib --edition 2018
error[E0658]: imports can only refer to extern crate names passed with `--extern` on stable channel (see issue #53130)
 --> foo.rs:3:5
  |
3 | use ignore;
  |     ^^^^^^ not an extern crate passed with `--extern`
  |
note: this import refers to the built-in attribute imported here
 --> foo.rs:3:5
  |
3 | use ignore;
  |     ^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.

First reported at rust-lang/cargo#6353 along with a suggestion of how to fix it

@alexcrichton alexcrichton added the A-edition-2018-lints Area: lints supporting the 2018 edition label Nov 28, 2018
illicitonion added a commit to twitter/pants that referenced this issue Dec 5, 2018
@alexcrichton alexcrichton added the A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. label Jan 7, 2019
bors added a commit that referenced this issue Jan 12, 2019
Stabilize `uniform_paths`

Address all the things described in #56417.

Assign visibilities to `macro_rules` items - `pub` to `macro_export`-ed macros and `pub(crate)` to non-exported macros, these visibilities determine how far these macros can be reexported with `use`.

Prohibit use of reexported inert attributes and "tool modules", after renaming (e.g. `use inline as imported_inline`) their respective tools and even compiler passes won't be able to recognize and properly check them.

Also turn use of uniform paths in 2015 macros into an error, I'd prefer to neither remove nor stabilize them right away because I still want to make some experiments in this area (uniform path fallback was added to 2015 macros used on 2018 edition in #56053 (comment)).

UPDATE: The last commit also stabilizes the feature `uniform_paths`.

Closes #53130
Closes #55618
Closes #56326
Closes #56398
Closes #56417
Closes #56821
Closes #57252
Closes #57422
bors added a commit that referenced this issue Jan 12, 2019
Stabilize `uniform_paths`

Address all the things described in #56417.

Assign visibilities to `macro_rules` items - `pub` to `macro_export`-ed macros and `pub(crate)` to non-exported macros, these visibilities determine how far these macros can be reexported with `use`.

Prohibit use of reexported inert attributes and "tool modules", after renaming (e.g. `use inline as imported_inline`) their respective tools and even compiler passes won't be able to recognize and properly check them.

Also turn use of uniform paths in 2015 macros into an error, I'd prefer to neither remove nor stabilize them right away because I still want to make some experiments in this area (uniform path fallback was added to 2015 macros used on 2018 edition in #56053 (comment)).

UPDATE: The last commit also stabilizes the feature `uniform_paths`.

Closes #53130
Closes #55618
Closes #56326
Closes #56398
Closes #56417
Closes #56821
Closes #57252
Closes #57422
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-edition-2018-lints Area: lints supporting the 2018 edition A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant