servo/components/script/dom/bindings
bors-servo 80cb0cf821 Auto merge of #11872 - eddyb:back-to-roots, r=Ms2ger
Replace return_address usage for rooting with stack guards and convenience macros.

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

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11872)
<!-- Reviewable:end -->
2016-07-04 11:03:35 -07:00
..
codegen Auto merge of #11872 - eddyb:back-to-roots, r=Ms2ger 2016-07-04 11:03:35 -07:00
callback.rs Switch to using the new rooted!/RootedGuard API for rooting. 2016-07-04 20:59:01 +03:00
cell.rs task -> thread 2016-01-10 17:58:13 +09:00
conversions.rs Move DOMString back to script 2016-05-24 10:54:57 +02:00
error.rs Switch to using the new rooted!/RootedGuard API for rooting. 2016-07-04 20:59:01 +03:00
global.rs removed unused imports 2016-06-02 16:18:13 -06:00
guard.rs Refactor util::prefs operations to be methods on static struct. 2016-07-02 16:43:39 -04:00
inheritance.rs Rustfmt some of script. 2015-11-18 11:14:05 +01:00
interface.rs Switch to using the new rooted!/RootedGuard API for rooting. 2016-07-04 20:59:01 +03:00
js.rs Move TrustedNodeAddress to script_layout_interface. 2016-06-20 19:08:06 +02:00
mod.rs Remove utils::Prefable in favour of guard::Guard 2016-05-26 23:56:13 +02:00
num.rs Use num-traits in script. 2016-04-20 15:23:43 +02:00
proxyhandler.rs Switch to using the new rooted!/RootedGuard API for rooting. 2016-07-04 20:59:01 +03:00
refcounted.rs Make debug logging for tracing JS objects more informative. 2016-05-11 08:34:48 -04:00
reflector.rs Add global default method for Reflectable trait 2016-01-11 20:23:47 -05:00
str.rs Remove unused ByteString::bytes() and its unit test. 2016-06-07 14:20:44 +02:00
structuredclone.rs Update SpiderMonkey 2016-05-03 18:36:11 +02:00
trace.rs Auto merge of #11872 - eddyb:back-to-roots, r=Ms2ger 2016-07-04 11:03:35 -07:00
utils.rs Switch to using the new rooted!/RootedGuard API for rooting. 2016-07-04 20:59:01 +03:00
weakref.rs Removed unused imports 2016-05-15 22:24:26 +03:00
xmlname.rs Move DOMString back to script 2016-05-24 10:54:57 +02:00