Skip to content

Commit

Permalink
Fix ICE checking for feature gated const fn
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarcho committed Apr 25, 2021
1 parent 08e36d7 commit 3dbbb1d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions clippy_utils/src/qualify_min_const_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions tests/ui/crashes/ice-7126.rs
Original file line number Diff line number Diff line change
@@ -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<i32, i32>);
impl Foo {
fn new() -> Self {
Self(BTreeMap::new())
}
}

fn main() {}

0 comments on commit 3dbbb1d

Please sign in to comment.