From 32c624e5852a91fbcd2fcc495cacd00a63452c6a Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Wed, 26 Apr 2017 14:01:36 -0700 Subject: [PATCH] Require Clone for SelectorImpl so that all the types that are parameterized on it can derive(Clone). It's not clear to me why this is a requirement, but it seems to be one. MozReview-Commit-ID: JM0DKjHHfT --- components/selectors/parser.rs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/components/selectors/parser.rs b/components/selectors/parser.rs index 65bd0944b1a..3d05f7ec734 100644 --- a/components/selectors/parser.rs +++ b/components/selectors/parser.rs @@ -42,7 +42,11 @@ macro_rules! with_all_bounds { /// This trait allows to define the parser implementation in regards /// of pseudo-classes/elements - pub trait SelectorImpl: Sized { + /// + /// NB: We need Clone so that we can derive(Clone) on struct with that + /// are parameterized on SelectorImpl. See + /// https://github.com/rust-lang/rust/issues/26925 + pub trait SelectorImpl: Clone + Sized { type AttrValue: $($InSelector)*; type Identifier: $($InSelector)* + PrecomputedHash; type ClassName: $($InSelector)* + PrecomputedHash; @@ -321,22 +325,12 @@ impl ComplexSelector { } } +#[derive(Clone)] pub struct SelectorIter<'a, Impl: 'a + SelectorImpl> { iter: Rev>>, next_combinator: Option, } -// NB: Deriving this doesn't work for some reason, because it expects Impl to -// implement Clone. -impl<'a, Impl: 'a + SelectorImpl> Clone for SelectorIter<'a, Impl> { - fn clone(&self) -> Self { - SelectorIter { - iter: self.iter.clone(), - next_combinator: self.next_combinator.clone(), - } - } -} - impl<'a, Impl: 'a + SelectorImpl> SelectorIter<'a, Impl> { /// Prepares this iterator to point to the next sequence to the left, /// returning the combinator if the sequence was found.