gecko-dev/servo/ports
Eduard Burtescu da092febcb servo: Merge #11872 - Replace return_address usage for rooting with stack guards and convenience macros (from eddyb:back-to-roots); r=Ms2ger
The existing `Rooted` and `RootedVec` users were migrated the the following two macros:
```rust
let x = Rooted::new(cx, value);
// Was changed to:
rooted!(in(cx) let x = value);
// Which expands to:
let mut __root = Rooted::new_unrooted(value);
let x = RootedGuard::new(cx, &mut __root);
```
```rust
let mut v = RootedVec::new();
v.extend(iterator);
// Was changed to:
rooted_vec!(let v <- iterator);
// Which expands to:
let mut __root = RootableVec::new();
let v = RootedVec::new(&mut __root, iterator);
```

The `rooted!` macro depends on servo/rust-mozjs#272.
These APIs based on two types, a container to be rooted and a rooting guard, allow implementing both `Rooted`-style rooting and `Traceable`-based rooting in stable Rust, without abusing `return_address`.

Such macros may have been tried before, but in 1.9 their hygiene is broken, they work only since 1.10.

Sadly, `Rooted` is a FFI type and completely exposed, so I cannot prevent anyone from creating their own, although all fields but the value get overwritten by `RootedGuard::new` anyway.
`RootableVec` OTOH is *guaranteed* to be empty when not rooted, which makes it harmless AFAICT.

By fixing rust-lang/rust#34227, this PR enables Servo to build with `-Zorbit`.

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix rust-lang/rust#34227
- [x] These changes do not require tests because they are not functional changes

Source-Repo: https://github.com/servo/servo
Source-Revision: 80cb0cf8214fd52d2884724614c40cb278ee7575
2016-07-04 11:03:35 -07:00
..
cef servo: Merge #11872 - Replace return_address usage for rooting with stack guards and convenience macros (from eddyb:back-to-roots); r=Ms2ger 2016-07-04 11:03:35 -07:00
geckolib servo: Merge #11972 - Staticize CASCADE_PROPERTIES, (temporarily) fix stylo path for animations, and introduce the long-term path to follow (from emilio:style-thingies); r=bholley 2016-07-02 13:27:25 -07:00
glutin servo: Merge #12178 - Refactor util::prefs operations to be methods on static struct (from frewsxcv:prefs); r=emilio 2016-07-03 08:19:04 -07:00