Skip to content

Commit

Permalink
Exclude Rvalue::AddressOf for raw pointer deref alignment checks
Browse files Browse the repository at this point in the history
  • Loading branch information
saethlin authored and Mark-Simulacrum committed May 30, 2023
1 parent 655516b commit 8fc89a2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions compiler/rustc_mir_transform/src/check_alignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ struct PointerFinder<'tcx, 'a> {
}

impl<'tcx, 'a> Visitor<'tcx> for PointerFinder<'tcx, 'a> {
fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {
if let Rvalue::AddressOf(..) = rvalue {
// Ignore dereferences inside of an AddressOf
return;
}
self.super_rvalue(rvalue, location);
}

fn visit_place(&mut self, place: &Place<'tcx>, context: PlaceContext, _location: Location) {
if let PlaceContext::NonUse(_) = context {
return;
Expand Down

0 comments on commit 8fc89a2

Please sign in to comment.