@@ -11,10 +11,10 @@ use rustc_ast::util::parser::ExprPrecedence;
11
11
use rustc_data_structures:: fx:: FxIndexMap ;
12
12
use rustc_errors:: Applicability ;
13
13
use rustc_hir:: def_id:: DefId ;
14
- use rustc_hir:: intravisit:: { Visitor , walk_ty } ;
14
+ use rustc_hir:: intravisit:: { InferKind , Visitor , VisitorExt , walk_ambig_ty } ;
15
15
use 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 ,
18
18
} ;
19
19
use rustc_lint:: { LateContext , LateLintPass } ;
20
20
use rustc_middle:: ty:: adjustment:: { Adjust , Adjustment , AutoBorrow , AutoBorrowMutability } ;
@@ -796,7 +796,7 @@ impl TyCoercionStability {
796
796
if let Some ( args) = path. args
797
797
&& args. args . iter ( ) . any ( |arg| match arg {
798
798
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 ( ) ) ,
800
800
_ => false ,
801
801
} )
802
802
{
@@ -815,7 +815,7 @@ impl TyCoercionStability {
815
815
| TyKind :: Path ( _) => Self :: Deref ,
816
816
TyKind :: OpaqueDef ( ..)
817
817
| TyKind :: TraitAscription ( ..)
818
- | TyKind :: Infer
818
+ | TyKind :: Infer ( ( ) )
819
819
| TyKind :: Typeof ( ..)
820
820
| TyKind :: TraitObject ( ..)
821
821
| TyKind :: InferDelegation ( ..)
@@ -889,29 +889,23 @@ impl TyCoercionStability {
889
889
fn ty_contains_infer ( ty : & hir:: Ty < ' _ > ) -> bool {
890
890
struct V ( bool ) ;
891
891
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_shared_ty_const ( & mut self , inf_id : HirId , _inf_span : Span , kind : InferKind < ' _ > ) -> Self :: Result {
893
+ if let InferKind :: Ty ( _) | InferKind :: Ambig ( _) = kind {
899
894
self . 0 = true ;
900
- } else {
901
- walk_ty ( self , ty) ;
902
895
}
896
+ self . visit_id ( inf_id) ;
903
897
}
904
898
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 ( _) ) {
907
901
self . 0 = true ;
908
- } else if let hir :: GenericArg :: Type ( ty ) = arg {
909
- self . visit_ty ( ty) ;
902
+ } else {
903
+ walk_ambig_ty ( self , ty) ;
910
904
}
911
905
}
912
906
}
913
907
let mut v = V ( false ) ;
914
- v. visit_ty ( ty) ;
908
+ v. visit_unambig_ty ( ty) ;
915
909
v. 0
916
910
}
917
911
0 commit comments