From a7ad92d9a3411e97244b3e1bbd4d939a3af83a32 Mon Sep 17 00:00:00 2001 From: eri Date: Sat, 30 Mar 2024 12:30:14 +0100 Subject: [PATCH] clippy: Fix `from_over_into` warnings (#31946) --- components/script/dom/bindings/interface.rs | 6 +++--- components/script/dom/bindings/str.rs | 24 ++++++++++----------- components/script/dom/node.rs | 12 +++++------ components/script/dom/xrsystem.rs | 6 +++--- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/components/script/dom/bindings/interface.rs b/components/script/dom/bindings/interface.rs index 34f6a694dc4..e1811ae793f 100644 --- a/components/script/dom/bindings/interface.rs +++ b/components/script/dom/bindings/interface.rs @@ -543,9 +543,9 @@ pub enum ProtoOrIfaceIndex { Constructor(PrototypeList::Constructor), } -impl Into for ProtoOrIfaceIndex { - fn into(self) -> usize { - match self { +impl From for usize { + fn from(index: ProtoOrIfaceIndex) -> usize { + match index { ProtoOrIfaceIndex::ID(id) => id as usize, ProtoOrIfaceIndex::Constructor(constructor) => constructor as usize, } diff --git a/components/script/dom/bindings/str.rs b/components/script/dom/bindings/str.rs index 70a2cc2f7fb..0d8770c0699 100644 --- a/components/script/dom/bindings/str.rs +++ b/components/script/dom/bindings/str.rs @@ -51,9 +51,9 @@ impl ByteString { } } -impl Into> for ByteString { - fn into(self) -> Vec { - self.0 +impl From for Vec { + fn from(byte_string: ByteString) -> Vec { + byte_string.0 } } @@ -640,21 +640,21 @@ impl From for String { } } -impl Into> for DOMString { - fn into(self) -> Vec { - self.0.into() +impl From for Vec { + fn from(contents: DOMString) -> Vec { + contents.0.into() } } -impl<'a> Into> for DOMString { - fn into(self) -> Cow<'a, str> { - self.0.into() +impl<'a> From for Cow<'a, str> { + fn from(contents: DOMString) -> Cow<'a, str> { + contents.0.into() } } -impl<'a> Into> for DOMString { - fn into(self) -> CowRcStr<'a> { - self.0.into() +impl<'a> From for CowRcStr<'a> { + fn from(contents: DOMString) -> CowRcStr<'a> { + contents.0.into() } } diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index aea3bc96366..aedd70442a9 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -3454,10 +3454,10 @@ impl UniqueId { } } -impl Into for NodeTypeId { +impl From for LayoutNodeType { #[inline(always)] - fn into(self) -> LayoutNodeType { - match self { + fn from(node_type: NodeTypeId) -> LayoutNodeType { + match node_type { NodeTypeId::Element(e) => LayoutNodeType::Element(e.into()), NodeTypeId::CharacterData(CharacterDataTypeId::Text(_)) => LayoutNodeType::Text, x => unreachable!("Layout should not traverse nodes of type {:?}", x), @@ -3465,10 +3465,10 @@ impl Into for NodeTypeId { } } -impl Into for ElementTypeId { +impl From for LayoutElementType { #[inline(always)] - fn into(self) -> LayoutElementType { - match self { + fn from(element_type: ElementTypeId) -> LayoutElementType { + match element_type { ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLBodyElement) => { LayoutElementType::HTMLBodyElement }, diff --git a/components/script/dom/xrsystem.rs b/components/script/dom/xrsystem.rs index 0f49ea47fb5..e7118d3544a 100644 --- a/components/script/dom/xrsystem.rs +++ b/components/script/dom/xrsystem.rs @@ -99,9 +99,9 @@ impl XRSystem { } } -impl Into for XRSessionMode { - fn into(self) -> SessionMode { - match self { +impl From for SessionMode { + fn from(mode: XRSessionMode) -> SessionMode { + match mode { XRSessionMode::Immersive_vr => SessionMode::ImmersiveVR, XRSessionMode::Immersive_ar => SessionMode::ImmersiveAR, XRSessionMode::Inline => SessionMode::Inline,