-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate an intermediate temporary for
Drop
constants.
To limit the fallout from this, don't do this for the last (or only) operand in an rvalue.
- Loading branch information
Showing
8 changed files
with
122 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,31 @@ | ||
// run-pass | ||
#![allow(unreachable_code)] | ||
|
||
use std::sync::atomic::{AtomicBool, Ordering}; | ||
use std::sync::atomic::{AtomicBool, Ordering, AtomicUsize}; | ||
|
||
struct Print(usize); | ||
|
||
impl Drop for Print { | ||
fn drop(&mut self) { | ||
println!("{}", self.0); | ||
FOO[self.0].store(true, Ordering::Relaxed); | ||
assert_eq!(BAR.fetch_sub(1, Ordering::Relaxed), self.0); | ||
} | ||
} | ||
|
||
const A: Print = Print(0); | ||
const B: Print = Print(1); | ||
|
||
static FOO: [AtomicBool; 3] = [AtomicBool::new(false), AtomicBool::new(false), AtomicBool::new(false)]; | ||
static FOO: [AtomicBool; 3] = | ||
[AtomicBool::new(false), AtomicBool::new(false), AtomicBool::new(false)]; | ||
static BAR: AtomicUsize = AtomicUsize::new(2); | ||
|
||
fn main() { | ||
loop { | ||
std::mem::forget(({A}, B, Print(2), break)); | ||
std::mem::forget(({ A }, B, Print(2), break)); | ||
} | ||
for (i, b) in FOO.iter().enumerate() { | ||
assert!(b.load(Ordering::Relaxed), "{} not set", i); | ||
} | ||
} | ||
assert_eq!(BAR.fetch_add(1, Ordering::Relaxed), usize::max_value()); | ||
} |