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

Cargo fix fails to apply --edition to block-utils crate #6413

Closed
cholcombe973 opened this issue Dec 9, 2018 · 2 comments
Closed

Cargo fix fails to apply --edition to block-utils crate #6413

cholcombe973 opened this issue Dec 9, 2018 · 2 comments

Comments

@cholcombe973
Copy link

I tried to use cargo fix --edition to upgrade my block-utils crate to the 2018 edition. It fails to apply and gives output suggesting I file a bug so here i am :)

Steps

  1. Checkout master of https://github.com/cholcombe973/block-utils
  2. run cargo fix --edition against it.
  3. Patch fails to apply

Possible Solution(s)

Notes

cargo fix --edition --allow-dirty
    Checking block-utils v0.6.0 (/home/chris/repos/block-utils)                                                                                                        
warning: failed to automatically apply fixes suggested by rustc to crate `block_utils`                                                                                 

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

  * src/lib.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: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition                                                        
 --> src/nvme.rs:5:5                                                                                                                                                   
  |                                                                                                                                                                    
5 | use {BlockResult, BlockUtilsError};                                                                                                                                
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{BlockResult, BlockUtilsError}`                                                                      
  |                                                                                                                                                                    
  = note: `-W absolute-paths-not-starting-with-crate` implied by `-W rust-2018-compatibility`                                                                          
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!                                    
  = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>                                                                      
                                                                                                                                                                       
warning: unused variable: `e`                                                                                                                                          
    --> src/lib.rs:1520:33                                                                                                                                             
     |                                                                                                                                                                 
1520 |             Err(nom::Err::Error(e)) | Err(nom::Err::Failure(e)) => Err(BlockUtilsError::new(                                                                    
     |                                 ^ help: consider using `_e` instead                                                                                             
     |                                                                                                                                                                 
     = note: #[warn(unused_variables)] on by default                                                                                                                   
                                                                                                                                                                       
warning: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition                                                        
 --> src/nvme.rs:5:5                                                                                                                                                   
  |                                                                                                                                                                    
5 | use {BlockResult, BlockUtilsError};                                                                                                                                
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{BlockResult, BlockUtilsError}`                                                                      
  |                                                                                                                                                                    
  = note: `-W absolute-paths-not-starting-with-crate` implied by `-W rust-2018-compatibility`                                                                          
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!                                    
  = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>                                                                      
                                                                                                                                                                       
warning: unused variable: `e`                                                                                                                                          
    --> src/lib.rs:1520:33                                                                                                                                             
     |                                                                                                                                                                 
1520 |             Err(nom::Err::Error(e)) | Err(nom::Err::Failure(e)) => Err(BlockUtilsError::new(                                                                    
     |                                 ^ help: consider using `_e` instead                                                                                             
     |                                                                                                                                                                 
     = note: #[warn(unused_variables)] on by default                                                                                                                   
                                                                                                                                                                       
    Finished dev [unoptimized + debuginfo] target(s) in 5.56s  

Output of cargo version: cargo 1.31.0 (339d9f9 2018-11-16)

rustc --version
rustc 1.31.0 (abe02cefd 2018-12-04)

running on Ubuntu 16.04.4 LTS

@ehuss
Copy link
Contributor

ehuss commented Dec 9, 2018

Thanks for the report. Here is a reproduction:

fn main() {
    enum E {
        A(i32,),
        B(i32,),
    }
    match E::A(1) {
        E::A(x) | E::B(x) => {}
    }
}

The unused_variables lint does not give proper suggestions with | patterns in match arms. It only suggests _x for the first variable, but not the second, causing compilation to fail. Surprisingly I can't find any upstream issues for this.

To work around this, just update your match blocks to use _ or _e for the bindings.

@alexcrichton
Copy link
Member

Thanks for the report @cholcombe973 and the reduction @ehuss! I've moved the suggestion bug to rust-lang/rust as it's a compiler bug and the otherwise relevant but for edition migration is at #5738, so I'm going to close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants