Rust

Rust

Made by DeepSource

Found builtin-type shadow RS-W1028

Bug risk
Major

Generic type parameters or pattern captures that have the same name as certain builtin-types can cause unexpected errors.

Bad practice

fn f<u32>(a: u32) -> u32 {
    0u32 // results in a type error
}

fn f(S { a: i32 }: S) {
    // here, `i32` is a variable that captures `S::a`, and not the builtin-type
}

Recommended

fn f<T>(a: T) -> u32 {
    0
}

fn f(S { a: val }: S) { 
    // `S::a` is captured in `val`
}