@@ -11,10 +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- use rustc_hir:: intravisit:: { Visitor , walk_ty} ;
14+ use rustc_hir:: intravisit:: { InferKind , Visitor , VisitorExt , walk_ty} ;
1515use rustc_hir:: {
16- self as hir, BindingMode , Body , BodyId , BorrowKind , Expr , ExprKind , HirId , MatchSource , Mutability , Node , Pat ,
17- 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 ,
1818} ;
1919use rustc_lint:: { LateContext , LateLintPass } ;
2020use rustc_middle:: ty:: adjustment:: { Adjust , Adjustment , AutoBorrow , AutoBorrowMutability } ;
@@ -796,7 +796,7 @@ impl TyCoercionStability {
796796 if let Some ( args) = path. args
797797 && args. args . iter ( ) . any ( |arg| match arg {
798798 hir:: GenericArg :: Infer ( _) => true ,
799- hir:: GenericArg :: Type ( ty) => ty_contains_infer ( ty) ,
799+ hir:: GenericArg :: Type ( ty) => ty_contains_infer ( ty. as_unambig_ty ( ) ) ,
800800 _ => false ,
801801 } )
802802 {
@@ -815,7 +815,7 @@ impl TyCoercionStability {
815815 | TyKind :: Path ( _) => Self :: Deref ,
816816 TyKind :: OpaqueDef ( ..)
817817 | TyKind :: TraitAscription ( ..)
818- | TyKind :: Infer
818+ | TyKind :: Infer ( ( ) )
819819 | TyKind :: Typeof ( ..)
820820 | TyKind :: TraitObject ( ..)
821821 | TyKind :: InferDelegation ( ..)
@@ -889,29 +889,23 @@ impl TyCoercionStability {
889889fn ty_contains_infer ( ty : & hir:: Ty < ' _ > ) -> bool {
890890 struct V ( bool ) ;
891891 impl Visitor < ' _ > for V {
892- fn visit_ty ( & mut self , ty : & hir:: Ty < ' _ > ) {
893- if self . 0
894- || matches ! (
895- ty. kind,
896- TyKind :: OpaqueDef ( ..) | TyKind :: Infer | TyKind :: Typeof ( _) | TyKind :: Err ( _)
897- )
898- {
892+ fn visit_infer ( & mut self , inf_id : HirId , _inf_span : Span , kind : InferKind < ' _ > ) -> Self :: Result {
893+ if let InferKind :: Ty ( _) | InferKind :: Ambig ( _) = kind {
899894 self . 0 = true ;
900- } else {
901- walk_ty ( self , ty) ;
902895 }
896+ self . visit_id ( inf_id) ;
903897 }
904898
905- fn visit_generic_arg ( & mut self , arg : & hir:: GenericArg < ' _ > ) {
906- 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 ( _) ) {
907901 self . 0 = true ;
908- } else if let hir :: GenericArg :: Type ( ty ) = arg {
909- self . visit_ty ( ty) ;
902+ } else {
903+ walk_ty ( self , ty) ;
910904 }
911905 }
912906 }
913907 let mut v = V ( false ) ;
914- v. visit_ty ( ty) ;
908+ v. visit_unambig_ty ( ty) ;
915909 v. 0
916910}
917911
0 commit comments