Rollup merge of #130514 - compiler-errors:unsafe-binders, r=oli-obk
Implement MIR lowering for unsafe binders This is the final bit of the unsafe binders puzzle. It implements MIR, CTFE, and codegen for unsafe binders, and enforces that (for now) they are `Copy`. Later on, I'll introduce a new trait that relaxes this requirement to being "is `Copy` or `ManuallyDrop<T>`" which more closely models how we treat union fields. Namely, wrapping unsafe binders is now `Rvalue::WrapUnsafeBinder`, which acts much like an `Rvalue::Aggregate`. Unwrapping unsafe binders are implemented as a MIR projection `ProjectionElem::UnwrapUnsafeBinder`, which acts much like `ProjectionElem::Field`. Tracking: - https://github.com/rust-lang/rust/issues/130516
This commit is contained in:
commit
2fd3007cbc
56 changed files with 589 additions and 102 deletions
|
@ -830,8 +830,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, _) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue