icedland / iced

Blazing fast and correct x86/x64 disassembler, assembler, decoder, encoder for Rust, .NET, Java, Python, Lua
MIT License
2.91k stars 232 forks source link

Redundant import warnings. #522

Closed vext01 closed 7 months ago

vext01 commented 7 months ago

The latest rust nightly finds loads of redundant imports:

...
warning: the item `Vec` is imported redundantly                                                                                                                                                                                               
   --> iced-x86/src/formatter/gas/mem_size_tbl.rs:8:5                                                                                                                                                                                         
    |                                                                                                                                                                                                                                         
8   | use alloc::vec::Vec;                                                                                                                                                                                                                    
    |     ^^^^^^^^^^^^^^^                                                                                                                                                                                                                     
    |                                                                                                                                                                                                                                         
   ::: /home/vext01/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:125:13                                                                                                            
    |                                                                                                                                                                                                                                         
125 |     pub use super::v1::*;                                                                                                                                                                                                               
    |             --------- the item `Vec` is already defined here                                                                                                                                                                            

warning: the item `TryInto` is imported redundantly                                                                                                                                                                                           
   --> iced-x86/src/formatter/gas/mem_size_tbl.rs:9:5                                                                                                                                                                                         
    |                                                                                                                                                                                                                                         
9   | use core::convert::TryInto;                                                                                                                                                                                                             
    |     ^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                                                                              
    |                                                                                                                                                                                                                                         
   ::: /home/vext01/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:129:13                                                                                                            
    |                                                                                                                                                                                                                                         
129 |     pub use core::prelude::rust_2021::*;                                                                                                                                                                                                
    |             ------------------------ the item `TryInto` is already defined here
...
wtfsck commented 7 months ago

Which features did you enable? The CI tests several different combinations but not all possible combinations.

vext01 commented 7 months ago

I just ran cargo test, so I guess the default feature set.

vext01 commented 7 months ago

FWIW, we've been through this dance recently in some of our Rust code. Something changed in rust nightly.

wtfsck commented 7 months ago

I ran cargo test and I seem to have only gotten errors about code_asm since it's not enabled by default.

cargo test --tests showed no warnings, no Vec or TryInto warnings.

vext01 commented 7 months ago

Are you running a recent nightly?

wtfsck commented 7 months ago

No only stable.

vext01 commented 7 months ago

You will probably start seeing these warnings with the next stable version of rust then.

wtfsck commented 7 months ago

They're in nightly but not beta. Seems like when you import something with * you import other use statements too in that module, including eg. use alloc::vec::Vec;. I don't know if this is a new bug. If we get this warning in stable, I may need to just disable that warning since it will be useless.