Skip to content

Commit b95ea45

Browse files
Note why rust-call abi requires sized obl
1 parent b7095f5 commit b95ea45

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -2663,9 +2663,15 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
26632663
| ObligationCauseCode::LetElse
26642664
| ObligationCauseCode::BinOp { .. }
26652665
| ObligationCauseCode::AscribeUserTypeProvePredicate(..)
2666-
| ObligationCauseCode::RustCall
26672666
| ObligationCauseCode::DropImpl
26682667
| ObligationCauseCode::ConstParam(_) => {}
2668+
ObligationCauseCode::RustCall => {
2669+
if let Some(pred) = predicate.to_opt_poly_trait_pred()
2670+
&& Some(pred.def_id()) == self.tcx.lang_items().sized_trait()
2671+
{
2672+
err.note("argument required to be sized due to `extern \"rust-call\"` ABI");
2673+
}
2674+
}
26692675
ObligationCauseCode::SliceOrArrayElem => {
26702676
err.note("slice and array elements must have `Sized` type");
26712677
}

tests/ui/unsized-locals/rust-call.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ LL | f(*slice);
66
|
77
= help: within `([u8],)`, the trait `Sized` is not implemented for `[u8]`
88
= note: required because it appears within the type `([u8],)`
9+
= note: argument required to be sized due to `extern "rust-call"` ABI
910

1011
error: aborting due to previous error
1112

0 commit comments

Comments
 (0)