Merge rustc::middle::*lang_items.
This commit is contained in:
parent
d3b2385d40
commit
513eb744c0
@ -13,7 +13,9 @@ use crate::ty::{self, TyCtxt};
|
||||
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_span::Span;
|
||||
use rustc_target::spec::PanicStrategy;
|
||||
|
||||
pub use rustc_hir::weak_lang_items::link_name;
|
||||
pub use rustc_hir::{LangItem, LanguageItems};
|
||||
|
||||
impl<'tcx> TyCtxt<'tcx> {
|
||||
@ -38,4 +40,26 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_weak_lang_item(&self, item_def_id: DefId) -> bool {
|
||||
self.lang_items().is_weak_lang_item(item_def_id)
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `true` if the specified `lang_item` doesn't actually need to be
|
||||
/// present for this compilation.
|
||||
///
|
||||
/// Not all lang items are always required for each compilation, particularly in
|
||||
/// the case of panic=abort. In these situations some lang items are injected by
|
||||
/// crates and don't actually need to be defined in libstd.
|
||||
pub fn whitelisted(tcx: TyCtxt<'_>, lang_item: LangItem) -> bool {
|
||||
// If we're not compiling with unwinding, we won't actually need these
|
||||
// symbols. Other panic runtimes ensure that the relevant symbols are
|
||||
// available to link things together, but they're never exercised.
|
||||
if tcx.sess.panic_strategy() != PanicStrategy::Unwind {
|
||||
return lang_item == LangItem::EhPersonalityLangItem
|
||||
|| lang_item == LangItem::EhUnwindResumeLangItem;
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
|
@ -33,4 +33,3 @@ pub mod recursion_limit;
|
||||
pub mod region;
|
||||
pub mod resolve_lifetime;
|
||||
pub mod stability;
|
||||
pub mod weak_lang_items;
|
||||
|
@ -1,32 +0,0 @@
|
||||
//! Validity checking for weak lang items
|
||||
|
||||
use crate::ty::TyCtxt;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::{lang_items, LangItem};
|
||||
use rustc_target::spec::PanicStrategy;
|
||||
|
||||
pub use rustc_hir::weak_lang_items::link_name;
|
||||
|
||||
impl<'tcx> TyCtxt<'tcx> {
|
||||
pub fn is_weak_lang_item(&self, item_def_id: DefId) -> bool {
|
||||
self.lang_items().is_weak_lang_item(item_def_id)
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `true` if the specified `lang_item` doesn't actually need to be
|
||||
/// present for this compilation.
|
||||
///
|
||||
/// Not all lang items are always required for each compilation, particularly in
|
||||
/// the case of panic=abort. In these situations some lang items are injected by
|
||||
/// crates and don't actually need to be defined in libstd.
|
||||
pub fn whitelisted(tcx: TyCtxt<'_>, lang_item: LangItem) -> bool {
|
||||
// If we're not compiling with unwinding, we won't actually need these
|
||||
// symbols. Other panic runtimes ensure that the relevant symbols are
|
||||
// available to link things together, but they're never exercised.
|
||||
if tcx.sess.panic_strategy() != PanicStrategy::Unwind {
|
||||
return lang_item == lang_items::EhPersonalityLangItem
|
||||
|| lang_item == lang_items::EhUnwindResumeLangItem;
|
||||
}
|
||||
|
||||
false
|
||||
}
|
@ -28,8 +28,8 @@ use crate::{CachedModuleCodegen, CrateInfo, MemFlags, ModuleCodegen, ModuleKind}
|
||||
use rustc::middle::codegen_fn_attrs::CodegenFnAttrs;
|
||||
use rustc::middle::cstore::EncodedMetadata;
|
||||
use rustc::middle::cstore::{self, LinkagePreference};
|
||||
use rustc::middle::lang_items;
|
||||
use rustc::middle::lang_items::StartFnLangItem;
|
||||
use rustc::middle::weak_lang_items;
|
||||
use rustc::mir::mono::{CodegenUnit, CodegenUnitNameBuilder, MonoItem};
|
||||
use rustc::session::config::{self, EntryFnType, Lto};
|
||||
use rustc::session::Session;
|
||||
@ -847,11 +847,8 @@ impl CrateInfo {
|
||||
|
||||
// No need to look for lang items that are whitelisted and don't
|
||||
// actually need to exist.
|
||||
let missing = missing
|
||||
.iter()
|
||||
.cloned()
|
||||
.filter(|&l| !weak_lang_items::whitelisted(tcx, l))
|
||||
.collect();
|
||||
let missing =
|
||||
missing.iter().cloned().filter(|&l| !lang_items::whitelisted(tcx, l)).collect();
|
||||
info.missing_lang_items.insert(cnum, missing);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//! Validity checking for weak lang items
|
||||
|
||||
use rustc::middle::lang_items;
|
||||
use rustc::middle::weak_lang_items::whitelisted;
|
||||
use rustc::middle::lang_items::whitelisted;
|
||||
use rustc::session::config;
|
||||
|
||||
use rustc::hir::map::Map;
|
||||
|
@ -20,8 +20,8 @@ use crate::astconv::{AstConv, Bounds, SizedByDefault};
|
||||
use crate::check::intrinsic::intrinsic_operation_unsafety;
|
||||
use crate::constrained_generic_params as cgp;
|
||||
use crate::lint;
|
||||
use crate::middle::lang_items;
|
||||
use crate::middle::resolve_lifetime as rl;
|
||||
use crate::middle::weak_lang_items;
|
||||
use rustc::hir::map::blocks::FnLikeNode;
|
||||
use rustc::hir::map::Map;
|
||||
use rustc::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
|
||||
@ -2977,7 +2977,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, id: DefId) -> CodegenFnAttrs {
|
||||
if tcx.is_weak_lang_item(id) {
|
||||
codegen_fn_attrs.flags |= CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL;
|
||||
}
|
||||
if let Some(name) = weak_lang_items::link_name(&attrs) {
|
||||
if let Some(name) = lang_items::link_name(&attrs) {
|
||||
codegen_fn_attrs.export_name = Some(name);
|
||||
codegen_fn_attrs.link_name = Some(name);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user