From 783b1ce99c86106456329d7fc51c149bc27a282a Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Sat, 27 May 2023 14:52:41 -0400 Subject: Exclude Rvalue::AddressOf for raw pointer deref alignment checks --- compiler/rustc_mir_transform/src/check_alignment.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'compiler/rustc_mir_transform/src/check_alignment.rs') diff --git a/compiler/rustc_mir_transform/src/check_alignment.rs b/compiler/rustc_mir_transform/src/check_alignment.rs index d60184e0ebe..1fe8ea07892 100644 --- a/compiler/rustc_mir_transform/src/check_alignment.rs +++ b/compiler/rustc_mir_transform/src/check_alignment.rs @@ -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; -- cgit 1.4.1-3-g733a5