Implement MIR, CTFE, and codegen for unsafe binders
This commit is contained in:
parent
7f36543a48
commit
fc1a9186dc
55 changed files with 493 additions and 101 deletions
|
@ -723,6 +723,10 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
Rvalue::WrapUnsafeBinder(..) => {
|
||||
// Unsafe binders are always trivial to create.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -258,6 +258,8 @@ where
|
|||
in_place::<Q, _>(cx, in_local, place.as_ref())
|
||||
}
|
||||
|
||||
Rvalue::WrapUnsafeBinder(op, _) => in_operand::<Q, _>(cx, in_local, op),
|
||||
|
||||
Rvalue::Aggregate(kind, operands) => {
|
||||
// Return early if we know that the struct or enum being constructed is always
|
||||
// qualified.
|
||||
|
@ -297,7 +299,8 @@ where
|
|||
| ProjectionElem::ConstantIndex { .. }
|
||||
| ProjectionElem::Subslice { .. }
|
||||
| ProjectionElem::Downcast(_, _)
|
||||
| ProjectionElem::Index(_) => {}
|
||||
| ProjectionElem::Index(_)
|
||||
| ProjectionElem::UnwrapUnsafeBinder(_) => {}
|
||||
}
|
||||
|
||||
let base_ty = place_base.ty(cx.body, cx.tcx);
|
||||
|
|
|
@ -202,7 +202,8 @@ where
|
|||
| mir::Rvalue::NullaryOp(..)
|
||||
| mir::Rvalue::UnaryOp(..)
|
||||
| mir::Rvalue::Discriminant(..)
|
||||
| mir::Rvalue::Aggregate(..) => {}
|
||||
| mir::Rvalue::Aggregate(..)
|
||||
| mir::Rvalue::WrapUnsafeBinder(..) => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -381,6 +381,7 @@ where
|
|||
OpaqueCast(ty) => {
|
||||
span_bug!(self.cur_span(), "OpaqueCast({ty}) encountered after borrowck")
|
||||
}
|
||||
UnwrapUnsafeBinder(target) => base.transmute(self.layout_of(target)?, self)?,
|
||||
// We don't want anything happening here, this is here as a dummy.
|
||||
Subtype(_) => base.transmute(base.layout(), self)?,
|
||||
Field(field, _) => self.project_field(base, field.index())?,
|
||||
|
|
|
@ -277,6 +277,11 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
|||
let discr = self.discriminant_for_variant(op.layout.ty, variant)?;
|
||||
self.write_immediate(*discr, &dest)?;
|
||||
}
|
||||
|
||||
WrapUnsafeBinder(ref op, _ty) => {
|
||||
let op = self.eval_operand(op, None)?;
|
||||
self.copy_op_allow_transmute(&op, &dest)?;
|
||||
}
|
||||
}
|
||||
|
||||
trace!("{:?}", self.dump_place(&dest));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue