diff --git a/clippy_utils/src/qualify_min_const_fn.rs b/clippy_utils/src/qualify_min_const_fn.rs index b2ce58b597b3..37716fa13afd 100644 --- a/clippy_utils/src/qualify_min_const_fn.rs +++ b/clippy_utils/src/qualify_min_const_fn.rs @@ -375,8 +375,8 @@ fn is_const_fn(tcx: TyCtxt<'_>, def_id: DefId, msrv: Option<&RustcVersion>) -> b .expect("`rustc_attr::StabilityLevel::Stable::since` is ill-formatted"), ) } else { - // `rustc_mir::const_eval::is_const_fn` should return false for unstably const functions. - unreachable!(); + // Unstable const fn with the feature enabled. + msrv.is_none() } } else { true diff --git a/tests/ui/crashes/ice-7126.rs b/tests/ui/crashes/ice-7126.rs new file mode 100644 index 000000000000..ca563ba09785 --- /dev/null +++ b/tests/ui/crashes/ice-7126.rs @@ -0,0 +1,14 @@ +// This test requires a feature gated const fn and will stop working in the future. + +#![feature(const_btree_new)] + +use std::collections::BTreeMap; + +struct Foo(BTreeMap); +impl Foo { + fn new() -> Self { + Self(BTreeMap::new()) + } +} + +fn main() {}