diff options
author | Simon Sapin <simon.sapin@exyr.org> | 2019-07-31 13:34:01 +0200 |
---|---|---|
committer | Simon Sapin <simon.sapin@exyr.org> | 2019-07-31 13:34:01 +0200 |
commit | c38c964f1b1d2614f50863be0b896e1700b5fea8 (patch) | |
tree | cb22eaf3b552b3fac4bd06b70e42fbf3d30e369c /components | |
parent | 87e7e3d429f2122ffa9ef016ba5659a3b21be91b (diff) | |
download | servo-c38c964f1b1d2614f50863be0b896e1700b5fea8.tar.gz servo-c38c964f1b1d2614f50863be0b896e1700b5fea8.zip |
Upgrade to rustc 1.38.0-nightly (dddb7fca0 2019-07-30)
Diffstat (limited to 'components')
37 files changed, 117 insertions, 108 deletions
diff --git a/components/config/lib.rs b/components/config/lib.rs index f00c2b853f8..47bef2f0c3e 100644 --- a/components/config/lib.rs +++ b/components/config/lib.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -#![feature(core_intrinsics)] #![deny(unsafe_code)] #[macro_use] diff --git a/components/config/pref_util.rs b/components/config/pref_util.rs index 152719209bb..8a3fde0c99b 100644 --- a/components/config/pref_util.rs +++ b/components/config/pref_util.rs @@ -116,7 +116,7 @@ macro_rules! impl_from_pref { panic!( format!("Cannot convert {:?} to {:?}", other, - unsafe { std::intrinsics::type_name::<$t>() } + std::any::type_name::<$t>() ) ); } diff --git a/components/profile_traits/energy.rs b/components/profile_traits/energy.rs index 93891df4adb..fec9a92c61b 100644 --- a/components/profile_traits/energy.rs +++ b/components/profile_traits/energy.rs @@ -60,5 +60,4 @@ mod energymon { init(); unsafe { EM.map_or(0, |em| ((*em).interval_us() as f64 / 1000.0).ceil() as u32) } } - } diff --git a/components/script/dom/attr.rs b/components/script/dom/attr.rs index 269627bf870..886f62718e9 100644 --- a/components/script/dom/attr.rs +++ b/components/script/dom/attr.rs @@ -194,7 +194,7 @@ impl Attr { ScriptThread::enqueue_callback_reaction(owner, reaction, None); } - assert_eq!(Some(owner), self.owner().deref()); + assert_eq!(Some(owner), self.owner().as_deref()); owner.will_mutate_attr(self); self.swap_value(&mut value); if self.identifier.namespace == ns!() { @@ -227,7 +227,11 @@ impl Attr { match (self.owner(), owner) { (Some(old), None) => { // Already gone from the list of attributes of old owner. - assert!(old.get_attribute(&ns, &self.identifier.local_name).deref() != Some(self)) + assert!( + old.get_attribute(&ns, &self.identifier.local_name) + .as_deref() != + Some(self) + ) }, (Some(old), Some(new)) => assert_eq!(&*old, new), _ => {}, diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 72f13335ac0..ca041fdddeb 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -7301,9 +7301,9 @@ def process_arg(expr, arg): if arg.variadic or arg.type.isSequence(): expr += ".r()" elif arg.type.nullable() and arg.optional and not arg.defaultValue: - expr += ".as_ref().map(Option::deref)" + expr += ".as_ref().map(Option::as_deref)" elif arg.type.nullable() or arg.optional and not arg.defaultValue: - expr += ".deref()" + expr += ".as_deref()" else: expr = "&" + expr elif isinstance(arg.type, IDLPromiseType): diff --git a/components/script/dom/bindings/root.rs b/components/script/dom/bindings/root.rs index c87c83a2469..6e2c883984c 100644 --- a/components/script/dom/bindings/root.rs +++ b/components/script/dom/bindings/root.rs @@ -332,7 +332,7 @@ unsafe impl<T: DomObject> JSTraceable for Dom<T> { unsafe fn trace(&self, trc: *mut JSTracer) { let trace_string; let trace_info = if cfg!(debug_assertions) { - trace_string = format!("for {} on heap", ::std::intrinsics::type_name::<T>()); + trace_string = format!("for {} on heap", ::std::any::type_name::<T>()); &trace_string[..] } else { "for DOM object on heap" diff --git a/components/script/dom/compositionevent.rs b/components/script/dom/compositionevent.rs index a0f99715cf2..aa72db95d21 100644 --- a/components/script/dom/compositionevent.rs +++ b/components/script/dom/compositionevent.rs @@ -53,7 +53,7 @@ impl CompositionEvent { type_, init.parent.parent.bubbles, init.parent.parent.cancelable, - init.parent.view.deref(), + init.parent.view.as_deref(), init.parent.detail, init.data.clone(), ); diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 85639964710..c9c9a1156bc 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -612,7 +612,7 @@ impl Document { .upcast::<Element>() .has_attribute(&local_name!("href")) }); - self.base_element.set(base.deref()); + self.base_element.set(base.as_deref()); } pub fn dom_count(&self) -> u32 { @@ -757,7 +757,7 @@ impl Document { let target = self.find_fragment_node(fragment); // Step 1 - self.set_target_element(target.deref()); + self.set_target_element(target.as_deref()); let point = target .as_ref() @@ -798,7 +798,7 @@ impl Document { y, global_scope.pipeline_id().root_scroll_id(), ScrollBehavior::Instant, - target.deref(), + target.as_deref(), ); } } @@ -862,7 +862,7 @@ impl Document { /// Reassign the focus context to the element that last requested focus during this /// transaction, or none if no elements requested it. pub fn commit_focus_transaction(&self, focus_type: FocusType) { - if self.focused == self.possibly_focused.get().deref() { + if self.focused == self.possibly_focused.get().as_deref() { return; } if let Some(ref elem) = self.focused.get() { @@ -877,7 +877,7 @@ impl Document { } } - self.focused.set(self.possibly_focused.get().deref()); + self.focused.set(self.possibly_focused.get().as_deref()); if let Some(ref elem) = self.focused.get() { elem.set_focus_state(true); @@ -1224,7 +1224,7 @@ impl Document { } // Store the current mouse over target for next frame. - prev_mouse_over_target.set(maybe_new_target.deref()); + prev_mouse_over_target.set(maybe_new_target.as_deref()); self.window .reflow(ReflowGoal::Full, ReflowReason::MouseEvent); @@ -2892,7 +2892,7 @@ impl Document { fn create_node_list<F: Fn(&Node) -> bool>(&self, callback: F) -> DomRoot<NodeList> { let doc = self.GetDocumentElement(); - let maybe_node = doc.deref().map(Castable::upcast::<Node>); + let maybe_node = doc.as_deref().map(Castable::upcast::<Node>); let iter = maybe_node .iter() .flat_map(|node| node.traverse_preorder(ShadowIncluding::No)) @@ -3900,7 +3900,7 @@ impl DocumentMethods for Document { let parent = root.upcast::<Node>(); let child = elem.upcast::<Node>(); parent - .InsertBefore(child, parent.GetFirstChild().deref()) + .InsertBefore(child, parent.GetFirstChild().as_deref()) .unwrap() }, } @@ -3985,7 +3985,7 @@ impl DocumentMethods for Document { // Step 2. let old_body = self.GetBody(); - if old_body.deref() == Some(new_body) { + if old_body.as_deref() == Some(new_body) { return Ok(()); } diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 91d7a8aa450..4b16db4699e 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -1365,7 +1365,7 @@ impl Element { ScriptThread::enqueue_callback_reaction(self, reaction, None); } - assert!(attr.GetOwnerElement().deref() == Some(self)); + assert!(attr.GetOwnerElement().as_deref() == Some(self)); self.will_mutate_attr(attr); self.attrs.borrow_mut().push(Dom::from_ref(attr)); if attr.namespace() == &ns!() { @@ -1680,12 +1680,12 @@ impl Element { } }, AdjacentPosition::AfterBegin => { - Node::pre_insert(node, &self_node, self_node.GetFirstChild().deref()).map(Some) + Node::pre_insert(node, &self_node, self_node.GetFirstChild().as_deref()).map(Some) }, AdjacentPosition::BeforeEnd => Node::pre_insert(node, &self_node, None).map(Some), AdjacentPosition::AfterEnd => { if let Some(parent) = self_node.GetParentNode() { - Node::pre_insert(node, &parent, self_node.GetNextSibling().deref()).map(Some) + Node::pre_insert(node, &parent, self_node.GetNextSibling().as_deref()).map(Some) } else { Ok(None) } @@ -1725,7 +1725,7 @@ impl Element { } // Step 9 - if doc.GetBody().deref() == self.downcast::<HTMLElement>() && + if doc.GetBody().as_deref() == self.downcast::<HTMLElement>() && doc.quirks_mode() == QuirksMode::Quirks && !self.potentially_scrollable() { @@ -2194,7 +2194,7 @@ impl ElementMethods for Element { } // Step 7 - if doc.GetBody().deref() == self.downcast::<HTMLElement>() && + if doc.GetBody().as_deref() == self.downcast::<HTMLElement>() && doc.quirks_mode() == QuirksMode::Quirks && !self.potentially_scrollable() { @@ -2244,7 +2244,7 @@ impl ElementMethods for Element { } // Step 9 - if doc.GetBody().deref() == self.downcast::<HTMLElement>() && + if doc.GetBody().as_deref() == self.downcast::<HTMLElement>() && doc.quirks_mode() == QuirksMode::Quirks && !self.potentially_scrollable() { @@ -2290,7 +2290,7 @@ impl ElementMethods for Element { } // Step 7 - if doc.GetBody().deref() == self.downcast::<HTMLElement>() && + if doc.GetBody().as_deref() == self.downcast::<HTMLElement>() && doc.quirks_mode() == QuirksMode::Quirks && !self.potentially_scrollable() { @@ -2341,7 +2341,7 @@ impl ElementMethods for Element { } // Step 9 - if doc.GetBody().deref() == self.downcast::<HTMLElement>() && + if doc.GetBody().as_deref() == self.downcast::<HTMLElement>() && doc.quirks_mode() == QuirksMode::Quirks && !self.potentially_scrollable() { @@ -2856,7 +2856,7 @@ impl VirtualMethods for Element { } let fullscreen = doc.GetFullscreenElement(); - if fullscreen.deref() == Some(self) { + if fullscreen.as_deref() == Some(self) { doc.exit_fullscreen(); } if let Some(ref value) = *self.id_attribute.borrow() { diff --git a/components/script/dom/event.rs b/components/script/dom/event.rs index 7c56e672e11..a14beccabe3 100644 --- a/components/script/dom/event.rs +++ b/components/script/dom/event.rs @@ -485,7 +485,7 @@ fn dispatch_to_listeners(event: &Event, target: &EventTarget, event_path: &[&Eve // Step 6. for object in event_path.iter().rev() { invoke( - window.deref(), + window.as_deref(), object, event, Some(ListenerPhase::Capturing), @@ -501,7 +501,7 @@ fn dispatch_to_listeners(event: &Event, target: &EventTarget, event_path: &[&Eve event.phase.set(EventPhase::AtTarget); // Step 8. - invoke(window.deref(), target, event, None); + invoke(window.as_deref(), target, event, None); if event.stop_propagation.get() { return; } @@ -517,7 +517,12 @@ fn dispatch_to_listeners(event: &Event, target: &EventTarget, event_path: &[&Eve // Step 9.2. for object in event_path { - invoke(window.deref(), object, event, Some(ListenerPhase::Bubbling)); + invoke( + window.as_deref(), + object, + event, + Some(ListenerPhase::Bubbling), + ); if event.stop_propagation.get() { return; } diff --git a/components/script/dom/focusevent.rs b/components/script/dom/focusevent.rs index 44440cc24df..2a19ce48729 100644 --- a/components/script/dom/focusevent.rs +++ b/components/script/dom/focusevent.rs @@ -72,9 +72,9 @@ impl FocusEvent { type_, bubbles, cancelable, - init.parent.view.deref(), + init.parent.view.as_deref(), init.parent.detail, - init.relatedTarget.deref(), + init.relatedTarget.as_deref(), ); Ok(event) } diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs index 95ac9918996..7bec738f382 100644 --- a/components/script/dom/htmlelement.rs +++ b/components/script/dom/htmlelement.rs @@ -694,7 +694,7 @@ impl HTMLElement { .take_while(|elem| !elem.is_labelable_element()) .filter_map(DomRoot::downcast::<HTMLLabelElement>) .filter(|elem| !elem.upcast::<Element>().has_attribute(&local_name!("for"))) - .filter(|elem| elem.first_labelable_descendant().deref() == Some(self)) + .filter(|elem| elem.first_labelable_descendant().as_deref() == Some(self)) .map(DomRoot::upcast::<Node>); let id = element.Id(); diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index 03e4b8b5195..603ebf69f56 100755 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -1094,7 +1094,7 @@ pub trait FormControl: DomObject { if let Some(ref new_owner) = new_owner { new_owner.add_control(self); } - self.set_form_owner(new_owner.deref()); + self.set_form_owner(new_owner.as_deref()); } } diff --git a/components/script/dom/htmlheadelement.rs b/components/script/dom/htmlheadelement.rs index 0389ff9b43b..07054971ffa 100644 --- a/components/script/dom/htmlheadelement.rs +++ b/components/script/dom/htmlheadelement.rs @@ -49,7 +49,7 @@ impl HTMLHeadElement { pub fn set_document_referrer(&self) { let doc = document_from_node(self); - if doc.GetHead().deref() != Some(self) { + if doc.GetHead().as_deref() != Some(self) { return; } diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index 26a5c41a26c..fa389cf9941 100755 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -903,7 +903,7 @@ fn broadcast_radio_checked(broadcaster: &HTMLInputElement, group: Option<&Atom>) } } - do_broadcast(doc.upcast(), broadcaster, owner.deref(), group) + do_broadcast(doc.upcast(), broadcaster, owner.as_deref(), group) } // https://html.spec.whatwg.org/multipage/#radio-button-group @@ -914,7 +914,7 @@ fn in_same_group( ) -> bool { other.input_type() == InputType::Radio && // TODO Both a and b are in the same home subtree. - other.form_owner().deref() == owner && + other.form_owner().as_deref() == owner && match (other.radio_group_name(), group) { (Some(ref s1), Some(s2)) => compatibility_caseless_match_str(s1, s2) && s2 != &atom!(""), _ => false @@ -1647,8 +1647,10 @@ impl Activatable for HTMLInputElement { .query_selector_iter(DOMString::from("input[type=radio]")) .unwrap() .filter_map(DomRoot::downcast::<HTMLInputElement>) - .find(|r| in_same_group(&*r, owner.deref(), group.as_ref()) && r.Checked()); - cache.checked_radio = checked_member.deref().map(Dom::from_ref); + .find(|r| { + in_same_group(&*r, owner.as_deref(), group.as_ref()) && r.Checked() + }); + cache.checked_radio = checked_member.as_deref().map(Dom::from_ref); cache.checked_changed = self.checked_changed.get(); self.SetChecked(true); }, @@ -1689,7 +1691,7 @@ impl Activatable for HTMLInputElement { // we can check if the conditions for radio group siblings apply if in_same_group( &o, - self.form_owner().deref(), + self.form_owner().as_deref(), self.radio_group_name().as_ref(), ) { o.SetChecked(true); diff --git a/components/script/dom/htmloptionscollection.rs b/components/script/dom/htmloptionscollection.rs index e67c94d35b1..8eb0c4e284b 100644 --- a/components/script/dom/htmloptionscollection.rs +++ b/components/script/dom/htmloptionscollection.rs @@ -192,7 +192,7 @@ impl HTMLOptionsCollectionMethods for HTMLOptionsCollection { }; // Step 6 - Node::pre_insert(node, &parent, reference_node.deref()).map(|_| ()) + Node::pre_insert(node, &parent, reference_node.as_deref()).map(|_| ()) } // https://html.spec.whatwg.org/multipage/#dom-htmloptionscollection-remove diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs index 1af49a42f79..dbfda59db02 100644 --- a/components/script/dom/htmlscriptelement.rs +++ b/components/script/dom/htmlscriptelement.rs @@ -625,7 +625,7 @@ impl HTMLScriptElement { self.run_a_classic_script(&script); // Step 6. - document.set_current_script(old_script.deref()); + document.set_current_script(old_script.as_deref()); // Step 7. if let Some(doc) = neutralized_doc { diff --git a/components/script/dom/htmltableelement.rs b/components/script/dom/htmltableelement.rs index c27aa17d39e..bc4724493c4 100644 --- a/components/script/dom/htmltableelement.rs +++ b/components/script/dom/htmltableelement.rs @@ -190,7 +190,7 @@ impl HTMLTableElementMethods for HTMLTableElement { if let Some(caption) = new_caption { let node = self.upcast::<Node>(); - node.InsertBefore(caption.upcast(), node.GetFirstChild().deref()) + node.InsertBefore(caption.upcast(), node.GetFirstChild().as_deref()) .expect("Insertion failed"); } } @@ -281,7 +281,7 @@ impl HTMLTableElementMethods for HTMLTableElement { fn filter(&self, elem: &Element, root: &Node) -> bool { elem.is::<HTMLTableSectionElement>() && elem.local_name() == &local_name!("tbody") && - elem.upcast::<Node>().GetParentNode().deref() == Some(root) + elem.upcast::<Node>().GetParentNode().as_deref() == Some(root) } } @@ -303,7 +303,7 @@ impl HTMLTableElementMethods for HTMLTableElement { .find(|n| n.is::<HTMLTableSectionElement>() && n.local_name() == &local_name!("tbody")); let reference_element = last_tbody.and_then(|t| t.upcast::<Node>().GetNextSibling()); - node.InsertBefore(tbody.upcast(), reference_element.deref()) + node.InsertBefore(tbody.upcast(), reference_element.as_deref()) .expect("Insertion failed"); tbody } diff --git a/components/script/dom/htmltablerowelement.rs b/components/script/dom/htmltablerowelement.rs index e7e2a6d2a99..fbe7ef0cfc8 100644 --- a/components/script/dom/htmltablerowelement.rs +++ b/components/script/dom/htmltablerowelement.rs @@ -31,7 +31,7 @@ struct CellsFilter; impl CollectionFilter for CellsFilter { fn filter(&self, elem: &Element, root: &Node) -> bool { (elem.is::<HTMLTableCellElement>()) && - elem.upcast::<Node>().GetParentNode().deref() == Some(root) + elem.upcast::<Node>().GetParentNode().as_deref() == Some(root) } } diff --git a/components/script/dom/htmltablesectionelement.rs b/components/script/dom/htmltablesectionelement.rs index ff7dbcd3679..6d31e1ad0c6 100644 --- a/components/script/dom/htmltablesectionelement.rs +++ b/components/script/dom/htmltablesectionelement.rs @@ -59,7 +59,7 @@ struct RowsFilter; impl CollectionFilter for RowsFilter { fn filter(&self, elem: &Element, root: &Node) -> bool { elem.is::<HTMLTableRowElement>() && - elem.upcast::<Node>().GetParentNode().deref() == Some(root) + elem.upcast::<Node>().GetParentNode().as_deref() == Some(root) } } diff --git a/components/script/dom/inputevent.rs b/components/script/dom/inputevent.rs index c991e9779b9..9a0925d7f21 100644 --- a/components/script/dom/inputevent.rs +++ b/components/script/dom/inputevent.rs @@ -54,7 +54,7 @@ impl InputEvent { type_, init.parent.parent.bubbles, init.parent.parent.cancelable, - init.parent.view.deref(), + init.parent.view.as_deref(), init.parent.detail, init.data.clone(), init.isComposing, diff --git a/components/script/dom/keyboardevent.rs b/components/script/dom/keyboardevent.rs index 0c0376085b3..cdf44774454 100644 --- a/components/script/dom/keyboardevent.rs +++ b/components/script/dom/keyboardevent.rs @@ -111,7 +111,7 @@ impl KeyboardEvent { type_, init.parent.parent.parent.bubbles, init.parent.parent.parent.cancelable, - init.parent.parent.view.deref(), + init.parent.parent.view.as_deref(), init.parent.parent.detail, Key::Unidentified, init.code.clone(), diff --git a/components/script/dom/mouseevent.rs b/components/script/dom/mouseevent.rs index 6656eac90fe..9b184a96da6 100644 --- a/components/script/dom/mouseevent.rs +++ b/components/script/dom/mouseevent.rs @@ -119,7 +119,7 @@ impl MouseEvent { type_, bubbles, cancelable, - init.parent.parent.view.deref(), + init.parent.parent.view.as_deref(), init.parent.parent.detail, init.screenX, init.screenY, @@ -131,7 +131,7 @@ impl MouseEvent { init.parent.metaKey, init.button, 0, - init.relatedTarget.deref(), + init.relatedTarget.as_deref(), None, ); Ok(event) diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index b11b9e0786c..26bb6d53752 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -244,11 +244,11 @@ impl Node { assert!(new_child.next_sibling.get().is_none()); match before { Some(ref before) => { - assert!(before.parent_node.get().deref() == Some(self)); + assert!(before.parent_node.get().as_deref() == Some(self)); let prev_sibling = before.GetPreviousSibling(); match prev_sibling { None => { - assert!(self.first_child.get().deref() == Some(*before)); + assert!(self.first_child.get().as_deref() == Some(*before)); self.first_child.set(Some(new_child)); }, Some(ref prev_sibling) => { @@ -334,34 +334,34 @@ impl Node { /// /// Fails unless `child` is a child of this node. fn remove_child(&self, child: &Node, cached_index: Option<u32>) { - assert!(child.parent_node.get().deref() == Some(self)); + assert!(child.parent_node.get().as_deref() == Some(self)); let prev_sibling = child.GetPreviousSibling(); match prev_sibling { None => { - self.first_child.set(child.next_sibling.get().deref()); + self.first_child.set(child.next_sibling.get().as_deref()); }, Some(ref prev_sibling) => { prev_sibling .next_sibling - .set(child.next_sibling.get().deref()); + .set(child.next_sibling.get().as_deref()); }, } let next_sibling = child.GetNextSibling(); match next_sibling { None => { - self.last_child.set(child.prev_sibling.get().deref()); + self.last_child.set(child.prev_sibling.get().as_deref()); }, Some(ref next_sibling) => { next_sibling .prev_sibling - .set(child.prev_sibling.get().deref()); + .set(child.prev_sibling.get().as_deref()); }, } let context = UnbindContext::new( self, - prev_sibling.deref(), - next_sibling.deref(), + prev_sibling.as_deref(), + next_sibling.as_deref(), cached_index, ); @@ -759,7 +759,7 @@ impl Node { document != window.Document(), is_body_element, document.quirks_mode(), - html_element.deref() == self.downcast::<Element>(), + html_element.as_deref() == self.downcast::<Element>(), ) { // Step 2 && Step 5 (true, _, _, _) | (_, false, QuirksMode::Quirks, true) => Rect::zero(), @@ -806,7 +806,7 @@ impl Node { }; // Step 6. - Node::pre_insert(&node, &parent, viable_previous_sibling.deref())?; + Node::pre_insert(&node, &parent, viable_previous_sibling.as_deref())?; Ok(()) } @@ -829,7 +829,7 @@ impl Node { let node = self.owner_doc().node_from_nodes_and_strings(nodes)?; // Step 5. - Node::pre_insert(&node, &parent, viable_next_sibling.deref())?; + Node::pre_insert(&node, &parent, viable_next_sibling.as_deref())?; Ok(()) } @@ -852,7 +852,7 @@ impl Node { parent.ReplaceChild(&node, self)?; } else { // Step 6. - Node::pre_insert(&node, &parent, viable_next_sibling.deref())?; + Node::pre_insert(&node, &parent, viable_next_sibling.as_deref())?; } Ok(()) } @@ -864,7 +864,7 @@ impl Node { let node = doc.node_from_nodes_and_strings(nodes)?; // Step 2. let first_child = self.first_child.get(); - Node::pre_insert(&node, self, first_child.deref()).map(|_| ()) + Node::pre_insert(&node, self, first_child.as_deref()).map(|_| ()) } // https://dom.spec.whatwg.org/#dom-parentnode-append @@ -1072,7 +1072,7 @@ impl Node { None => return Err(Error::IndexSize), Some(node) => node, }; - self.InsertBefore(tr_node, node.deref())?; + self.InsertBefore(tr_node, node.as_deref())?; } } @@ -1839,7 +1839,7 @@ impl Node { let reference_child = match child { Some(child) if child == node => { reference_child_root = node.GetNextSibling(); - reference_child_root.deref() + reference_child_root.as_deref() }, _ => child, }; @@ -1869,7 +1869,8 @@ impl Node { ) { node.owner_doc().add_script_and_layout_blocker(); debug_assert!(&*node.owner_doc() == &*parent.owner_doc()); - debug_assert!(child.map_or(true, |child| Some(parent) == child.GetParentNode().deref())); + debug_assert!(child.map_or(true, |child| Some(parent) == + child.GetParentNode().as_deref())); // Step 1. let count = if node.is::<DocumentFragment>() { @@ -1944,7 +1945,7 @@ impl Node { } if let SuppressObserver::Unsuppressed = suppress_observers { vtable_for(&parent).children_changed(&ChildrenMutation::insert( - previous_sibling.deref(), + previous_sibling.as_deref(), new_nodes, child, )); @@ -1952,7 +1953,7 @@ impl Node { let mutation = Mutation::ChildList { added: Some(new_nodes), removed: None, - prev: previous_sibling.deref(), + prev: previous_sibling.as_deref(), next: child, }; MutationObserver::queue_a_mutation_record(&parent, mutation); @@ -2055,18 +2056,18 @@ impl Node { // Step 12. if let SuppressObserver::Unsuppressed = suppress_observers { vtable_for(&parent).children_changed(&ChildrenMutation::replace( - old_previous_sibling.deref(), + old_previous_sibling.as_deref(), &Some(&node), &[], - old_next_sibling.deref(), + old_next_sibling.as_deref(), )); let removed = [node]; let mutation = Mutation::ChildList { added: None, removed: Some(&removed), - prev: old_previous_sibling.deref(), - next: old_next_sibling.deref(), + prev: old_previous_sibling.as_deref(), + next: old_next_sibling.as_deref(), }; MutationObserver::queue_a_mutation_record(&parent, mutation); } @@ -2402,7 +2403,7 @@ impl NodeMethods for Node { }; // Step 3. - Node::replace_all(node.deref(), self); + Node::replace_all(node.as_deref(), self); }, NodeTypeId::CharacterData(..) => { let characterdata = self.downcast::<CharacterData>().unwrap(); @@ -2508,10 +2509,10 @@ impl NodeMethods for Node { // Step 7-8. let child_next_sibling = child.GetNextSibling(); let node_next_sibling = node.GetNextSibling(); - let reference_child = if child_next_sibling.deref() == Some(node) { - node_next_sibling.deref() + let reference_child = if child_next_sibling.as_deref() == Some(node) { + node_next_sibling.as_deref() } else { - child_next_sibling.deref() + child_next_sibling.as_deref() }; // Step 9. @@ -2546,7 +2547,7 @@ impl NodeMethods for Node { // Step 14. vtable_for(&self).children_changed(&ChildrenMutation::replace( - previous_sibling.deref(), + previous_sibling.as_deref(), &removed_child, nodes, reference_child, @@ -2555,7 +2556,7 @@ impl NodeMethods for Node { let mutation = Mutation::ChildList { added: Some(nodes), removed: removed.as_ref().map(|r| &r[..]), - prev: previous_sibling.deref(), + prev: previous_sibling.as_deref(), next: reference_child, }; MutationObserver::queue_a_mutation_record(&self, mutation); diff --git a/components/script/dom/nodelist.rs b/components/script/dom/nodelist.rs index 248984746db..82fd3be59d6 100644 --- a/components/script/dom/nodelist.rs +++ b/components/script/dom/nodelist.rs @@ -132,7 +132,7 @@ impl ChildrenList { let last_visited = node.GetFirstChild(); ChildrenList { node: Dom::from_ref(node), - last_visited: MutNullableDom::new(last_visited.deref()), + last_visited: MutNullableDom::new(last_visited.as_deref()), last_index: Cell::new(0u32), } } @@ -315,7 +315,7 @@ impl ChildrenList { } fn reset(&self) { - self.last_visited.set(self.node.GetFirstChild().deref()); + self.last_visited.set(self.node.GetFirstChild().as_deref()); self.last_index.set(0u32); } } diff --git a/components/script/dom/range.rs b/components/script/dom/range.rs index de17427664e..64a26fa0ba9 100644 --- a/components/script/dom/range.rs +++ b/components/script/dom/range.rs @@ -756,7 +756,7 @@ impl RangeMethods for Range { }; // Step 6. - Node::ensure_pre_insertion_validity(node, &parent, reference_node.deref())?; + Node::ensure_pre_insertion_validity(node, &parent, reference_node.as_deref())?; // Step 7. let split_text; @@ -764,14 +764,14 @@ impl RangeMethods for Range { Some(text) => { split_text = text.SplitText(start_offset)?; let new_reference = DomRoot::upcast::<Node>(split_text); - assert!(new_reference.GetParentNode().deref() == Some(&parent)); + assert!(new_reference.GetParentNode().as_deref() == Some(&parent)); Some(new_reference) }, _ => reference_node, }; // Step 8. - let reference_node = if Some(node) == reference_node.deref() { + let reference_node = if Some(node) == reference_node.as_deref() { node.GetNextSibling() } else { reference_node @@ -794,7 +794,7 @@ impl RangeMethods for Range { }; // Step 12. - Node::pre_insert(node, &parent, reference_node.deref())?; + Node::pre_insert(node, &parent, reference_node.as_deref())?; // Step 13. if self.Collapsed() { @@ -989,7 +989,7 @@ impl RangeMethods for Range { }; // Step 2. - let element = Element::fragment_parsing_context(&owner_doc, element.deref()); + let element = Element::fragment_parsing_context(&owner_doc, element.as_deref()); // Step 3. let fragment_node = element.parse_fragment(fragment)?; diff --git a/components/script/dom/servoparser/mod.rs b/components/script/dom/servoparser/mod.rs index 9f6a2214ed0..db6058c36b7 100644 --- a/components/script/dom/servoparser/mod.rs +++ b/components/script/dom/servoparser/mod.rs @@ -199,7 +199,7 @@ impl ServoParser { let fragment_context = FragmentContext { context_elem: context_node, - form_elem: form.deref(), + form_elem: form.as_deref(), }; let parser = ServoParser::new( diff --git a/components/script/dom/storageevent.rs b/components/script/dom/storageevent.rs index 01990917cd1..19e5a96da9c 100644 --- a/components/script/dom/storageevent.rs +++ b/components/script/dom/storageevent.rs @@ -91,7 +91,7 @@ impl StorageEvent { let oldValue = init.oldValue.clone(); let newValue = init.newValue.clone(); let url = init.url.clone(); - let storageArea = init.storageArea.deref(); + let storageArea = init.storageArea.as_deref(); let bubbles = EventBubbles::from(init.parent.bubbles); let cancelable = EventCancelable::from(init.parent.cancelable); let event = StorageEvent::new( diff --git a/components/script/dom/text.rs b/components/script/dom/text.rs index a3b66583d83..541bfd1ebd5 100644 --- a/components/script/dom/text.rs +++ b/components/script/dom/text.rs @@ -68,7 +68,7 @@ impl TextMethods for Text { if let Some(ref parent) = parent { // Step 7.1. parent - .InsertBefore(new_node.upcast(), node.GetNextSibling().deref()) + .InsertBefore(new_node.upcast(), node.GetNextSibling().as_deref()) .unwrap(); // Steps 7.2-3. node.ranges() diff --git a/components/script/dom/uievent.rs b/components/script/dom/uievent.rs index b791a2f8b8a..b9ab31958c9 100644 --- a/components/script/dom/uievent.rs +++ b/components/script/dom/uievent.rs @@ -73,7 +73,7 @@ impl UIEvent { type_, bubbles, cancelable, - init.view.deref(), + init.view.as_deref(), init.detail, ); Ok(event) diff --git a/components/script/dom/vrdisplay.rs b/components/script/dom/vrdisplay.rs index 81a263d3394..c3652fea392 100644 --- a/components/script/dom/vrdisplay.rs +++ b/components/script/dom/vrdisplay.rs @@ -43,7 +43,6 @@ use ipc_channel::ipc::IpcSender; use profile_traits::ipc; use std::cell::Cell; use std::mem; -use std::ops::Deref; use std::rc::Rc; use std::thread; use webvr_traits::{WebVRDisplayData, WebVRDisplayEvent, WebVRFrameData, WebVRPoseInformation}; @@ -136,7 +135,7 @@ impl VRDisplay { display.capabilities.clone(), &global, )), - stage_params: MutNullableDom::new(stage.as_ref().map(|v| v.deref())), + stage_params: MutNullableDom::new(stage.as_deref()), frame_data: DomRefCell::new(Default::default()), layer: DomRefCell::new(Default::default()), layer_ctx: MutNullableDom::default(), @@ -279,7 +278,7 @@ impl VRDisplayMethods for VRDisplay { // https://w3c.github.io/webvr/#dom-vrdisplay-depthnear fn SetDepthNear(&self, value: Finite<f64>) { - self.depth_near.set(*value.deref()); + self.depth_near.set(*value); } // https://w3c.github.io/webvr/#dom-vrdisplay-depthfar @@ -289,7 +288,7 @@ impl VRDisplayMethods for VRDisplay { // https://w3c.github.io/webvr/#dom-vrdisplay-depthfar fn SetDepthFar(&self, value: Finite<f64>) { - self.depth_far.set(*value.deref()); + self.depth_far.set(*value); } // https://w3c.github.io/webvr/#dom-vrdisplay-requestanimationframe @@ -465,7 +464,7 @@ impl VRDisplay { if let Some(ref stage) = display.stage_parameters { if self.stage_params.get().is_none() { let params = Some(VRStageParameters::new(stage.clone(), &self.global())); - self.stage_params.set(params.as_ref().map(|v| v.deref())); + self.stage_params.set(params.as_deref()); } else { self.stage_params.get().unwrap().update(&stage); } @@ -510,7 +509,7 @@ impl VRDisplay { match recv { Ok(()) => { *this.layer.borrow_mut() = layer_bounds; - this.layer_ctx.set(ctx.as_ref().map(|c| &**c)); + this.layer_ctx.set(ctx.as_deref()); this.init_present(); promise.map(resolve); }, @@ -808,7 +807,7 @@ fn parse_bounds(src: &Option<Vec<Finite<f32>>>, dst: &mut [f32; 4]) -> Result<() ); } for i in 0..4 { - dst[i] = *values[i].deref(); + dst[i] = *values[i]; } Ok(()) }, diff --git a/components/script/dom/wheelevent.rs b/components/script/dom/wheelevent.rs index 0fd23db8da8..4c3d6d94efa 100644 --- a/components/script/dom/wheelevent.rs +++ b/components/script/dom/wheelevent.rs @@ -83,7 +83,7 @@ impl WheelEvent { type_, EventBubbles::from(init.parent.parent.parent.parent.bubbles), EventCancelable::from(init.parent.parent.parent.parent.cancelable), - init.parent.parent.parent.view.deref(), + init.parent.parent.parent.view.as_deref(), init.parent.parent.parent.detail, init.deltaX, init.deltaY, @@ -148,7 +148,7 @@ impl WheelEventMethods for WheelEvent { self.mouseevent.ShiftKey(), self.mouseevent.MetaKey(), self.mouseevent.Button(), - self.mouseevent.GetRelatedTarget().deref(), + self.mouseevent.GetRelatedTarget().as_deref(), ); self.delta_x.set(delta_x_arg); self.delta_y.set(delta_y_arg); diff --git a/components/script/dom/windowproxy.rs b/components/script/dom/windowproxy.rs index 0c7a00978bc..dbdd09eabb9 100644 --- a/components/script/dom/windowproxy.rs +++ b/components/script/dom/windowproxy.rs @@ -525,7 +525,7 @@ impl WindowProxy { } pub fn frame_element(&self) -> Option<&Element> { - self.frame_element.deref() + self.frame_element.as_deref() } pub fn document(&self) -> Option<DomRoot<Document>> { @@ -535,7 +535,7 @@ impl WindowProxy { } pub fn parent(&self) -> Option<&WindowProxy> { - self.parent.deref() + self.parent.as_deref() } pub fn top(&self) -> &WindowProxy { diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index f6bcff56177..da5d8f2e7aa 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -2997,7 +2997,7 @@ impl ScriptThread { global_to_clone, browsing_context_id, top_level_browsing_context_id, - parent.deref(), + parent.as_deref(), opener, ); self.window_proxies @@ -3043,8 +3043,8 @@ impl ScriptThread { &window, browsing_context_id, top_level_browsing_context_id, - iframe.deref().map(Castable::upcast), - parent.deref(), + iframe.as_deref().map(Castable::upcast), + parent.as_deref(), opener, ); self.window_proxies diff --git a/components/script/task.rs b/components/script/task.rs index 61f9bf436dd..3508a790780 100644 --- a/components/script/task.rs +++ b/components/script/task.rs @@ -32,7 +32,7 @@ macro_rules! task { pub trait TaskOnce: Send { #[allow(unsafe_code)] fn name(&self) -> &'static str { - unsafe { ::std::intrinsics::type_name::<Self>() } + ::std::any::type_name::<Self>() } fn run_once(self); diff --git a/components/script/textinput.rs b/components/script/textinput.rs index c2a5575e9ec..0401134bd66 100644 --- a/components/script/textinput.rs +++ b/components/script/textinput.rs @@ -996,7 +996,8 @@ impl<T: ClipboardProvider> TextInput<T> { self.lines .iter() .fold(UTF16CodeUnits::zero(), |m, l| { - m + UTF16CodeUnits(l.chars().map(char::len_utf16).sum::<usize>() + 1) // + 1 for the '\n' + m + UTF16CodeUnits(l.chars().map(char::len_utf16).sum::<usize>() + 1) + // + 1 for the '\n' }) .saturating_sub(UTF16CodeUnits::one()) } diff --git a/components/style/rule_tree/mod.rs b/components/style/rule_tree/mod.rs index c52b7874a70..02ebeed0452 100644 --- a/components/style/rule_tree/mod.rs +++ b/components/style/rule_tree/mod.rs @@ -971,7 +971,6 @@ mod gecko_leak_checking { NS_LogDtor(ptr as *mut c_void, s, size_of::<RuleNode>() as u32); } } - } #[inline(always)] |