1
1
use std:: fmt;
2
2
3
+ use rustc_errors:: ErrorGuaranteed ;
3
4
use rustc_infer:: infer:: canonical:: Canonical ;
4
5
use rustc_middle:: mir:: ConstraintCategory ;
5
6
use rustc_middle:: ty:: { self , ToPredicate , Ty , TyCtxt , TypeFoldable } ;
6
7
use rustc_span:: def_id:: DefId ;
7
8
use rustc_span:: Span ;
8
9
use rustc_trait_selection:: traits:: query:: type_op:: { self , TypeOpOutput } ;
9
- use rustc_trait_selection:: traits:: query:: { Fallible , NoSolution } ;
10
10
use rustc_trait_selection:: traits:: ObligationCause ;
11
11
12
12
use crate :: diagnostics:: { ToUniverseInfo , UniverseInfo } ;
@@ -30,14 +30,15 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
30
30
locations : Locations ,
31
31
category : ConstraintCategory < ' tcx > ,
32
32
op : Op ,
33
- ) -> Fallible < R >
33
+ ) -> Result < R , ErrorGuaranteed >
34
34
where
35
35
Op : type_op:: TypeOp < ' tcx , Output = R > ,
36
36
Op :: ErrorInfo : ToUniverseInfo < ' tcx > ,
37
37
{
38
38
let old_universe = self . infcx . universe ( ) ;
39
39
40
- let TypeOpOutput { output, constraints, error_info } = op. fully_perform ( self . infcx ) ?;
40
+ let TypeOpOutput { output, constraints, error_info } =
41
+ op. fully_perform ( self . infcx , locations. span ( self . body ) ) ?;
41
42
42
43
debug ! ( ?output, ?constraints) ;
43
44
@@ -135,14 +136,11 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
135
136
) {
136
137
let param_env = self . param_env ;
137
138
let predicate = predicate. to_predicate ( self . tcx ( ) ) ;
138
- self . fully_perform_op (
139
+ let _ : Result < _ , ErrorGuaranteed > = self . fully_perform_op (
139
140
locations,
140
141
category,
141
142
param_env. and ( type_op:: prove_predicate:: ProvePredicate :: new ( predicate) ) ,
142
- )
143
- . unwrap_or_else ( |NoSolution | {
144
- span_mirbug ! ( self , NoSolution , "could not prove {:?}" , predicate) ;
145
- } )
143
+ ) ;
146
144
}
147
145
148
146
pub ( super ) fn normalize < T > ( & mut self , value : T , location : impl NormalizeLocation ) -> T
@@ -163,15 +161,12 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
163
161
T : type_op:: normalize:: Normalizable < ' tcx > + fmt:: Display + Copy + ' tcx ,
164
162
{
165
163
let param_env = self . param_env ;
166
- self . fully_perform_op (
164
+ let result : Result < _ , ErrorGuaranteed > = self . fully_perform_op (
167
165
location. to_locations ( ) ,
168
166
category,
169
167
param_env. and ( type_op:: normalize:: Normalize :: new ( value) ) ,
170
- )
171
- . unwrap_or_else ( |NoSolution | {
172
- span_mirbug ! ( self , NoSolution , "failed to normalize `{:?}`" , value) ;
173
- value
174
- } )
168
+ ) ;
169
+ result. unwrap_or ( value)
175
170
}
176
171
177
172
#[ instrument( skip( self ) , level = "debug" ) ]
@@ -181,18 +176,11 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
181
176
user_ty : ty:: UserType < ' tcx > ,
182
177
span : Span ,
183
178
) {
184
- self . fully_perform_op (
179
+ let _ : Result < _ , ErrorGuaranteed > = self . fully_perform_op (
185
180
Locations :: All ( span) ,
186
181
ConstraintCategory :: Boring ,
187
182
self . param_env . and ( type_op:: ascribe_user_type:: AscribeUserType :: new ( mir_ty, user_ty) ) ,
188
- )
189
- . unwrap_or_else ( |err| {
190
- span_mirbug ! (
191
- self ,
192
- span,
193
- "ascribe_user_type `{mir_ty:?}=={user_ty:?}` failed with `{err:?}`" ,
194
- ) ;
195
- } ) ;
183
+ ) ;
196
184
}
197
185
198
186
/// *Incorrectly* skips the WF checks we normally do in `ascribe_user_type`.
@@ -219,7 +207,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
219
207
220
208
let cause = ObligationCause :: dummy_with_span ( span) ;
221
209
let param_env = self . param_env ;
222
- self . fully_perform_op (
210
+ let _ : Result < _ , ErrorGuaranteed > = self . fully_perform_op (
223
211
Locations :: All ( span) ,
224
212
ConstraintCategory :: Boring ,
225
213
type_op:: custom:: CustomTypeOp :: new (
@@ -230,13 +218,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
230
218
} ,
231
219
"ascribe_user_type_skip_wf" ,
232
220
) ,
233
- )
234
- . unwrap_or_else ( |err| {
235
- span_mirbug ! (
236
- self ,
237
- span,
238
- "ascribe_user_type_skip_wf `{mir_ty:?}=={user_ty:?}` failed with `{err:?}`" ,
239
- ) ;
240
- } ) ;
221
+ ) ;
241
222
}
242
223
}
0 commit comments