Skip to content

Commit

Permalink
compiler: replace some mem::forget's with ManuallyDrop
Browse files Browse the repository at this point in the history
  • Loading branch information
GrigorenkoPV committed Jul 14, 2024
1 parent 1295c79 commit 17a6874
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions compiler/rustc_lint/src/levels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,7 @@ 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);
self.provider.cur = std::mem::ManuallyDrop::new(push).prev;
}
}

Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_query_system/src/query/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use std::cell::Cell;
use std::collections::hash_map::Entry;
use std::fmt::Debug;
use std::hash::Hash;
use std::mem;
use std::mem::ManuallyDrop;
use thin_vec::ThinVec;
use tracing::instrument;

Expand Down Expand Up @@ -169,11 +169,11 @@ where
where
C: QueryCache<Key = K>,
{
let key = self.key;
let state = self.state;

// Forget ourself so our destructor won't poison the query
mem::forget(self);
let this = ManuallyDrop::new(self);

let key = this.key;
let state = this.state;

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

0 comments on commit 17a6874

Please sign in to comment.