@@ -94,7 +94,7 @@ pub fn compute_dropck_outlives_inner<'tcx>(
9494 goal : ParamEnvAnd < ' tcx , DropckOutlives < ' tcx > > ,
9595 span : Span ,
9696) -> Result < DropckOutlivesResult < ' tcx > , NoSolution > {
97- match compute_dropck_outlives_with_errors ( ocx, goal, span, false ) {
97+ match compute_dropck_outlives_with_errors ( ocx, goal, span) {
9898 Ok ( r) => Ok ( r) ,
9999 Err ( _) => Err ( NoSolution ) ,
100100 }
@@ -104,7 +104,6 @@ pub fn compute_dropck_outlives_with_errors<'tcx, E>(
104104 ocx : & ObligationCtxt < ' _ , ' tcx , E > ,
105105 goal : ParamEnvAnd < ' tcx , DropckOutlives < ' tcx > > ,
106106 span : Span ,
107- report_errors : bool ,
108107) -> Result < DropckOutlivesResult < ' tcx > , Vec < E > >
109108where
110109 E : FromSolverError < ' tcx , NextSolverError < ' tcx > > ,
@@ -162,17 +161,14 @@ where
162161 result. overflows. len( ) ,
163162 ty_stack. len( )
164163 ) ;
165- match dtorck_constraint_for_ty_inner (
164+ dtorck_constraint_for_ty_inner (
166165 tcx,
167166 ocx. infcx . typing_env ( param_env) ,
168167 span,
169168 depth,
170169 ty,
171170 & mut constraints,
172- ) {
173- Err ( _) => return Err ( Vec :: new ( ) ) ,
174- _ => ( ) ,
175- } ;
171+ ) ;
176172
177173 // "outlives" represent types/regions that may be touched
178174 // by a destructor.
@@ -192,24 +188,19 @@ where
192188 // do not themselves define a destructor", more or less. We have
193189 // to push them onto the stack to be expanded.
194190 for ty in constraints. dtorck_types . drain ( ..) {
195- let ty = if report_errors {
196- let normalized_ty = ocx. deeply_normalize ( & cause, param_env, ty) ?;
197-
198- let errors = ocx. select_where_possible ( ) ;
199- if !errors. is_empty ( ) {
200- debug ! ( "failed to normalize dtorck type: {ty} ~> {errors:#?}" ) ;
201- return Err ( errors) ;
202- }
203- normalized_ty
204- } else if let Ok ( Normalized { value : ty, obligations } ) =
191+ let ty = if let Ok ( Normalized { value : ty, obligations } ) =
205192 ocx. infcx . at ( & cause, param_env) . query_normalize ( ty)
206193 {
207194 ocx. register_obligations ( obligations) ;
208195
209196 debug ! ( "dropck_outlives: ty from dtorck_types = {:?}" , ty) ;
210197 ty
211198 } else {
212- return Err ( Vec :: new ( ) ) ;
199+ ocx. deeply_normalize ( & cause, param_env, ty) ?;
200+
201+ let errors = ocx. select_where_possible ( ) ;
202+ debug ! ( "normalize errors: {ty} ~> {errors:#?}" ) ;
203+ return Err ( errors) ;
213204 } ;
214205
215206 match ty. kind ( ) {
@@ -246,14 +237,14 @@ pub fn dtorck_constraint_for_ty_inner<'tcx>(
246237 depth : usize ,
247238 ty : Ty < ' tcx > ,
248239 constraints : & mut DropckConstraint < ' tcx > ,
249- ) -> Result < ( ) , NoSolution > {
240+ ) {
250241 if !tcx. recursion_limit ( ) . value_within_limit ( depth) {
251242 constraints. overflows . push ( ty) ;
252- return Ok ( ( ) ) ;
243+ return ;
253244 }
254245
255246 if trivial_dropck_outlives ( tcx, ty) {
256- return Ok ( ( ) ) ;
247+ return ;
257248 }
258249
259250 match ty. kind ( ) {
@@ -277,22 +268,20 @@ pub fn dtorck_constraint_for_ty_inner<'tcx>(
277268 // single-element containers, behave like their element
278269 rustc_data_structures:: stack:: ensure_sufficient_stack ( || {
279270 dtorck_constraint_for_ty_inner ( tcx, typing_env, span, depth + 1 , * ety, constraints)
280- } ) ? ;
271+ } ) ;
281272 }
282273
283274 ty:: Tuple ( tys) => rustc_data_structures:: stack:: ensure_sufficient_stack ( || {
284275 for ty in tys. iter ( ) {
285- dtorck_constraint_for_ty_inner ( tcx, typing_env, span, depth + 1 , ty, constraints) ? ;
276+ dtorck_constraint_for_ty_inner ( tcx, typing_env, span, depth + 1 , ty, constraints) ;
286277 }
287- Ok :: < _ , NoSolution > ( ( ) )
288- } ) ?,
278+ } ) ,
289279
290280 ty:: Closure ( _, args) => rustc_data_structures:: stack:: ensure_sufficient_stack ( || {
291281 for ty in args. as_closure ( ) . upvar_tys ( ) {
292- dtorck_constraint_for_ty_inner ( tcx, typing_env, span, depth + 1 , ty, constraints) ? ;
282+ dtorck_constraint_for_ty_inner ( tcx, typing_env, span, depth + 1 , ty, constraints) ;
293283 }
294- Ok :: < _ , NoSolution > ( ( ) )
295- } ) ?,
284+ } ) ,
296285
297286 ty:: CoroutineClosure ( _, args) => {
298287 rustc_data_structures:: stack:: ensure_sufficient_stack ( || {
@@ -304,10 +293,9 @@ pub fn dtorck_constraint_for_ty_inner<'tcx>(
304293 depth + 1 ,
305294 ty,
306295 constraints,
307- ) ? ;
296+ ) ;
308297 }
309- Ok :: < _ , NoSolution > ( ( ) )
310- } ) ?
298+ } )
311299 }
312300
313301 ty:: Coroutine ( _, args) => {
@@ -346,7 +334,7 @@ pub fn dtorck_constraint_for_ty_inner<'tcx>(
346334
347335 ty:: Adt ( def, args) => {
348336 let DropckConstraint { dtorck_types, outlives, overflows } =
349- tcx. at ( span) . adt_dtorck_constraint ( def. did ( ) ) ? ;
337+ tcx. at ( span) . adt_dtorck_constraint ( def. did ( ) ) ;
350338 // FIXME: we can try to recursively `dtorck_constraint_on_ty`
351339 // there, but that needs some way to handle cycles.
352340 constraints
@@ -379,9 +367,7 @@ pub fn dtorck_constraint_for_ty_inner<'tcx>(
379367 ty:: Placeholder ( ..) | ty:: Bound ( ..) | ty:: Infer ( ..) | ty:: Error ( _) => {
380368 // By the time this code runs, all type variables ought to
381369 // be fully resolved.
382- return Err ( NoSolution ) ;
370+ tcx . dcx ( ) . span_delayed_bug ( span , format ! ( "Unresolved type in dropck: {:?}." , ty ) ) ;
383371 }
384372 }
385-
386- Ok ( ( ) )
387373}
0 commit comments