diff options
| author | Masaki Hara <ackie.h.gmai@gmail.com> | 2018-11-28 23:59:19 +0900 |
|---|---|---|
| committer | Masaki Hara <ackie.h.gmai@gmail.com> | 2018-11-28 23:59:19 +0900 |
| commit | 8cab350c85b9738e4dbc99c67e71bd4a5b6f62a7 (patch) | |
| tree | 8fbb45d1b05612efcd1c59882c97c61f829e4ccc | |
| parent | 9d35e57907ce2a57446e94dcf9e3403a51de6205 (diff) | |
| download | rust-8cab350c85b9738e4dbc99c67e71bd4a5b6f62a7.tar.gz rust-8cab350c85b9738e4dbc99c67e71bd4a5b6f62a7.zip | |
Don't use ReErased in deferred sizedness checking.
| -rw-r--r-- | src/librustc_typeck/check/mod.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 44aa52651b0..a107cec9ef4 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -3970,7 +3970,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // // to work in stable even if the Sized bound on `drop` is relaxed. for i in 0..fn_sig.inputs().skip_binder().len() { - let input = tcx.erase_late_bound_regions(&fn_sig.input(i)); + // We just want to check sizedness, so instead of introducing + // placeholder lifetimes with probing, we just replace higher lifetimes + // with fresh vars. + let input = self.replace_bound_vars_with_fresh_vars( + expr.span, + infer::LateBoundRegionConversionTime::FnCall, + &fn_sig.input(i)).0; self.require_type_is_sized_deferred(input, expr.span, traits::SizedArgumentType); } @@ -3978,7 +3984,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // Here we want to prevent struct constructors from returning unsized types. // There were two cases this happened: fn pointer coercion in stable // and usual function call in presense of unsized_locals. - let output = tcx.erase_late_bound_regions(&fn_sig.output()); + // Also, as we just want to check sizedness, instead of introducing + // placeholder lifetimes with probing, we just replace higher lifetimes + // with fresh vars. + let output = self.replace_bound_vars_with_fresh_vars( + expr.span, + infer::LateBoundRegionConversionTime::FnCall, + &fn_sig.output()).0; self.require_type_is_sized_deferred(output, expr.span, traits::SizedReturnType); } |
