@@ -13,9 +13,9 @@ use rustc_infer::infer::region_constraints::{GenericKind, VarInfos, VerifyBound,
1313use rustc_infer:: infer:: { InferCtxt , NllRegionVariableOrigin , RegionVariableOrigin } ;
1414use rustc_middle:: bug;
1515use rustc_middle:: mir:: {
16- BasicBlock , Body , ClosureOutlivesRequirement , ClosureOutlivesSubject , ClosureOutlivesSubjectTy ,
17- ClosureRegionRequirements , ConstraintCategory , Local , Location , ReturnConstraint ,
18- TerminatorKind ,
16+ AnnotationSource , BasicBlock , Body , ClosureOutlivesRequirement , ClosureOutlivesSubject ,
17+ ClosureOutlivesSubjectTy , ClosureRegionRequirements , ConstraintCategory , Local , Location ,
18+ ReturnConstraint , TerminatorKind ,
1919} ;
2020use rustc_middle:: traits:: { ObligationCause , ObligationCauseCode } ;
2121use rustc_middle:: ty:: fold:: fold_regions;
@@ -2063,15 +2063,19 @@ impl<'tcx> RegionInferenceContext<'tcx> {
20632063 // Mimic old logic for this, to minimize false positives in tests.
20642064 && !path
20652065 . iter ( )
2066- . any ( |c| matches ! ( c. category, ConstraintCategory :: TypeAnnotation ) ) =>
2066+ . any ( |c| matches ! ( c. category, ConstraintCategory :: TypeAnnotation ( _ ) ) ) =>
20672067 {
20682068 1
20692069 }
20702070 // Between other interesting constraints, order by their position on the `path`.
20712071 ConstraintCategory :: Yield
20722072 | ConstraintCategory :: UseAsConst
20732073 | ConstraintCategory :: UseAsStatic
2074- | ConstraintCategory :: TypeAnnotation
2074+ | ConstraintCategory :: TypeAnnotation (
2075+ AnnotationSource :: Ascription
2076+ | AnnotationSource :: Declaration
2077+ | AnnotationSource :: OpaqueCast ,
2078+ )
20752079 | ConstraintCategory :: Cast { .. }
20762080 | ConstraintCategory :: CallArgument ( _)
20772081 | ConstraintCategory :: CopyBound
@@ -2082,17 +2086,19 @@ impl<'tcx> RegionInferenceContext<'tcx> {
20822086 // Give assignments a lower priority when flagged as less likely to be interesting.
20832087 // In particular, de-prioritize MIR assignments lowered from argument patterns.
20842088 ConstraintCategory :: Assignment { has_interesting_ty : false } => 3 ,
2089+ // Generic arguments are unlikely to be what relates regions together
2090+ ConstraintCategory :: TypeAnnotation ( AnnotationSource :: GenericArg ) => 4 ,
20852091 // We handle predicates and opaque types specially; don't prioritize them here.
2086- ConstraintCategory :: Predicate ( _) | ConstraintCategory :: OpaqueType => 4 ,
2092+ ConstraintCategory :: Predicate ( _) | ConstraintCategory :: OpaqueType => 5 ,
20872093 // `Boring` constraints can correspond to user-written code and have useful spans,
20882094 // but don't provide any other useful information for diagnostics.
2089- ConstraintCategory :: Boring => 5 ,
2095+ ConstraintCategory :: Boring => 6 ,
20902096 // `BoringNoLocation` constraints can point to user-written code, but are less
20912097 // specific, and are not used for relations that would make sense to blame.
2092- ConstraintCategory :: BoringNoLocation => 6 ,
2098+ ConstraintCategory :: BoringNoLocation => 7 ,
20932099 // Do not blame internal constraints.
2094- ConstraintCategory :: Internal => 7 ,
2095- ConstraintCategory :: IllegalUniverse => 8 ,
2100+ ConstraintCategory :: Internal => 8 ,
2101+ ConstraintCategory :: IllegalUniverse => 9 ,
20962102 }
20972103 } ;
20982104
0 commit comments