@@ -6,9 +6,9 @@ use crate::session_diagnostics::{
6
6
} ;
7
7
use rustc_errors:: { Applicability , Diag } ;
8
8
use rustc_errors:: { DiagCtxt , MultiSpan } ;
9
- use rustc_hir as hir;
10
9
use rustc_hir:: def:: { CtorKind , Namespace } ;
11
10
use rustc_hir:: CoroutineKind ;
11
+ use rustc_hir:: { self as hir, LangItem } ;
12
12
use rustc_index:: IndexSlice ;
13
13
use rustc_infer:: infer:: BoundRegionConversionTime ;
14
14
use rustc_infer:: traits:: SelectionError ;
@@ -116,7 +116,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
116
116
{
117
117
if let ty:: FnDef ( id, _) = * const_. ty ( ) . kind ( ) {
118
118
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 ) {
120
120
let closure = match args. first ( ) {
121
121
Some ( Spanned {
122
122
node : Operand :: Copy ( place) | Operand :: Move ( place) , ..
@@ -767,13 +767,12 @@ impl<'tcx> BorrowedContentSource<'tcx> {
767
767
ty:: FnDef ( def_id, args) => {
768
768
let trait_id = tcx. trait_of_item ( def_id) ?;
769
769
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 )
773
772
{
774
773
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 )
777
776
{
778
777
Some ( BorrowedContentSource :: OverloadedIndex ( args. type_at ( 0 ) ) )
779
778
} else {
@@ -1041,7 +1040,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1041
1040
. unwrap_or_else ( || "value" . to_owned ( ) ) ;
1042
1041
match kind {
1043
1042
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 ) =>
1045
1044
{
1046
1045
err. subdiagnostic (
1047
1046
self . dcx ( ) ,
@@ -1268,7 +1267,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1268
1267
let ty = moved_place. ty ( self . body , tcx) . ty ;
1269
1268
1270
1269
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 )
1272
1271
&& let ty:: Ref ( _, _, hir:: Mutability :: Mut ) = args. type_at ( 0 ) . kind ( )
1273
1272
&& let self_ty = self . infcx . instantiate_binder_with_fresh_vars (
1274
1273
fn_call_span,
0 commit comments