10
10
11
11
use rustc:: traits:: { Normalized , ObligationCause } ;
12
12
use rustc:: traits:: query:: NoSolution ;
13
- use rustc:: ty:: { ParamEnvAnd , Ty , TyCtxt } ;
13
+ use rustc:: ty:: { self , ParamEnvAnd , Ty , TyCtxt } ;
14
14
use rustc:: util:: common:: CellUsizeExt ;
15
15
16
16
crate fn normalize_ty_after_erasing_regions < ' tcx > (
17
17
tcx : TyCtxt < ' _ , ' tcx , ' tcx > ,
18
18
goal : ParamEnvAnd < ' tcx , Ty < ' tcx > > ,
19
19
) -> Ty < ' tcx > {
20
20
let ParamEnvAnd { param_env, value } = goal;
21
- tcx. sess . perf_stats . normalize_ty_after_erasing_regions . increment ( ) ;
21
+ tcx. sess
22
+ . perf_stats
23
+ . normalize_ty_after_erasing_regions
24
+ . increment ( ) ;
22
25
tcx. infer_ctxt ( ) . enter ( |infcx| {
23
26
let cause = ObligationCause :: dummy ( ) ;
24
27
match infcx. at ( & cause, param_env) . normalize ( & value) {
25
- Ok ( Normalized { value : normalized_value, obligations : _ } ) => {
26
- // ^^^^^^^^^^^
27
- // We don't care about the `obligations`,
28
- // they are always only region relations,
29
- // and we are about to erase those anyway.
28
+ Ok ( Normalized {
29
+ value : normalized_value,
30
+ obligations : normalized_obligations,
31
+ } ) => {
32
+ // We don't care about the `obligations`; they are
33
+ // always only region relations, and we are about to
34
+ // erase those anyway:
35
+ debug_assert_eq ! (
36
+ normalized_obligations
37
+ . iter( )
38
+ . find( |p| not_outlives_predicate( & p. predicate) ) ,
39
+ None ,
40
+ ) ;
41
+
30
42
let normalized_value = infcx. resolve_type_vars_if_possible ( & normalized_value) ;
31
43
let normalized_value = infcx. tcx . erase_regions ( & normalized_value) ;
32
44
tcx. lift_to_global ( & normalized_value) . unwrap ( )
@@ -35,3 +47,16 @@ crate fn normalize_ty_after_erasing_regions<'tcx>(
35
47
}
36
48
} )
37
49
}
50
+
51
+ fn not_outlives_predicate ( p : & ty:: Predicate < ' _ > ) -> bool {
52
+ match p {
53
+ ty:: Predicate :: RegionOutlives ( ..) | ty:: Predicate :: TypeOutlives ( ..) => false ,
54
+ ty:: Predicate :: Trait ( ..)
55
+ | ty:: Predicate :: Projection ( ..)
56
+ | ty:: Predicate :: WellFormed ( ..)
57
+ | ty:: Predicate :: ObjectSafe ( ..)
58
+ | ty:: Predicate :: ClosureKind ( ..)
59
+ | ty:: Predicate :: Subtype ( ..)
60
+ | ty:: Predicate :: ConstEvaluatable ( ..) => true ,
61
+ }
62
+ }
0 commit comments