@@ -555,7 +555,6 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
555555 }
556556 } )
557557 . collect :: < Vec < _ > > ( ) ;
558- let crate_def_id = CRATE_DEF_ID . to_def_id ( ) ;
559558 // Try to filter out intrinsics candidates, as long as we have
560559 // some other candidates to suggest.
561560 let intrinsic_candidates: Vec < _ > = candidates
@@ -566,8 +565,9 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
566565 . collect ( ) ;
567566 if candidates. is_empty ( ) {
568567 // Put them back if we have no more candidates to suggest...
569- candidates. extend ( intrinsic_candidates) ;
568+ candidates = intrinsic_candidates;
570569 }
570+ let crate_def_id = CRATE_DEF_ID . to_def_id ( ) ;
571571 if candidates. is_empty ( ) && is_expected ( Res :: Def ( DefKind :: Enum , crate_def_id) ) {
572572 let mut enum_candidates: Vec < _ > = self
573573 . r
@@ -1008,7 +1008,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
10081008 span : Span ,
10091009 ) {
10101010 if let Some ( ( trait_ref, self_ty) ) =
1011- self . diagnostic_metadata . currently_processing_impl_trait . clone ( )
1011+ self . diagnostic_metadata . currently_processing_impl_trait . clone ( )
10121012 && let TyKind :: Path ( _, self_ty_path) = & self_ty. kind
10131013 && let PathResult :: Module ( ModuleOrUniformRoot :: Module ( module) ) =
10141014 self . resolve_path ( & Segment :: from_path ( self_ty_path) , Some ( TypeNS ) , None )
@@ -1180,37 +1180,34 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
11801180 /// return the span of whole call and the span for all arguments expect the first one (`self`).
11811181 fn call_has_self_arg ( & self , source : PathSource < ' _ > ) -> Option < ( Span , Option < Span > ) > {
11821182 let mut has_self_arg = None ;
1183- if let PathSource :: Expr ( Some ( parent) ) = source {
1184- match & parent. kind {
1185- ExprKind :: Call ( _, args) if !args. is_empty ( ) => {
1186- let mut expr_kind = & args[ 0 ] . kind ;
1187- loop {
1188- match expr_kind {
1189- ExprKind :: Path ( _, arg_name) if arg_name. segments . len ( ) == 1 => {
1190- if arg_name. segments [ 0 ] . ident . name == kw:: SelfLower {
1191- let call_span = parent. span ;
1192- let tail_args_span = if args. len ( ) > 1 {
1193- Some ( Span :: new (
1194- args[ 1 ] . span . lo ( ) ,
1195- args. last ( ) . unwrap ( ) . span . hi ( ) ,
1196- call_span. ctxt ( ) ,
1197- None ,
1198- ) )
1199- } else {
1200- None
1201- } ;
1202- has_self_arg = Some ( ( call_span, tail_args_span) ) ;
1203- }
1204- break ;
1183+ if let PathSource :: Expr ( Some ( parent) ) = source
1184+ && let ExprKind :: Call ( _, args) = & parent. kind
1185+ && !args. is_empty ( ) {
1186+ let mut expr_kind = & args[ 0 ] . kind ;
1187+ loop {
1188+ match expr_kind {
1189+ ExprKind :: Path ( _, arg_name) if arg_name. segments . len ( ) == 1 => {
1190+ if arg_name. segments [ 0 ] . ident . name == kw:: SelfLower {
1191+ let call_span = parent. span ;
1192+ let tail_args_span = if args. len ( ) > 1 {
1193+ Some ( Span :: new (
1194+ args[ 1 ] . span . lo ( ) ,
1195+ args. last ( ) . unwrap ( ) . span . hi ( ) ,
1196+ call_span. ctxt ( ) ,
1197+ None ,
1198+ ) )
1199+ } else {
1200+ None
1201+ } ;
1202+ has_self_arg = Some ( ( call_span, tail_args_span) ) ;
12051203 }
1206- ExprKind :: AddrOf ( _, _, expr) => expr_kind = & expr. kind ,
1207- _ => break ,
1204+ break ;
12081205 }
1206+ ExprKind :: AddrOf ( _, _, expr) => expr_kind = & expr. kind ,
1207+ _ => break ,
12091208 }
12101209 }
1211- _ => ( ) ,
1212- }
1213- } ;
1210+ }
12141211 has_self_arg
12151212 }
12161213
0 commit comments