File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
compiler/rustc_middle/src/hir Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ use rustc_data_structures::fingerprint::Fingerprint;
1010use rustc_data_structures:: sorted_map:: SortedMap ;
1111use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
1212use rustc_data_structures:: sync:: { DynSend , DynSync , try_par_for_each_in} ;
13- use rustc_hir:: def:: DefKind ;
13+ use rustc_hir:: def:: { DefKind , Res } ;
1414use rustc_hir:: def_id:: { DefId , LocalDefId , LocalModDefId } ;
1515use rustc_hir:: lints:: DelayedLint ;
1616use rustc_hir:: * ;
@@ -203,6 +203,20 @@ impl<'tcx> TyCtxt<'tcx> {
203203 }
204204 } )
205205 }
206+
207+ pub fn qpath_is_lang_item ( self , qpath : QPath < ' _ > , lang_item : LangItem ) -> bool {
208+ self . qpath_lang_item ( qpath) == Some ( lang_item)
209+ }
210+
211+ /// This does not use typeck results since this is intended to be used with generated code.
212+ pub fn qpath_lang_item ( self , qpath : QPath < ' _ > ) -> Option < LangItem > {
213+ if let QPath :: Resolved ( _, path) = qpath
214+ && let Res :: Def ( _, def_id) = path. res
215+ {
216+ return self . lang_items ( ) . from_def_id ( def_id) ;
217+ }
218+ None
219+ }
206220}
207221
208222/// Hashes computed by [`TyCtxt::hash_owner_nodes`] if necessary.
You can’t perform that action at this time.
0 commit comments