From fec53fd9db276d34d8d17701aeb3e81576d761fe Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 1 Oct 2022 09:49:52 +0200 Subject: [PATCH] Add sanity Drop impl. --- compiler/rustc_lint/src/levels.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/compiler/rustc_lint/src/levels.rs b/compiler/rustc_lint/src/levels.rs index 7b7831bd019e..be1d7d98aa69 100644 --- a/compiler/rustc_lint/src/levels.rs +++ b/compiler/rustc_lint/src/levels.rs @@ -494,6 +494,14 @@ impl<'s> LintLevelsBuilder<'s, TopDown> { /// Called after `push` when the scope of a set of attributes are exited. pub(crate) fn pop(&mut self, push: BuilderPush) { self.provider.cur = push.prev; + std::mem::forget(push); + } +} + +#[cfg(debug_assertions)] +impl Drop for BuilderPush { + fn drop(&mut self) { + panic!("Found a `push` without a `pop`."); } }