Enforce unsafe binders must be Copy (for now)

This commit is contained in:
Michael Goulet 2025-01-31 02:04:10 +00:00
parent fc1a9186dc
commit b63341e892
5 changed files with 98 additions and 41 deletions

View file

@ -828,8 +828,25 @@ impl<'a, 'tcx> TypeVisitor<TyCtxt<'tcx>> for WfPredicates<'a, 'tcx> {
// Let the visitor iterate into the argument/return
// types appearing in the fn signature.
}
ty::UnsafeBinder(_) => {
// FIXME(unsafe_binders): We should also recurse into the binder here.
ty::UnsafeBinder(ty) => {
// FIXME(unsafe_binders): For now, we have no way to express
// that a type must be `ManuallyDrop` OR `Copy` (or a pointer).
if !ty.has_escaping_bound_vars() {
self.out.push(traits::Obligation::new(
self.tcx(),
self.cause(ObligationCauseCode::Misc),
self.param_env,
ty.map_bound(|ty| {
ty::TraitRef::new(
self.tcx(),
self.tcx().require_lang_item(LangItem::Copy, Some(self.span)),
[ty],
)
}),
));
}
// We recurse into the binder below.
}
ty::Dynamic(data, r, _) => {