Comment on the unsafety code for layout constrained fields
This commit is contained in:
parent
55abc0bc90
commit
e5d90652e2
@ -192,6 +192,12 @@ fn visit_place(&mut self,
|
||||
.ty(self.mir, self.tcx)
|
||||
.to_ty(self.tcx)
|
||||
.is_freeze(self.tcx, self.param_env, self.source_info.span);
|
||||
// prevent
|
||||
// * `&mut x.field`
|
||||
// * `x.field = y;`
|
||||
// * `&x.field` if `field`'s type has interior mutability
|
||||
// because either of these would allow modifying the layout constrained field and
|
||||
// insert values that violate the layout constraints.
|
||||
if context.is_mutating_use() || is_borrow_of_interior_mut {
|
||||
self.check_mut_borrowing_layout_constrained_field(
|
||||
place, context.is_mutating_use(),
|
||||
|
Loading…
Reference in New Issue
Block a user