From 9f00d836af0a02110a0a47f4d4c7c7182f04574f Mon Sep 17 00:00:00 2001 From: ouz-a Date: Sun, 24 Jul 2022 13:26:20 +0300 Subject: [PATCH] make sure has_deref is correct --- compiler/rustc_middle/src/mir/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index a8408cfe570..f7311ebdabf 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -1464,6 +1464,8 @@ impl<'tcx> Place<'tcx> { /// If MirPhase >= Derefered and if projection contains Deref, /// It's guaranteed to be in the first place pub fn has_deref(&self) -> bool { + // To make sure this is not accidently used in wrong mir phase + debug_assert!(!self.projection[1..].contains(&PlaceElem::Deref)); self.projection.first() == Some(&PlaceElem::Deref) }