Skip to content

Commit 8cab350

Browse files
committed
Don't use ReErased in deferred sizedness checking.
1 parent 9d35e57 commit 8cab350

File tree

1 file changed

+14
-2
lines changed
  • src/librustc_typeck/check

1 file changed

+14
-2
lines changed

src/librustc_typeck/check/mod.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -3970,15 +3970,27 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
39703970
//
39713971
// to work in stable even if the Sized bound on `drop` is relaxed.
39723972
for i in 0..fn_sig.inputs().skip_binder().len() {
3973-
let input = tcx.erase_late_bound_regions(&fn_sig.input(i));
3973+
// We just want to check sizedness, so instead of introducing
3974+
// placeholder lifetimes with probing, we just replace higher lifetimes
3975+
// with fresh vars.
3976+
let input = self.replace_bound_vars_with_fresh_vars(
3977+
expr.span,
3978+
infer::LateBoundRegionConversionTime::FnCall,
3979+
&fn_sig.input(i)).0;
39743980
self.require_type_is_sized_deferred(input, expr.span,
39753981
traits::SizedArgumentType);
39763982
}
39773983
}
39783984
// Here we want to prevent struct constructors from returning unsized types.
39793985
// There were two cases this happened: fn pointer coercion in stable
39803986
// and usual function call in presense of unsized_locals.
3981-
let output = tcx.erase_late_bound_regions(&fn_sig.output());
3987+
// Also, as we just want to check sizedness, instead of introducing
3988+
// placeholder lifetimes with probing, we just replace higher lifetimes
3989+
// with fresh vars.
3990+
let output = self.replace_bound_vars_with_fresh_vars(
3991+
expr.span,
3992+
infer::LateBoundRegionConversionTime::FnCall,
3993+
&fn_sig.output()).0;
39823994
self.require_type_is_sized_deferred(output, expr.span, traits::SizedReturnType);
39833995
}
39843996

0 commit comments

Comments
 (0)