@@ -2,24 +2,19 @@ use std::borrow::Cow;
22use std:: iter;
33
44use rustc_data_structures:: fx:: FxIndexSet ;
5- use rustc_errors:: {
6- Applicability , E0050 , E0053 , E0053 , E0053 , struct_span_code_err, struct_span_code_err,
7- struct_span_code_err,
8- } ;
5+ use rustc_errors:: { Applicability , E0050 , E0053 , struct_span_code_err} ;
96use rustc_hir:: def_id:: { DefId , LocalDefId } ;
10- use rustc_hir:: {
11- self as hir, self as hir, self as hir, FnSig , HirId , HirId , HirId , ItemKind , ItemKind , ItemKind ,
12- } ;
7+ use rustc_hir:: { self as hir, FnSig , HirId , ItemKind } ;
8+ use rustc_infer:: infer:: canonical:: ir:: TypingMode ;
139use rustc_infer:: infer:: { self , InferCtxt , TyCtxtInferExt } ;
1410use rustc_infer:: traits:: { ObligationCause , ObligationCauseCode } ;
1511use rustc_middle:: ty;
1612use rustc_middle:: ty:: TyCtxt ;
17- use rustc_middle:: ty:: error:: { ExpectedFound , TypeError , TypeError , TypeError } ;
18- use rustc_span:: { ErrorGuaranteed , Ident , Span } ;
13+ use rustc_middle:: ty:: error:: { ExpectedFound , TypeError } ;
14+ use rustc_span:: { ErrorGuaranteed , Ident , Span , Symbol } ;
1915use rustc_trait_selection:: error_reporting:: InferCtxtErrorExt ;
2016use rustc_trait_selection:: regions:: InferCtxtRegionExt ;
2117use rustc_trait_selection:: traits:: ObligationCtxt ;
22- use rustc_type_ir:: TypingMode ;
2318use tracing:: { debug, instrument} ;
2419
2520use super :: potentially_plural_count;
@@ -150,9 +145,9 @@ fn compare_number_of_method_arguments<'tcx>(
150145 }
151146 } )
152147 } )
153- . or_else ( || tcx. hir ( ) . span_if_local ( declaration) ) ;
148+ . or_else ( || tcx. hir_span_if_local ( declaration) ) ;
154149
155- let ( external_impl_sig, _, _) = & tcx. hir ( ) . expect_item ( external_impl) . expect_fn ( ) ;
150+ let ( _ , external_impl_sig, _, _) = & tcx. hir_expect_item ( external_impl) . expect_fn ( ) ;
156151 let pos = external_impl_number_args. saturating_sub ( 1 ) ;
157152 let impl_span = external_impl_sig
158153 . decl
@@ -326,7 +321,7 @@ fn report_eii_mismatch<'tcx>(
326321 if declaration_sig. inputs ( ) . len ( ) == * i {
327322 // Suggestion to change output type. We do not suggest in `async` functions
328323 // to avoid complex logic or incorrect output.
329- if let ItemKind :: Fn { sig, .. } = & tcx. hir ( ) . expect_item ( external_impl_did) . kind
324+ if let ItemKind :: Fn { sig, .. } = & tcx. hir_expect_item ( external_impl_did) . kind
330325 && !sig. header . asyncness . is_async ( )
331326 {
332327 let msg = "change the output type to match the declaration" ;
@@ -381,12 +376,9 @@ fn extract_spans_for_error_reporting<'tcx>(
381376) -> ( Span , Option < Span > , Ident ) {
382377 let tcx = infcx. tcx ;
383378 let ( mut external_impl_args, external_impl_name) = {
384- let item = tcx. hir ( ) . expect_item ( external_impl) ;
385- let ( sig, _, _) = item. expect_fn ( ) ;
386- (
387- sig. decl . inputs . iter ( ) . map ( |t| t. span ) . chain ( iter:: once ( sig. decl . output . span ( ) ) ) ,
388- item. ident ,
389- )
379+ let item = tcx. hir_expect_item ( external_impl) ;
380+ let ( ident, sig, _, _) = item. expect_fn ( ) ;
381+ ( sig. decl . inputs . iter ( ) . map ( |t| t. span ) . chain ( iter:: once ( sig. decl . output . span ( ) ) ) , ident)
390382 } ;
391383
392384 let declaration_args = declaration. as_local ( ) . map ( |def_id| {
@@ -403,7 +395,7 @@ fn extract_spans_for_error_reporting<'tcx>(
403395 declaration_args. and_then ( |mut args| args. nth ( i) ) ,
404396 external_impl_name,
405397 ) ,
406- _ => ( cause. span , tcx. hir ( ) . span_if_local ( declaration) , external_impl_name) ,
398+ _ => ( cause. span , tcx. hir_span_if_local ( declaration) , external_impl_name) ,
407399 }
408400}
409401
0 commit comments