@@ -11,14 +11,10 @@ use rustc_ast::util::parser::ExprPrecedence;
1111use rustc_data_structures:: fx:: FxIndexMap ;
1212use rustc_errors:: Applicability ;
1313use rustc_hir:: def_id:: DefId ;
14- <<<<<<< HEAD
15- use rustc_hir:: intravisit:: { Visitor , walk_ty} ;
16- =======
1714use rustc_hir:: intravisit:: { InferKind , Visitor , VisitorExt , walk_ty} ;
18- >>>>>>> 79008780707 ( flip `walk_x_ty` function names)
1915use rustc_hir:: {
20- self as hir , BindingMode , Body , BodyId , BorrowKind , Expr , ExprKind , HirId , MatchSource , Mutability , Node , Pat ,
21- PatKind , Path , QPath , TyKind , UnOp ,
16+ self as hir, AmbigArg , BindingMode , Body , BodyId , BorrowKind , Expr , ExprKind , HirId , MatchSource , Mutability , Node ,
17+ Pat , PatKind , Path , QPath , TyKind , UnOp ,
2218} ;
2319use rustc_lint:: { LateContext , LateLintPass } ;
2420use rustc_middle:: ty:: adjustment:: { Adjust , Adjustment , AutoBorrow , AutoBorrowMutability } ;
@@ -800,7 +796,7 @@ impl TyCoercionStability {
800796 if let Some ( args) = path. args
801797 && args. args . iter ( ) . any ( |arg| match arg {
802798 hir:: GenericArg :: Infer ( _) => true ,
803- hir:: GenericArg :: Type ( ty) => ty_contains_infer ( ty) ,
799+ hir:: GenericArg :: Type ( ty) => ty_contains_infer ( ty. as_unambig_ty ( ) ) ,
804800 _ => false ,
805801 } )
806802 {
@@ -819,7 +815,7 @@ impl TyCoercionStability {
819815 | TyKind :: Path ( _) => Self :: Deref ,
820816 TyKind :: OpaqueDef ( ..)
821817 | TyKind :: TraitAscription ( ..)
822- | TyKind :: Infer
818+ | TyKind :: Infer ( ( ) )
823819 | TyKind :: Typeof ( ..)
824820 | TyKind :: TraitObject ( ..)
825821 | TyKind :: InferDelegation ( ..)
@@ -893,29 +889,23 @@ impl TyCoercionStability {
893889fn ty_contains_infer ( ty : & hir:: Ty < ' _ > ) -> bool {
894890 struct V ( bool ) ;
895891 impl Visitor < ' _ > for V {
896- fn visit_ty ( & mut self , ty : & hir:: Ty < ' _ > ) {
897- if self . 0
898- || matches ! (
899- ty. kind,
900- TyKind :: OpaqueDef ( ..) | TyKind :: Infer | TyKind :: Typeof ( _) | TyKind :: Err ( _)
901- )
902- {
892+ fn visit_infer ( & mut self , inf_id : HirId , _inf_span : Span , kind : InferKind < ' _ > ) -> Self :: Result {
893+ if let InferKind :: Ty ( _) | InferKind :: Ambig ( _) = kind {
903894 self . 0 = true ;
904- } else {
905- walk_ty ( self , ty) ;
906895 }
896+ self . visit_id ( inf_id) ;
907897 }
908898
909- fn visit_generic_arg ( & mut self , arg : & hir:: GenericArg < ' _ > ) {
910- if self . 0 || matches ! ( arg , hir :: GenericArg :: Infer ( _) ) {
899+ fn visit_ty ( & mut self , ty : & hir:: Ty < ' _ , AmbigArg > ) {
900+ if self . 0 || matches ! ( ty . kind , TyKind :: OpaqueDef ( .. ) | TyKind :: Typeof ( _ ) | TyKind :: Err ( _) ) {
911901 self . 0 = true ;
912- } else if let hir :: GenericArg :: Type ( ty ) = arg {
913- self . visit_ty ( ty) ;
902+ } else {
903+ walk_ty ( self , ty) ;
914904 }
915905 }
916906 }
917907 let mut v = V ( false ) ;
918- v. visit_ty ( ty) ;
908+ v. visit_unambig_ty ( ty) ;
919909 v. 0
920910}
921911
0 commit comments