@@ -94,7 +94,7 @@ pub fn compute_dropck_outlives_inner<'tcx>(
94
94
goal: ParamEnvAnd<'tcx, DropckOutlives<'tcx>>,
95
95
span: Span,
96
96
) -> 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) {
98
98
Ok(r) => Ok(r),
99
99
Err(_) => Err(NoSolution),
100
100
}
@@ -104,7 +104,6 @@ pub fn compute_dropck_outlives_with_errors<'tcx, E>(
104
104
ocx: &ObligationCtxt<'_, 'tcx, E>,
105
105
goal: ParamEnvAnd<'tcx, DropckOutlives<'tcx>>,
106
106
span: Span,
107
- report_errors: bool,
108
107
) -> Result<DropckOutlivesResult<'tcx>, Vec<E>>
109
108
where
110
109
E: FromSolverError<'tcx, NextSolverError<'tcx>>,
@@ -162,17 +161,14 @@ where
162
161
result.overflows.len(),
163
162
ty_stack.len()
164
163
);
165
- match dtorck_constraint_for_ty_inner(
164
+ dtorck_constraint_for_ty_inner(
166
165
tcx,
167
166
ocx.infcx.typing_env(param_env),
168
167
span,
169
168
depth,
170
169
ty,
171
170
&mut constraints,
172
- ) {
173
- Err(_) => return Err(Vec::new()),
174
- _ => (),
175
- };
171
+ );
176
172
177
173
// "outlives" represent types/regions that may be touched
178
174
// by a destructor.
@@ -192,24 +188,19 @@ where
192
188
// do not themselves define a destructor", more or less. We have
193
189
// to push them onto the stack to be expanded.
194
190
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 }) =
205
192
ocx.infcx.at(&cause, param_env).query_normalize(ty)
206
193
{
207
194
ocx.register_obligations(obligations);
208
195
209
196
debug!("dropck_outlives: ty from dtorck_types = {:?}", ty);
210
197
ty
211
198
} 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);
213
204
};
214
205
215
206
match ty.kind() {
@@ -246,14 +237,14 @@ pub fn dtorck_constraint_for_ty_inner<'tcx>(
246
237
depth: usize,
247
238
ty: Ty<'tcx>,
248
239
constraints: &mut DropckConstraint<'tcx>,
249
- ) -> Result<(), NoSolution> {
240
+ ) {
250
241
if !tcx.recursion_limit().value_within_limit(depth) {
251
242
constraints.overflows.push(ty);
252
- return Ok(()) ;
243
+ return;
253
244
}
254
245
255
246
if trivial_dropck_outlives(tcx, ty) {
256
- return Ok(()) ;
247
+ return;
257
248
}
258
249
259
250
match ty.kind() {
@@ -277,22 +268,20 @@ pub fn dtorck_constraint_for_ty_inner<'tcx>(
277
268
// single-element containers, behave like their element
278
269
rustc_data_structures::stack::ensure_sufficient_stack(|| {
279
270
dtorck_constraint_for_ty_inner(tcx, typing_env, span, depth + 1, *ety, constraints)
280
- })? ;
271
+ });
281
272
}
282
273
283
274
ty::Tuple(tys) => rustc_data_structures::stack::ensure_sufficient_stack(|| {
284
275
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);
286
277
}
287
- Ok::<_, NoSolution>(())
288
- })?,
278
+ }),
289
279
290
280
ty::Closure(_, args) => rustc_data_structures::stack::ensure_sufficient_stack(|| {
291
281
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);
293
283
}
294
- Ok::<_, NoSolution>(())
295
- })?,
284
+ }),
296
285
297
286
ty::CoroutineClosure(_, args) => {
298
287
rustc_data_structures::stack::ensure_sufficient_stack(|| {
@@ -304,10 +293,9 @@ pub fn dtorck_constraint_for_ty_inner<'tcx>(
304
293
depth + 1,
305
294
ty,
306
295
constraints,
307
- )? ;
296
+ );
308
297
}
309
- Ok::<_, NoSolution>(())
310
- })?
298
+ })
311
299
}
312
300
313
301
ty::Coroutine(_, args) => {
@@ -346,7 +334,7 @@ pub fn dtorck_constraint_for_ty_inner<'tcx>(
346
334
347
335
ty::Adt(def, args) => {
348
336
let DropckConstraint { dtorck_types, outlives, overflows } =
349
- tcx.at(span).adt_dtorck_constraint(def.did())? ;
337
+ tcx.at(span).adt_dtorck_constraint(def.did());
350
338
// FIXME: we can try to recursively `dtorck_constraint_on_ty`
351
339
// there, but that needs some way to handle cycles.
352
340
constraints
@@ -379,9 +367,7 @@ pub fn dtorck_constraint_for_ty_inner<'tcx>(
379
367
ty::Placeholder(..) | ty::Bound(..) | ty::Infer(..) | ty::Error(_) => {
380
368
// By the time this code runs, all type variables ought to
381
369
// be fully resolved.
382
- return Err(NoSolution );
370
+ tcx.dcx().span_delayed_bug(span, format!("Unresolved type in dropck: {:?}.", ty) );
383
371
}
384
372
}
385
-
386
- Ok(())
387
373
}
0 commit comments