Skip to content

'cargo fix --edition-idioms' deletes the crate in '#[cfg_attr(test, macro_use)] extern crate foo;' #6360

@ExpHP

Description

@ExpHP

Running cargo fix --edition-idioms on the following causes cargo to delete the text extern crate itertools; as shown, leaving behind an orphaned attribute and trailing whitespace. Needless to say, this transformation is not correct.

Cargo.toml

[package]
name = "lollol"
version = "0.1.0"
edition = "2018"

[dependencies]
itertools = "0.7.11"

src/main.rs

- #[cfg_attr(test, macro_use)] extern crate itertools;
+ #[cfg_attr(test, macro_use)] 
  use itertools::Itertools;

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

  #[test]
  fn test() {
      println!("{:?}", izip!((0..1), (0..1)).collect_vec());
  }

Besides the orphaned attribute that is now incorrectly applied to the use on the next line, tests now fail to compile due to missing izip!.


cargo 1.32.0-nightly (b3d0b2e54 2018-11-15)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions