unused-features only warns unused non-language features

994b826
Opened by Florian Hahn at 2025-03-01 11:40:05

For the following snippet, rustc only warns about rustc_privat being unused:

#![feature(rustc_private)]
#![feature(box_syntax)]
#![feature(trace_macros)]
#![feature(slicing_syntax)]
#![feature(log_syntax)]

fn main() {}

According to the documentation, check_unused_or_stable_features only checks unused non-langauge features, but it is the only place that emits UNSUSED_FEATURES.

  1. I would like to work on a patch for this issue. Would it make sense to collect language feature usage in synatx::feature_gate::PostExpansionVisitor and check for unused language features in ``synatx::feature_gate::check_crate`?

    Florian Hahn at 2015-03-19 20:51:14

  2. Triage: today, this says that slicing_syntax is stable, but only complains about rustc_private. Removing that and leaving box_syntax, trace_macros, and log_syntax actually compiles with no warnings whatsoever, even though they don't appear to be used?

    Steve Klabnik at 2016-06-06 20:06:00

  3. Some more undetected ones:

    #![feature(slice_patterns)]
    #![feature(inclusive_range_syntax)]
    #![feature(type_ascription)]
    #![feature(asm)]
    #![feature(stmt_expr_attributes)]
    #![feature(conservative_impl_trait)]
    #![feature(const_fn)]
    

    leonardo-m at 2017-08-20 17:29:50

  4. When enabling incremental compilation we removed the global state that contained all used unstable features and thus had to remove the unused features warning.

    bjorn3 at 2023-07-15 13:08:42