Fix some no_move errors

This commit is contained in:
Manish Goregaokar 2015-04-26 23:01:13 +05:30
parent 63714ebc5f
commit dcb0a0eab6
17 changed files with 46 additions and 34 deletions

View file

@ -4492,6 +4492,7 @@ class CGDictionary(CGThing):
for m in self.memberInfo] for m in self.memberInfo]
return (string.Template( return (string.Template(
"#[no_move]\n" +
"pub struct ${selfName} {\n" + "pub struct ${selfName} {\n" +
"${inheritance}" + "${inheritance}" +
"\n".join(memberDecls) + "\n" + "\n".join(memberDecls) + "\n" +

View file

@ -34,6 +34,7 @@ pub enum GlobalRef<'a> {
} }
/// A stack-based rooted reference to a global object. /// A stack-based rooted reference to a global object.
#[no_move]
pub enum GlobalRoot { pub enum GlobalRoot {
/// A root for a `Window` object. /// A root for a `Window` object.
Window(Root<window::Window>), Window(Root<window::Window>),

View file

@ -152,7 +152,9 @@ pub mod trace;
/// Generated JS-Rust bindings. /// Generated JS-Rust bindings.
#[allow(missing_docs, non_snake_case)] #[allow(missing_docs, non_snake_case)]
pub mod codegen { pub mod codegen {
#[allow(unrooted_must_root)] // FIXME(#5853) we shouldn't need to
// allow moved_no_move here
#[allow(unrooted_must_root, moved_no_move)]
pub mod Bindings; pub mod Bindings;
pub mod InterfaceTypes; pub mod InterfaceTypes;
pub mod InheritTypes; pub mod InheritTypes;

View file

@ -1195,7 +1195,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
match title { match title {
None => DOMString::new(), None => DOMString::new(),
Some(title) => { Some(ref title) => {
// Steps 3-4. // Steps 3-4.
let value = Node::collect_text_contents(title.r().children()); let value = Node::collect_text_contents(title.r().children());
split_html_space_chars(&value).collect::<Vec<_>>().connect(" ") split_html_space_chars(&value).collect::<Vec<_>>().connect(" ")
@ -1310,9 +1310,9 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
return Ok(()); return Ok(());
} }
match (self.get_html_element().root(), old_body) { match (self.get_html_element().root(), &old_body) {
// Step 3. // Step 3.
(Some(ref root), Some(ref child)) => { (Some(ref root), &Some(ref child)) => {
let root: JSRef<Node> = NodeCast::from_ref(root.r()); let root: JSRef<Node> = NodeCast::from_ref(root.r());
let child: JSRef<Node> = NodeCast::from_ref(child.r()); let child: JSRef<Node> = NodeCast::from_ref(child.r());
let new_body: JSRef<Node> = NodeCast::from_ref(new_body); let new_body: JSRef<Node> = NodeCast::from_ref(new_body);
@ -1323,7 +1323,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
(None, _) => return Err(HierarchyRequest), (None, _) => return Err(HierarchyRequest),
// Step 5. // Step 5.
(Some(ref root), None) => { (Some(ref root), &None) => {
let root: JSRef<Node> = NodeCast::from_ref(root.r()); let root: JSRef<Node> = NodeCast::from_ref(root.r());
let new_body: JSRef<Node> = NodeCast::from_ref(new_body); let new_body: JSRef<Node> = NodeCast::from_ref(new_body);
assert!(root.AppendChild(new_body).is_ok()); assert!(root.AppendChild(new_body).is_ok());

View file

@ -92,7 +92,7 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> {
// Step 5. // Step 5.
match maybe_elem.root() { match maybe_elem.root() {
None => (), None => (),
Some(elem) => { Some(ref elem) => {
assert!(doc_node.AppendChild(NodeCast::from_ref(elem.r())).is_ok()) assert!(doc_node.AppendChild(NodeCast::from_ref(elem.r())).is_ok())
} }
} }

View file

@ -964,7 +964,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
})); }));
let attribute = self.get_attribute(&ns!(""), local_name).root(); let attribute = self.get_attribute(&ns!(""), local_name).root();
match attribute { match attribute {
Some(attribute) => { Some(ref attribute) => {
match *attribute.r().value() { match *attribute.r().value() {
AttrValue::UInt(_, value) => value, AttrValue::UInt(_, value) => value,
_ => panic!("Expected an AttrValue::UInt: \ _ => panic!("Expected an AttrValue::UInt: \
@ -1457,7 +1457,7 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
if !tree_in_doc { return; } if !tree_in_doc { return; }
if let Some(attr) = self.get_attribute(&ns!(""), &atom!("id")).root() { if let Some(ref attr) = self.get_attribute(&ns!(""), &atom!("id")).root() {
let doc = document_from_node(*self).root(); let doc = document_from_node(*self).root();
let value = attr.r().Value(); let value = attr.r().Value();
if !value.is_empty() { if !value.is_empty() {
@ -1474,7 +1474,7 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
if !tree_in_doc { return; } if !tree_in_doc { return; }
if let Some(attr) = self.get_attribute(&ns!(""), &atom!("id")).root() { if let Some(ref attr) = self.get_attribute(&ns!(""), &atom!("id")).root() {
let doc = document_from_node(*self).root(); let doc = document_from_node(*self).root();
let value = attr.r().Value(); let value = attr.r().Value();
if !value.is_empty() { if !value.is_empty() {
@ -1698,7 +1698,7 @@ impl<'a> ActivationElementHelpers<'a> for JSRef<'a, Element> {
// Step 4 // Step 4
let e = self.nearest_activable_element().root(); let e = self.nearest_activable_element().root();
match e { match e {
Some(el) => match el.r().as_maybe_activatable() { Some(ref el) => match el.r().as_maybe_activatable() {
Some(elem) => { Some(elem) => {
// Step 5-6 // Step 5-6
elem.pre_click_activation(); elem.pre_click_activation();

View file

@ -115,7 +115,7 @@ pub fn dispatch_event<'a, 'b>(target: JSRef<'a, EventTarget>,
/* default action */ /* default action */
let target = event.GetTarget().root(); let target = event.GetTarget().root();
match target { match target {
Some(target) => { Some(ref target) => {
let node: Option<JSRef<Node>> = NodeCast::to_ref(target.r()); let node: Option<JSRef<Node>> = NodeCast::to_ref(target.r());
match node { match node {
Some(node) => { Some(node) => {

View file

@ -522,7 +522,7 @@ pub trait FormControl<'a> : Copy + Sized {
let doc = document_from_node(elem).root(); let doc = document_from_node(elem).root();
let owner = doc.r().GetElementById(owner).root(); let owner = doc.r().GetElementById(owner).root();
match owner { match owner {
Some(o) => { Some(ref o) => {
let maybe_form: Option<JSRef<HTMLFormElement>> = HTMLFormElementCast::to_ref(o.r()); let maybe_form: Option<JSRef<HTMLFormElement>> = HTMLFormElementCast::to_ref(o.r());
if maybe_form.is_some() { if maybe_form.is_some() {
return maybe_form.map(Temporary::from_rooted); return maybe_form.map(Temporary::from_rooted);

View file

@ -354,7 +354,7 @@ fn broadcast_radio_checked(broadcaster: JSRef<HTMLInputElement>, group: Option<&
.map(|t| t.root()) .map(|t| t.root())
.filter(|r| in_same_group(r.r(), owner, group) && broadcaster != r.r()) .filter(|r| in_same_group(r.r(), owner, group) && broadcaster != r.r())
}; };
for r in iter { for ref r in iter {
if r.r().Checked() { if r.r().Checked() {
r.r().SetChecked(false); r.r().SetChecked(false);
} }
@ -743,7 +743,7 @@ impl<'a> Activatable for JSRef<'a, HTMLInputElement> {
let old_checked: Option<Root<HTMLInputElement>> = cache.checked_radio.get().root(); let old_checked: Option<Root<HTMLInputElement>> = cache.checked_radio.get().root();
let name = self.get_radio_group_name(); let name = self.get_radio_group_name();
match old_checked { match old_checked {
Some(o) => { Some(ref o) => {
// Avoiding iterating through the whole tree here, instead // Avoiding iterating through the whole tree here, instead
// we can check if the conditions for radio group siblings apply // we can check if the conditions for radio group siblings apply
if name == o.r().get_radio_group_name() && // TODO should be compatibility caseless if name == o.r().get_radio_group_name() && // TODO should be compatibility caseless

View file

@ -60,7 +60,7 @@ impl HTMLLinkElement {
fn get_attr(element: JSRef<Element>, local_name: &Atom) -> Option<String> { fn get_attr(element: JSRef<Element>, local_name: &Atom) -> Option<String> {
let elem = element.get_attribute(&ns!(""), local_name).root(); let elem = element.get_attribute(&ns!(""), local_name).root();
elem.map(|e| { elem.as_ref().map(|e| {
// FIXME(https://github.com/rust-lang/rust/issues/23338) // FIXME(https://github.com/rust-lang/rust/issues/23338)
let e = e.r(); let e = e.r();
let value = e.value(); let value = e.value();

View file

@ -223,7 +223,7 @@ impl<'a> HTMLScriptElementHelpers for JSRef<'a, HTMLScriptElement> {
} }
// Step 13. // Step 13.
if let Some(charset) = element.get_attribute(&ns!(""), &Atom::from_slice("charset")).root() { if let Some(ref charset) = element.get_attribute(&ns!(""), &Atom::from_slice("charset")).root() {
if let Some(encodingRef) = encoding_from_whatwg_label(&charset.r().Value()) { if let Some(encodingRef) = encoding_from_whatwg_label(&charset.r().Value()) {
*self.block_character_encoding.borrow_mut() = encodingRef; *self.block_character_encoding.borrow_mut() = encodingRef;
} }
@ -236,7 +236,7 @@ impl<'a> HTMLScriptElementHelpers for JSRef<'a, HTMLScriptElement> {
let load = match element.get_attribute(&ns!(""), &atom!("src")).root() { let load = match element.get_attribute(&ns!(""), &atom!("src")).root() {
// Step 14. // Step 14.
Some(src) => { Some(ref src) => {
// Step 14.1 // Step 14.1
let src = src.r().Value(); let src = src.r().Value();

View file

@ -298,7 +298,7 @@ impl<'a> PrivateNodeHelpers for JSRef<'a, Node> {
} }
let parent = self.parent_node().root(); let parent = self.parent_node().root();
parent.map(|parent| vtable_for(&parent.r()).child_inserted(self)); parent.as_ref().map(|parent| vtable_for(&parent.r()).child_inserted(self));
document.r().content_and_heritage_changed(self, NodeDamage::OtherNodeDamage); document.r().content_and_heritage_changed(self, NodeDamage::OtherNodeDamage);
} }
@ -331,7 +331,7 @@ impl<'a> PrivateNodeHelpers for JSRef<'a, Node> {
assert!(Some(*before) == self.first_child().root().r()); assert!(Some(*before) == self.first_child().root().r());
self.first_child.set(Some(JS::from_rooted(new_child))); self.first_child.set(Some(JS::from_rooted(new_child)));
}, },
Some(prev_sibling) => { Some(ref prev_sibling) => {
prev_sibling.r().next_sibling.set(Some(JS::from_rooted(new_child))); prev_sibling.r().next_sibling.set(Some(JS::from_rooted(new_child)));
new_child.prev_sibling.set(Some(JS::from_rooted(prev_sibling.r()))); new_child.prev_sibling.set(Some(JS::from_rooted(prev_sibling.r())));
}, },
@ -342,7 +342,7 @@ impl<'a> PrivateNodeHelpers for JSRef<'a, Node> {
None => { None => {
match self.last_child().root() { match self.last_child().root() {
None => self.first_child.set(Some(JS::from_rooted(new_child))), None => self.first_child.set(Some(JS::from_rooted(new_child))),
Some(last_child) => { Some(ref last_child) => {
assert!(last_child.r().next_sibling().is_none()); assert!(last_child.r().next_sibling().is_none());
last_child.r().next_sibling.set(Some(JS::from_rooted(new_child))); last_child.r().next_sibling.set(Some(JS::from_rooted(new_child)));
new_child.prev_sibling.set(Some(JS::from_rooted(last_child.r()))); new_child.prev_sibling.set(Some(JS::from_rooted(last_child.r())));
@ -366,7 +366,7 @@ impl<'a> PrivateNodeHelpers for JSRef<'a, Node> {
None => { None => {
self.first_child.set(child.next_sibling.get()); self.first_child.set(child.next_sibling.get());
} }
Some(prev_sibling) => { Some(ref prev_sibling) => {
prev_sibling.r().next_sibling.set(child.next_sibling.get()); prev_sibling.r().next_sibling.set(child.next_sibling.get());
} }
} }
@ -375,7 +375,7 @@ impl<'a> PrivateNodeHelpers for JSRef<'a, Node> {
None => { None => {
self.last_child.set(child.prev_sibling.get()); self.last_child.set(child.prev_sibling.get());
} }
Some(next_sibling) => { Some(ref next_sibling) => {
next_sibling.r().prev_sibling.set(child.prev_sibling.get()); next_sibling.r().prev_sibling.set(child.prev_sibling.get());
} }
} }
@ -978,7 +978,7 @@ impl<'a> NodeHelpers for JSRef<'a, Node> {
fn remove_self(self) { fn remove_self(self) {
match self.parent_node().root() { match self.parent_node().root() {
Some(parent) => parent.r().remove_child(self), Some(ref parent) => parent.r().remove_child(self),
None => () None => ()
} }
} }
@ -1377,7 +1377,7 @@ impl Node {
pub fn adopt(node: JSRef<Node>, document: JSRef<Document>) { pub fn adopt(node: JSRef<Node>, document: JSRef<Document>) {
// Step 1. // Step 1.
match node.parent_node().root() { match node.parent_node().root() {
Some(parent) => { Some(ref parent) => {
Node::remove(node, parent.r(), SuppressObserver::Unsuppressed); Node::remove(node, parent.r(), SuppressObserver::Unsuppressed);
} }
None => (), None => (),
@ -1773,7 +1773,7 @@ impl Node {
// FIXME: https://github.com/mozilla/servo/issues/1737 // FIXME: https://github.com/mozilla/servo/issues/1737
let window = document.window().root(); let window = document.window().root();
for attr in node_elem.attrs().iter().map(|attr| attr.root()) { for ref attr in node_elem.attrs().iter().map(|attr| attr.root()) {
copy_elem.attrs_mut().push_unrooted( copy_elem.attrs_mut().push_unrooted(
&Attr::new(window.r(), &Attr::new(window.r(),
attr.r().local_name().clone(), attr.r().value().clone(), attr.r().local_name().clone(), attr.r().value().clone(),
@ -2581,7 +2581,7 @@ impl<'a> DisabledStateHelpers for JSRef<'a, Node> {
.map(|child| child.root()) .map(|child| child.root())
.find(|child| child.r().is_htmllegendelement()) .find(|child| child.r().is_htmllegendelement())
{ {
Some(legend) => { Some(ref legend) => {
// XXXabinader: should we save previous ancestor to avoid this iteration? // XXXabinader: should we save previous ancestor to avoid this iteration?
if self.ancestors().any(|ancestor| ancestor.root().r() == legend.r()) { continue; } if self.ancestors().any(|ancestor| ancestor.root().r() == legend.r()) { continue; }
}, },

View file

@ -94,7 +94,7 @@ impl<'a> TextMethods for JSRef<'a, Text> {
let nodes = first.r().inclusively_following_siblings().map(|node| node.root()) let nodes = first.r().inclusively_following_siblings().map(|node| node.root())
.take_while(|node| node.r().is_text()); .take_while(|node| node.r().is_text());
let mut text = DOMString::new(); let mut text = DOMString::new();
for node in nodes { for ref node in nodes {
let cdata = CharacterDataCast::to_ref(node.r()).unwrap(); let cdata = CharacterDataCast::to_ref(node.r()).unwrap();
text.push_str(&cdata.data()); text.push_str(&cdata.data());
} }

View file

@ -900,7 +900,7 @@ impl ScriptTask {
let doc = page.document().root(); let doc = page.document().root();
let frame_element = self.find_iframe(doc.r(), subpage_id).root(); let frame_element = self.find_iframe(doc.r(), subpage_id).root();
if let Some(frame_element) = frame_element { if let Some(ref frame_element) = frame_element {
let element: JSRef<Element> = ElementCast::from_ref(frame_element.r()); let element: JSRef<Element> = ElementCast::from_ref(frame_element.r());
doc.r().begin_focus_transaction(); doc.r().begin_focus_transaction();
doc.r().request_focus(element); doc.r().request_focus(element);
@ -921,7 +921,7 @@ impl ScriptTask {
self.find_iframe(doc.r(), subpage_id) self.find_iframe(doc.r(), subpage_id)
}).root(); }).root();
if let Some(frame_element) = frame_element { if let Some(ref frame_element) = frame_element {
frame_element.r().dispatch_mozbrowser_event(event); frame_element.r().dispatch_mozbrowser_event(event);
} }
} }
@ -937,7 +937,7 @@ impl ScriptTask {
self.find_iframe(doc.r(), old_subpage_id) self.find_iframe(doc.r(), old_subpage_id)
}).root(); }).root();
frame_element.unwrap().r().update_subpage_id(new_subpage_id); frame_element.as_ref().unwrap().r().update_subpage_id(new_subpage_id);
} }
/// Handles a notification that reflow completed. /// Handles a notification that reflow completed.
@ -1295,7 +1295,7 @@ impl ScriptTask {
let page = get_page(&self.root_page(), pipeline_id); let page = get_page(&self.root_page(), pipeline_id);
let document = page.document().root(); let document = page.document().root();
match document.r().find_fragment_node(fragment).root() { match document.r().find_fragment_node(fragment).root() {
Some(node) => { Some(ref node) => {
self.scroll_fragment_point(pipeline_id, node.r()); self.scroll_fragment_point(pipeline_id, node.r());
} }
None => {} None => {}
@ -1314,7 +1314,7 @@ impl ScriptTask {
.and_then(|name| document.r().find_fragment_node(name)) .and_then(|name| document.r().find_fragment_node(name))
.root(); .root();
match fragment_node { match fragment_node {
Some(node) => self.scroll_fragment_point(pipeline_id, node.r()), Some(ref node) => self.scroll_fragment_point(pipeline_id, node.r()),
None => {} None => {}
} }

View file

@ -781,6 +781,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "plugins" name = "plugins"
version = "0.0.1" version = "0.0.1"
dependencies = [
"tenacious 0.0.1 (git+https://github.com/Manishearth/rust-tenacious.git)",
]
[[package]] [[package]]
name = "pnacl-build-helper" name = "pnacl-build-helper"
@ -980,6 +983,11 @@ dependencies = [
name = "task_info" name = "task_info"
version = "0.0.1" version = "0.0.1"
[[package]]
name = "tenacious"
version = "0.0.1"
source = "git+https://github.com/Manishearth/rust-tenacious.git#d61782e70005a9f0cdf66f366d4ec88fc563ea1e"
[[package]] [[package]]
name = "text_writer" name = "text_writer"
version = "0.1.9" version = "0.1.9"

2
ports/cef/Cargo.lock generated
View file

@ -966,7 +966,7 @@ version = "0.0.1"
[[package]] [[package]]
name = "tenacious" name = "tenacious"
version = "0.0.1" version = "0.0.1"
source = "git+https://github.com/Manishearth/rust-tenacious.git#f47093c600b8cc1b29f89759eea6c18920584f71" source = "git+https://github.com/Manishearth/rust-tenacious.git#d61782e70005a9f0cdf66f366d4ec88fc563ea1e"
[[package]] [[package]]
name = "text_writer" name = "text_writer"

2
ports/gonk/Cargo.lock generated
View file

@ -957,7 +957,7 @@ version = "0.0.1"
[[package]] [[package]]
name = "tenacious" name = "tenacious"
version = "0.0.1" version = "0.0.1"
source = "git+https://github.com/Manishearth/rust-tenacious.git#f47093c600b8cc1b29f89759eea6c18920584f71" source = "git+https://github.com/Manishearth/rust-tenacious.git#d61782e70005a9f0cdf66f366d4ec88fc563ea1e"
[[package]] [[package]]
name = "text_writer" name = "text_writer"