use rustc_middle::ty::query::Providers;
use rustc_middle::ty::{DefIdTree, TyCtxt};
use rustc_span::symbol::Symbol;
-use rustc_target::spec::abi::Abi;
/// Whether the `def_id` is an unstable const fn and what feature gate is necessary to enable it
pub fn is_unstable_const_fn(tcx: TyCtxt<'_>, def_id: DefId) -> Option<Symbol> {
if tcx.is_const_fn_raw(def_id) {
let const_stab = tcx.lookup_const_stability(def_id)?;
- if const_stab.level.is_unstable() { Some(const_stab.feature) } else { None }
+ if const_stab.is_const_unstable() { Some(const_stab.feature) } else { None }
} else {
None
}
hir::Node::ForeignItem(hir::ForeignItem { kind: hir::ForeignItemKind::Fn(..), .. }) => {
// Intrinsics use `rustc_const_{un,}stable` attributes to indicate constness. All other
// foreign items cannot be evaluated at compile-time.
- let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
- let is_const = if let Abi::RustIntrinsic | Abi::PlatformIntrinsic =
- tcx.hir().get_foreign_abi(hir_id)
- {
+ let is_const = if tcx.is_intrinsic(def_id) {
tcx.lookup_const_stability(def_id).is_some()
} else {
false