rustc_lint::builtin

Static RUST_2021_INCOMPATIBLE_OR_PATTERNS

source
pub static RUST_2021_INCOMPATIBLE_OR_PATTERNS: &'static Lint
Expand description

The rust_2021_incompatible_or_patterns lint detects usage of old versions of or-patterns.

§Example

#![deny(rust_2021_incompatible_or_patterns)]

macro_rules! match_any {
    ( $expr:expr , $( $( $pat:pat )|+ => $expr_arm:expr ),+ ) => {
        match $expr {
            $(
                $( $pat => $expr_arm, )+
            )+
        }
    };
}

fn main() {
    let result: Result<i64, i32> = Err(42);
    let int: i64 = match_any!(result, Ok(i) | Err(i) => i.into());
    assert_eq!(int, 42);
}

{{produces}}

§Explanation

In Rust 2021, the pat matcher will match additional patterns, which include the | character.