Skip to content

Commit 17a6874

Browse files
committed
compiler: replace some mem::forget's with ManuallyDrop
1 parent 1295c79 commit 17a6874

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

compiler/rustc_lint/src/levels.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -529,8 +529,7 @@ impl<'s> LintLevelsBuilder<'s, TopDown> {
529529

530530
/// Called after `push` when the scope of a set of attributes are exited.
531531
pub(crate) fn pop(&mut self, push: BuilderPush) {
532-
self.provider.cur = push.prev;
533-
std::mem::forget(push);
532+
self.provider.cur = std::mem::ManuallyDrop::new(push).prev;
534533
}
535534
}
536535

compiler/rustc_query_system/src/query/plumbing.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use std::cell::Cell;
2525
use std::collections::hash_map::Entry;
2626
use std::fmt::Debug;
2727
use std::hash::Hash;
28-
use std::mem;
28+
use std::mem::ManuallyDrop;
2929
use thin_vec::ThinVec;
3030
use tracing::instrument;
3131

@@ -169,11 +169,11 @@ where
169169
where
170170
C: QueryCache<Key = K>,
171171
{
172-
let key = self.key;
173-
let state = self.state;
174-
175172
// Forget ourself so our destructor won't poison the query
176-
mem::forget(self);
173+
let this = ManuallyDrop::new(self);
174+
175+
let key = this.key;
176+
let state = this.state;
177177

178178
// Mark as complete before we remove the job from the active state
179179
// so no other thread can re-execute this query.

0 commit comments

Comments
 (0)