@@ -6,9 +6,9 @@ use crate::session_diagnostics::{
66} ;
77use rustc_errors:: { Applicability , Diag } ;
88use rustc_errors:: { DiagCtxt , MultiSpan } ;
9- use rustc_hir as hir;
109use rustc_hir:: def:: { CtorKind , Namespace } ;
1110use rustc_hir:: CoroutineKind ;
11+ use rustc_hir:: { self as hir, LangItem } ;
1212use rustc_index:: IndexSlice ;
1313use rustc_infer:: infer:: BoundRegionConversionTime ;
1414use rustc_infer:: traits:: SelectionError ;
@@ -116,7 +116,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
116116 {
117117 if let ty:: FnDef ( id, _) = * const_. ty ( ) . kind ( ) {
118118 debug ! ( "add_moved_or_invoked_closure_note: id={:?}" , id) ;
119- if Some ( self . infcx . tcx . parent ( id ) ) == self . infcx . tcx . lang_items ( ) . fn_once_trait ( ) {
119+ if self . infcx . tcx . is_lang_item ( self . infcx . tcx . parent ( id ) , LangItem :: FnOnce ) {
120120 let closure = match args. first ( ) {
121121 Some ( Spanned {
122122 node : Operand :: Copy ( place) | Operand :: Move ( place) , ..
@@ -767,13 +767,12 @@ impl<'tcx> BorrowedContentSource<'tcx> {
767767 ty:: FnDef ( def_id, args) => {
768768 let trait_id = tcx. trait_of_item ( def_id) ?;
769769
770- let lang_items = tcx. lang_items ( ) ;
771- if Some ( trait_id) == lang_items. deref_trait ( )
772- || Some ( trait_id) == lang_items. deref_mut_trait ( )
770+ if tcx. is_lang_item ( trait_id, LangItem :: Deref )
771+ || tcx. is_lang_item ( trait_id, LangItem :: DerefMut )
773772 {
774773 Some ( BorrowedContentSource :: OverloadedDeref ( args. type_at ( 0 ) ) )
775- } else if Some ( trait_id) == lang_items . index_trait ( )
776- || Some ( trait_id) == lang_items . index_mut_trait ( )
774+ } else if tcx . is_lang_item ( trait_id, LangItem :: Index )
775+ || tcx . is_lang_item ( trait_id, LangItem :: IndexMut )
777776 {
778777 Some ( BorrowedContentSource :: OverloadedIndex ( args. type_at ( 0 ) ) )
779778 } else {
@@ -1041,7 +1040,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
10411040 . unwrap_or_else ( || "value" . to_owned ( ) ) ;
10421041 match kind {
10431042 CallKind :: FnCall { fn_trait_id, self_ty }
1044- if Some ( fn_trait_id ) == self . infcx . tcx . lang_items ( ) . fn_once_trait ( ) =>
1043+ if self . infcx . tcx . is_lang_item ( fn_trait_id , LangItem :: FnOnce ) =>
10451044 {
10461045 err. subdiagnostic (
10471046 self . dcx ( ) ,
@@ -1268,7 +1267,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
12681267 let ty = moved_place. ty ( self . body , tcx) . ty ;
12691268
12701269 if let ty:: Adt ( def, args) = ty. peel_refs ( ) . kind ( )
1271- && Some ( def. did ( ) ) == tcx . lang_items ( ) . pin_type ( )
1270+ && tcx . is_lang_item ( def. did ( ) , LangItem :: Pin )
12721271 && let ty:: Ref ( _, _, hir:: Mutability :: Mut ) = args. type_at ( 0 ) . kind ( )
12731272 && let self_ty = self . infcx . instantiate_binder_with_fresh_vars (
12741273 fn_call_span,
0 commit comments