Use helper function for searching allow_internal_unstable
This commit is contained in:
parent
ed6c7efd87
commit
c3607bd7dd
@ -4,10 +4,12 @@
|
||||
//! has interior mutability or needs to be dropped, as well as the visitor that emits errors when
|
||||
//! it finds operations that are invalid in a certain context.
|
||||
|
||||
use rustc_attr as attr;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_span::Symbol;
|
||||
|
||||
pub use self::qualifs::Qualif;
|
||||
|
||||
@ -55,3 +57,9 @@ impl ConstCx<'mir, 'tcx> {
|
||||
pub fn is_lang_panic_fn(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool {
|
||||
Some(def_id) == tcx.lang_items().panic_fn() || Some(def_id) == tcx.lang_items().begin_panic_fn()
|
||||
}
|
||||
|
||||
pub fn allow_internal_unstable(tcx: TyCtxt<'tcx>, def_id: DefId, feature_gate: Symbol) -> bool {
|
||||
let attrs = tcx.get_attrs(def_id);
|
||||
attr::allow_internal_unstable(&tcx.sess, attrs)
|
||||
.map_or(false, |mut features| features.any(|name| name == feature_gate))
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
use rustc_attr as attr;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_middle::mir::*;
|
||||
@ -344,8 +343,7 @@ fn feature_allowed(tcx: TyCtxt<'tcx>, def_id: DefId, feature_gate: Symbol) -> bo
|
||||
|
||||
// However, we cannot allow stable `const fn`s to use unstable features without an explicit
|
||||
// opt-in via `allow_internal_unstable`.
|
||||
attr::allow_internal_unstable(&tcx.sess, &tcx.get_attrs(def_id))
|
||||
.map_or(false, |mut features| features.any(|name| name == feature_gate))
|
||||
super::check_consts::allow_internal_unstable(tcx, def_id, feature_gate)
|
||||
}
|
||||
|
||||
/// Returns `true` if the given library feature gate is allowed within the function with the given `DefId`.
|
||||
@ -364,8 +362,7 @@ pub fn lib_feature_allowed(tcx: TyCtxt<'tcx>, def_id: DefId, feature_gate: Symbo
|
||||
|
||||
// However, we cannot allow stable `const fn`s to use unstable features without an explicit
|
||||
// opt-in via `allow_internal_unstable`.
|
||||
attr::allow_internal_unstable(&tcx.sess, &tcx.get_attrs(def_id))
|
||||
.map_or(false, |mut features| features.any(|name| name == feature_gate))
|
||||
super::check_consts::allow_internal_unstable(tcx, def_id, feature_gate)
|
||||
}
|
||||
|
||||
fn check_terminator(
|
||||
|
Loading…
Reference in New Issue
Block a user