Skip to content

Commit 783b1ce

Browse files
committed
Exclude Rvalue::AddressOf for raw pointer deref alignment checks
1 parent de4dddf commit 783b1ce

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

compiler/rustc_mir_transform/src/check_alignment.rs

+8
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ struct PointerFinder<'tcx, 'a> {
7575
}
7676

7777
impl<'tcx, 'a> Visitor<'tcx> for PointerFinder<'tcx, 'a> {
78+
fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {
79+
if let Rvalue::AddressOf(..) = rvalue {
80+
// Ignore dereferences inside of an AddressOf
81+
return;
82+
}
83+
self.super_rvalue(rvalue, location);
84+
}
85+
7886
fn visit_place(&mut self, place: &Place<'tcx>, context: PlaceContext, _location: Location) {
7987
if let PlaceContext::NonUse(_) = context {
8088
return;

0 commit comments

Comments
 (0)