Skip to content

Commit fca0666

Browse files
Assign structured errors to min_const_fn checks
1 parent a29424a commit fca0666

File tree

5 files changed

+407
-130
lines changed

5 files changed

+407
-130
lines changed

src/librustc_mir/transform/check_consts/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,10 @@ impl fmt::Display for ConstKind {
111111
pub fn is_lang_panic_fn(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool {
112112
Some(def_id) == tcx.lang_items().panic_fn() || Some(def_id) == tcx.lang_items().begin_panic_fn()
113113
}
114+
115+
/// Returns `true` if the constness of this item is not stabilized, either because it is declared
116+
/// with `#![rustc_const_unstable]` or because the item itself is unstable.
117+
fn is_const_unstable(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool {
118+
tcx.lookup_const_stability(def_id).map_or(false, |stab| stab.level.is_unstable())
119+
|| tcx.lookup_stability(def_id).map_or(false, |stab| stab.level.is_unstable())
120+
}

0 commit comments

Comments
 (0)