Skip to content

Commit

Permalink
Workaround issue 22462 by moving static value into its own module.
Browse files Browse the repository at this point in the history
Precursor for overloaded-`box` and placement-`in`; see Issue 22181.
  • Loading branch information
pnkfelix committed Mar 12, 2015
1 parent 2d44712 commit a0e3c71
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/test/run-pass/drop-struct-as-object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@
#![allow(unknown_features)]
#![feature(box_syntax)]

static mut value: uint = 0;
mod s {
// FIXME(22181,22462) workaround hygiene issues between box
// desugaring, macro-hygiene (or lack thereof) and static bindings
// by forcing the static binding `value` into its own module.

pub static mut value: uint = 0;
}

struct Cat {
name : uint,
Expand All @@ -30,7 +36,7 @@ impl Dummy for Cat {

impl Drop for Cat {
fn drop(&mut self) {
unsafe { value = self.name; }
unsafe { s::value = self.name; }
}
}

Expand All @@ -40,6 +46,6 @@ pub fn main() {
let nyan: Box<Dummy> = x as Box<Dummy>;
}
unsafe {
assert_eq!(value, 22);
assert_eq!(s::value, 22);
}
}

0 comments on commit a0e3c71

Please sign in to comment.