Skip to content

cargo fix --edition-idioms fails on extern crate ignore #6353

@illicitonion

Description

@illicitonion

Problem
A module with extern crate ignore; causes auto-fixes to fail.
Expect cargo fix --edition-idioms to succeed. Instead, it errors and asks me to file a bug.

Steps

$ git clone https://github.com/illicitonion/cargo-fix-2018-repro.git
$ cd cargo-fix-2018-repro
$ rustc +beta --version
rustc 1.31.0-beta.17 (1a4f1f398 2018-11-25)
$ cargo +beta --version
cargo 1.31.0-beta (339d9f9c8 2018-11-16)
$ cargo +beta fix --edition-idioms
    Checking rust-ignore-repro v0.0.1 (/home/dwh/tmp/rustplay)                                                                                                                                                                                 
warning: failed to automatically apply fixes suggested by rustc to crate `rust_ignore_repro`                                                                                                                                                   

after fixes were automatically applied the compiler reported errors within these files:

  * src/main.rs

This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see 
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/cargo/issues
quoting the full output of this command we'd be very appreciative!

warning: `extern crate` is not idiomatic in the new edition                                                                                                                                                                                    
 --> src/main.rs:1:1                                                                                                                                                                                                                           
  |                                                                                                                                                                                                                                            
1 | extern crate ignore;                                                                                                                                                                                                                       
  | ^^^^^^^^^^^^^^^^^^^^ help: convert it to a `use`                                                                                                                                                                                           
  |                                                                                                                                                                                                                                            
  = note: `-W unused-extern-crates` implied by `-W rust-2018-idioms`                                                                                                                                                                           
                                                                                                                                                                                                                                               
warning: `extern crate` is not idiomatic in the new edition                                                                                                                                                                                    
 --> src/main.rs:1:1                                                                                                                                                                                                                           
  |                                                                                                                                                                                                                                            
1 | extern crate ignore;                                                                                                                                                                                                                       
  | ^^^^^^^^^^^^^^^^^^^^ help: convert it to a `use`                                                                                                                                                                                           
  |                                                                                                                                                                                                                                            
  = note: `-W unused-extern-crates` implied by `-W rust-2018-idioms`                                                                                                                                                                           
                                                                                                                                                                                                                                               
    Finished dev [unoptimized + debuginfo] target(s) in 0.43s
$ sed -e 's#extern crate#use#g' -i src/main.rs 
$ cargo +beta build
   Compiling rust-ignore-repro v0.0.1 (/home/dwh/tmp/rustplay)                                                                                                                                                                                 
error[E0658]: imports can only refer to extern crate names passed with `--extern` on stable channel (see issue #53130)                                                                                                                         
 --> src/main.rs:1:5                                                                                                                                                                                                                           
  |                                                                                                                                                                                                                                            
1 | use ignore;                                                                                                                                                                                                                                
  |     ^^^^^^ not an extern crate passed with `--extern`                                                                                                                                                                                      
  |                                                                                                                                                                                                                                            
note: this import refers to the built-in attribute imported here                                                                                                                                                                               
 --> src/main.rs:1:5                                                                                                                                                                                                                           
  |                                                                                                                                                                                                                                            
1 | use ignore;                                                                                                                                                                                                                                
  |     ^^^^^^                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                               
error: aborting due to previous error                                                                                                                                                                                                          
                                                                                                                                                                                                                                               
For more information about this error, try `rustc --explain E0658`.                                                                                                                                                                            
error: Could not compile `rust-ignore-repro`.                                                                                                                                                                                                  

To learn more, run the command again with --verbose.

Output of cargo version:

$ rustc +beta --version
rustc 1.31.0-beta.17 (1a4f1f398 2018-11-25)
$ cargo +beta --version
cargo 1.31.0-beta (339d9f9c8 2018-11-16)

If I instead replace with use ::ignore; it seems to work fine.

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