Skip to content

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

Closed
@alexcrichton

Description

@alexcrichton

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-edition-2018Area: The 2018 editionA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions