Separate unstable feature errors from other lints in output

73405c5
Opened by John Hodge (Mutabah) at 2023-09-24 16:41:36

When an unstable feature is used in a crate, and an error is emitted, it will sometimes (always?) be emitted before other lints (e.g. unused_*, dead_code). This causes the compilation error to be functionally lost in the compile output.

Example:

warning: ignoring specified output filename because multiple outputs were requested
Core/metadevs/storage.rs:250:32: 250:58 error: use of unstable library feature 'step_by': recent addition
Core/metadevs/storage.rs:250            for (blk,dst) in (first .. ).step_by(block_step as u64).zip( dst.chunks_mut( block_step * block_size ) )
                                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~
Core/metadevs/storage.rs:250:32: 250:58 help: add #![feature(step_by)] to the crate attributes to enable
Core/lib/mod.rs:9:5: 9:18 warning: unused import, #[warn(unused_imports)] on by default
Core/lib/mod.rs:9 use lib::mem::Box;
                      ^~~~~~~~~~~~~
Core/lib/mem/rc.rs:8:20: 8:31 warning: unused import, #[warn(unused_imports)] on by default
Core/lib/mem/rc.rs:8 use core::atomic::{AtomicUsize,Ordering};

(An excerpt from compiling a kernel, there are a lot of warnings due to incomplete/unused APIs)

  1. More generally, lints set to deny should probably run after lints set to warn.

    Rewi Haar at 2015-04-21 08:36:52

  2. Is there any plan for this being addressed soon? (I just got hit by the new &mut transmute lint)

    John Hodge (Mutabah) at 2015-05-09 10:23:31

  3. @thepowersgang are you still dealing with this in the new error messages?

    For example,

    fn main() { 
        panic!();
        
        unsafe { asm!(""); }
        
        println!("hello");
    }
    

    the asm and println are unreachable here, and with the feature flag, will show that warning. Without the flag, compilation fails, and you only get that failure, not the warning.

    Steve Klabnik at 2016-11-29 20:05:34

  4. The feature check for asm happens well before library feature checks. The following snippet shows an unstable error, followed by thee dead_code lints.

    fn main() {
    }
    
    fn foo<T: ::std::io::Read>(mut v: T) {
        let v = v.chars();
    }
    

    John Hodge (Mutabah) at 2016-11-29 23:51:06