rustc_lint::builtin

Static RUST_2024_INCOMPATIBLE_PAT

source
pub static RUST_2024_INCOMPATIBLE_PAT: &'static Lint
Expand description

The rust_2024_incompatible_pat lint detects patterns whose meaning will change in the Rust 2024 edition.

§Example

#![feature(ref_pat_eat_one_layer_2024)]
#![warn(rust_2024_incompatible_pat)]

if let Some(&a) = &Some(&0u8) {
    let _: u8 = a;
}
if let Some(mut _a) = &mut Some(0u8) {
    _a = 7u8;
}

{{produces}}

§Explanation

In Rust 2024 and above, the mut keyword does not reset the pattern binding mode, and nor do & or &mut patterns. The lint will suggest code that has the same meaning in all editions.