Skip to content

edition idioms: Incorrect span in extern crate removal #56328

Description

@alexcrichton

First reported upstream this code:

#![warn(rust_2018_idioms)]

#[cfg_attr(test, macro_use)]
extern crate itertools;

use itertools::Itertools;

fn main() {
    println!("{:?}", (0..1).collect_vec());
}

when compiled yields:

warning: unused extern crate
 --> src/main.rs:4:1
  |
4 | extern crate itertools;
  | ^^^^^^^^^^^^^^^^^^^^^^^ help: remove it
  |
note: lint level defined here
 --> src/main.rs:1:9
  |
1 | #![warn(rust_2018_idioms)]
  |         ^^^^^^^^^^^^^^^^
  = note: #[warn(unused_extern_crates)] implied by #[warn(rust_2018_idioms)]

but the suggestion is incorrect! Both the extern crate and the attribute on the item should be removed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-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`C-enhancementCategory: An issue proposing an enhancement or a PR with one.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.L-unused_extern_cratesLint: unused_extern_cratesT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions