1
1
//! Validity checking for weak lang items
2
2
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;
5
6
6
- use crate :: hir:: map:: Map ;
7
- use crate :: ty:: TyCtxt ;
7
+ use rustc :: hir:: map:: Map ;
8
+ use rustc :: ty:: TyCtxt ;
8
9
use rustc_data_structures:: fx:: FxHashSet ;
9
10
use rustc_errors:: struct_span_err;
10
11
use rustc_hir as hir;
11
- use rustc_hir:: def_id:: DefId ;
12
12
use rustc_hir:: intravisit:: { self , NestedVisitorMap , Visitor } ;
13
13
use rustc_lang_items:: weak_lang_items:: WEAK_ITEMS_REFS ;
14
14
use rustc_span:: symbol:: Symbol ;
15
15
use rustc_span:: Span ;
16
- use rustc_target:: spec:: PanicStrategy ;
17
-
18
- pub use rustc_lang_items:: weak_lang_items:: link_name;
19
16
20
17
struct Context < ' a , ' tcx > {
21
18
tcx : TyCtxt < ' tcx > ,
@@ -42,24 +39,6 @@ pub fn check_crate<'tcx>(tcx: TyCtxt<'tcx>, items: &mut lang_items::LanguageItem
42
39
verify ( tcx, items) ;
43
40
}
44
41
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
-
63
42
fn verify < ' tcx > ( tcx : TyCtxt < ' tcx > , items : & lang_items:: LanguageItems ) {
64
43
// We only need to check for the presence of weak lang items if we're
65
44
// emitting something that's not an rlib.
@@ -122,9 +101,3 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> {
122
101
intravisit:: walk_foreign_item ( self , i)
123
102
}
124
103
}
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