Skip to content

Commit 3dbbb1d

Browse files
committed
Fix ICE checking for feature gated const fn
1 parent 08e36d7 commit 3dbbb1d

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

clippy_utils/src/qualify_min_const_fn.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,8 @@ fn is_const_fn(tcx: TyCtxt<'_>, def_id: DefId, msrv: Option<&RustcVersion>) -> b
375375
.expect("`rustc_attr::StabilityLevel::Stable::since` is ill-formatted"),
376376
)
377377
} else {
378-
// `rustc_mir::const_eval::is_const_fn` should return false for unstably const functions.
379-
unreachable!();
378+
// Unstable const fn with the feature enabled.
379+
msrv.is_none()
380380
}
381381
} else {
382382
true

tests/ui/crashes/ice-7126.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// This test requires a feature gated const fn and will stop working in the future.
2+
3+
#![feature(const_btree_new)]
4+
5+
use std::collections::BTreeMap;
6+
7+
struct Foo(BTreeMap<i32, i32>);
8+
impl Foo {
9+
fn new() -> Self {
10+
Self(BTreeMap::new())
11+
}
12+
}
13+
14+
fn main() {}

0 commit comments

Comments
 (0)