1
1
use crate :: infer:: InferCtxt ;
2
- use crate :: traits:: query:: type_op:: { self , TypeOp , TypeOpOutput } ;
3
2
use crate :: traits:: { ObligationCause , ObligationCtxt } ;
4
3
use rustc_data_structures:: fx:: FxIndexSet ;
5
- use rustc_errors:: ErrorGuaranteed ;
6
4
use rustc_infer:: infer:: resolve:: OpportunisticRegionResolver ;
5
+ use rustc_infer:: infer:: InferOk ;
6
+ use rustc_middle:: infer:: canonical:: { OriginalQueryValues , QueryRegionConstraints } ;
7
7
use rustc_middle:: ty:: { self , ParamEnv , Ty , TypeFolder , TypeVisitableExt } ;
8
8
use rustc_span:: def_id:: LocalDefId ;
9
9
@@ -68,20 +68,29 @@ impl<'a, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'tcx> {
68
68
return vec ! [ ] ;
69
69
}
70
70
71
- let span = self . tcx . def_span ( body_id) ;
72
- let result: Result < _ , ErrorGuaranteed > = param_env
73
- . and ( type_op:: implied_outlives_bounds:: ImpliedOutlivesBounds { ty } )
74
- . fully_perform ( self , span) ;
75
- let result = match result {
76
- Ok ( r) => r,
77
- Err ( _) => {
78
- return vec ! [ ] ;
79
- }
71
+ let mut canonical_var_values = OriginalQueryValues :: default ( ) ;
72
+ let canonical_ty =
73
+ self . canonicalize_query_keep_static ( param_env. and ( ty) , & mut canonical_var_values) ;
74
+ let Ok ( canonical_result) = self . tcx . implied_outlives_bounds ( canonical_ty) else {
75
+ return vec ! [ ] ;
76
+ } ;
77
+
78
+ let mut constraints = QueryRegionConstraints :: default ( ) ;
79
+ let Ok ( InferOk { value, obligations } ) = self
80
+ . instantiate_nll_query_response_and_region_obligations (
81
+ & ObligationCause :: dummy ( ) ,
82
+ param_env,
83
+ & canonical_var_values,
84
+ canonical_result,
85
+ & mut constraints,
86
+ ) else {
87
+ return vec ! [ ] ;
80
88
} ;
89
+ assert_eq ! ( & obligations, & [ ] ) ;
81
90
82
- let TypeOpOutput { output, constraints, .. } = result;
91
+ if !constraints. is_empty ( ) {
92
+ let span = self . tcx . def_span ( body_id) ;
83
93
84
- if let Some ( constraints) = constraints {
85
94
debug ! ( ?constraints) ;
86
95
if !constraints. member_constraints . is_empty ( ) {
87
96
span_bug ! ( span, "{:#?}" , constraints. member_constraints) ;
@@ -108,7 +117,7 @@ impl<'a, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'tcx> {
108
117
}
109
118
} ;
110
119
111
- output
120
+ value
112
121
}
113
122
114
123
fn implied_bounds_tys (
0 commit comments