Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement Deref<Target=T> for JS<T> where T: Reflectable #8060
Conversation
highfive
commented
Oct 17, 2015
That isn't completely true. For example, servo/components/script/script_task.rs Line 409 in e31ad01 mouse_over_targets: DOMRefCell<Vec<JS<Node>>>,).
I'd be much more comfortable with this if we unified |
|
The case you point out isn't unsafe in terms of Rust, in the sense that only a panic will happen if we try to drop it while borrowed, AFAIK. |
|
The way Deref makes the problem worse is that if you write something like |
|
Unwrapping the result should make @Manishearth's lint complain, because it puts |
|
Yes, the lint is probably good enough that it isn't a big deal, just a minor thing to try and watch for when reviewing DOM code. |
|
We should perhaps disallow cloning |
|
@Manishearth I thought we had removed that with |
|
Isn't |
|
That's what I'm saying, I thought we had removed |
|
We can't remove |
| @@ -549,7 +549,6 @@ impl Document { | |||
| pub fn send_title_to_compositor(&self) { | |||
| let window = self.window(); | |||
| // FIXME(https://github.com/rust-lang/rust/issues/23338) | |||
| let window = window.r(); | |||
This comment has been minimized.
This comment has been minimized.
dzbarsky
Oct 18, 2015
Member
let compositor = self.window().compositor() and remove the above line and FIXME?
This comment has been minimized.
This comment has been minimized.
|
@bors-servo r+ Reviewed 23 of 23 files at r1. Comments from the review on Reviewable.io |
|
|
Implement Deref<Target=T> for JS<T> where T: Reflectable We can only borrow `JS<T>` from rooted things, so it's safe to deref it. The only types that provide mutable `JS<T>` things are `MutHeap<JS<T>>` and `MutNullableHeap<JS<T>>`, which don't actually expose that they contain `JS<T>` values. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8060) <!-- Reviewable:end -->
|
|
|
|
|
|
|
@bors-servo retry #7731 |
Implement Deref<Target=T> for JS<T> where T: Reflectable We can only borrow `JS<T>` from rooted things, so it's safe to deref it. The only types that provide mutable `JS<T>` things are `MutHeap<JS<T>>` and `MutNullableHeap<JS<T>>`, which don't actually expose that they contain `JS<T>` values. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8060) <!-- Reviewable:end -->
|
|
nox commentedOct 17, 2015
We can only borrow
JS<T>from rooted things, so it's safe to deref it.The only types that provide mutable
JS<T>things areMutHeap<JS<T>>andMutNullableHeap<JS<T>>, which don't actually expose that they containJS<T>values.