@@ -13,9 +13,9 @@ use rustc_infer::infer::region_constraints::{GenericKind, VarInfos, VerifyBound,
13
13
use rustc_infer:: infer:: { InferCtxt , NllRegionVariableOrigin , RegionVariableOrigin } ;
14
14
use rustc_middle:: bug;
15
15
use 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 ,
19
19
} ;
20
20
use rustc_middle:: traits:: { ObligationCause , ObligationCauseCode } ;
21
21
use rustc_middle:: ty:: fold:: fold_regions;
@@ -2063,15 +2063,19 @@ impl<'tcx> RegionInferenceContext<'tcx> {
2063
2063
// Mimic old logic for this, to minimize false positives in tests.
2064
2064
&& !path
2065
2065
. iter ( )
2066
- . any ( |c| matches ! ( c. category, ConstraintCategory :: TypeAnnotation ) ) =>
2066
+ . any ( |c| matches ! ( c. category, ConstraintCategory :: TypeAnnotation ( _ ) ) ) =>
2067
2067
{
2068
2068
1
2069
2069
}
2070
2070
// Between other interesting constraints, order by their position on the `path`.
2071
2071
ConstraintCategory :: Yield
2072
2072
| ConstraintCategory :: UseAsConst
2073
2073
| ConstraintCategory :: UseAsStatic
2074
- | ConstraintCategory :: TypeAnnotation
2074
+ | ConstraintCategory :: TypeAnnotation (
2075
+ AnnotationSource :: Ascription
2076
+ | AnnotationSource :: Declaration
2077
+ | AnnotationSource :: OpaqueCast ,
2078
+ )
2075
2079
| ConstraintCategory :: Cast { .. }
2076
2080
| ConstraintCategory :: CallArgument ( _)
2077
2081
| ConstraintCategory :: CopyBound
@@ -2082,17 +2086,19 @@ impl<'tcx> RegionInferenceContext<'tcx> {
2082
2086
// Give assignments a lower priority when flagged as less likely to be interesting.
2083
2087
// In particular, de-prioritize MIR assignments lowered from argument patterns.
2084
2088
ConstraintCategory :: Assignment { has_interesting_ty : false } => 3 ,
2089
+ // Generic arguments are unlikely to be what relates regions together
2090
+ ConstraintCategory :: TypeAnnotation ( AnnotationSource :: GenericArg ) => 4 ,
2085
2091
// We handle predicates and opaque types specially; don't prioritize them here.
2086
- ConstraintCategory :: Predicate ( _) | ConstraintCategory :: OpaqueType => 4 ,
2092
+ ConstraintCategory :: Predicate ( _) | ConstraintCategory :: OpaqueType => 5 ,
2087
2093
// `Boring` constraints can correspond to user-written code and have useful spans,
2088
2094
// but don't provide any other useful information for diagnostics.
2089
- ConstraintCategory :: Boring => 5 ,
2095
+ ConstraintCategory :: Boring => 6 ,
2090
2096
// `BoringNoLocation` constraints can point to user-written code, but are less
2091
2097
// specific, and are not used for relations that would make sense to blame.
2092
- ConstraintCategory :: BoringNoLocation => 6 ,
2098
+ ConstraintCategory :: BoringNoLocation => 7 ,
2093
2099
// Do not blame internal constraints.
2094
- ConstraintCategory :: Internal => 7 ,
2095
- ConstraintCategory :: IllegalUniverse => 8 ,
2100
+ ConstraintCategory :: Internal => 8 ,
2101
+ ConstraintCategory :: IllegalUniverse => 9 ,
2096
2102
}
2097
2103
} ;
2098
2104
0 commit comments