rustc_lint_defs::builtin

Static CONST_EVALUATABLE_UNCHECKED

source
pub static CONST_EVALUATABLE_UNCHECKED: &Lint
Expand description

The const_evaluatable_unchecked lint detects a generic constant used in a type.

§Example

const fn foo<T>() -> usize {
    if std::mem::size_of::<*mut T>() < 8 { // size of *mut T does not depend on T
        4
    } else {
        8
    }
}

fn test<T>() {
    let _ = [0; foo::<T>()];
}

{{produces}}

§Explanation

In the 1.43 release, some uses of generic parameters in array repeat expressions were accidentally allowed. This is a future-incompatible lint to transition this to a hard error in the future. See issue #76200 for a more detailed description and possible fixes.