Rollup merge of #111885 - compiler-errors:rust-call-abi-sized, r=eholk

Don't ICE on unsized `extern "rust-call"` call

Conceptually builds on #111864, but doesn't depend on it.
This commit is contained in:
Matthias Krüger 2023-06-13 07:02:28 +02:00 committed by GitHub
commit b7706e891d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 40 additions and 2 deletions

View file

@ -1449,7 +1449,7 @@ fn check_fn_or_method<'tcx>(
let span = tcx.def_span(def_id);
let has_implicit_self = hir_decl.implicit_self != hir::ImplicitSelfKind::None;
let mut inputs = sig.inputs().iter().skip(if has_implicit_self { 1 } else { 0 });
// Check that the argument is a tuple
// Check that the argument is a tuple and is sized
if let Some(ty) = inputs.next() {
wfcx.register_bound(
ObligationCause::new(span, wfcx.body_def_id, ObligationCauseCode::RustCall),
@ -1457,6 +1457,12 @@ fn check_fn_or_method<'tcx>(
*ty,
tcx.require_lang_item(hir::LangItem::Tuple, Some(span)),
);
wfcx.register_bound(
ObligationCause::new(span, wfcx.body_def_id, ObligationCauseCode::RustCall),
wfcx.param_env,
*ty,
tcx.require_lang_item(hir::LangItem::Sized, Some(span)),
);
} else {
tcx.sess.span_err(
hir_decl.inputs.last().map_or(span, |input| input.span),