11//! Validity checking for weak lang items
22
3- use crate :: middle:: lang_items;
4- use crate :: session:: config;
3+ use rustc:: middle:: lang_items;
4+ use rustc:: middle:: weak_lang_items:: whitelisted;
5+ use rustc:: session:: config;
56
6- use crate :: hir:: map:: Map ;
7- use crate :: ty:: TyCtxt ;
7+ use rustc :: hir:: map:: Map ;
8+ use rustc :: ty:: TyCtxt ;
89use rustc_data_structures:: fx:: FxHashSet ;
910use rustc_errors:: struct_span_err;
1011use rustc_hir as hir;
11- use rustc_hir:: def_id:: DefId ;
1212use rustc_hir:: intravisit:: { self , NestedVisitorMap , Visitor } ;
1313use rustc_lang_items:: weak_lang_items:: WEAK_ITEMS_REFS ;
1414use rustc_span:: symbol:: Symbol ;
1515use rustc_span:: Span ;
16- use rustc_target:: spec:: PanicStrategy ;
17-
18- pub use rustc_lang_items:: weak_lang_items:: link_name;
1916
2017struct Context < ' a , ' tcx > {
2118 tcx : TyCtxt < ' tcx > ,
@@ -42,24 +39,6 @@ pub fn check_crate<'tcx>(tcx: TyCtxt<'tcx>, items: &mut lang_items::LanguageItem
4239 verify ( tcx, items) ;
4340}
4441
45- /// Returns `true` if the specified `lang_item` doesn't actually need to be
46- /// present for this compilation.
47- ///
48- /// Not all lang items are always required for each compilation, particularly in
49- /// the case of panic=abort. In these situations some lang items are injected by
50- /// crates and don't actually need to be defined in libstd.
51- pub fn whitelisted ( tcx : TyCtxt < ' _ > , lang_item : lang_items:: LangItem ) -> bool {
52- // If we're not compiling with unwinding, we won't actually need these
53- // symbols. Other panic runtimes ensure that the relevant symbols are
54- // available to link things together, but they're never exercised.
55- if tcx. sess . panic_strategy ( ) != PanicStrategy :: Unwind {
56- return lang_item == lang_items:: EhPersonalityLangItem
57- || lang_item == lang_items:: EhUnwindResumeLangItem ;
58- }
59-
60- false
61- }
62-
6342fn verify < ' tcx > ( tcx : TyCtxt < ' tcx > , items : & lang_items:: LanguageItems ) {
6443 // We only need to check for the presence of weak lang items if we're
6544 // emitting something that's not an rlib.
@@ -122,9 +101,3 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> {
122101 intravisit:: walk_foreign_item ( self , i)
123102 }
124103}
125-
126- impl < ' tcx > TyCtxt < ' tcx > {
127- pub fn is_weak_lang_item ( & self , item_def_id : DefId ) -> bool {
128- self . lang_items ( ) . is_weak_lang_item ( item_def_id)
129- }
130- }
0 commit comments