diff --git a/src/generate/rust.rs b/src/generate/rust.rs index 3a7214e..66b9f01 100644 --- a/src/generate/rust.rs +++ b/src/generate/rust.rs @@ -401,7 +401,7 @@ enum Code { Label(Rc), } -impl<'a> Continuation<'a> { +impl Continuation<'_> { fn next_code_label(&mut self) -> Rc { let counter = self .code_labels @@ -860,12 +860,10 @@ where let parse_node_kind = ParseNodeKind::NamedRule(name.to_string()); let rust_slice_ty = Pat::rust_slice_ty(); quote!( - impl<'_a, I> #ident<'_a, 'static, I> + impl #ident<'_, '_, I> where I: ::gll::runtime::Input, { - pub fn parse(input: I) - -> ::gll::runtime::ParseResult>> - { + pub fn parse(input: I) -> ::gll::runtime::ParseResult> { let handle = |forest_and_node| OwnedHandle { forest_and_node, _marker: PhantomData, @@ -878,7 +876,7 @@ where } } - impl<'_a, I: ::gll::runtime::Input> OwnedHandle> { + impl OwnedHandle> { pub fn with(&self, f: impl for<'a, 'i> FnOnce(Handle<'a, 'i, I, #ident<'a, 'i, I>>) -> R) -> R { self.forest_and_node.unpack_ref(|_, forest_and_node| { let (ref forest, node) = *forest_and_node; @@ -1238,7 +1236,7 @@ fn rule_debug_impl( d.finish() ) }; - quote!(impl<'a, 'i, I: ::gll::runtime::Input> fmt::Debug for #ident<'a, 'i, I> { + quote!(impl fmt::Debug for #ident<'_, '_, I> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { #body } @@ -1271,7 +1269,7 @@ fn rule_handle_debug_impl(name: &str, has_fields: bool) -> Src { } } - impl<'_a, I: ::gll::runtime::Input> fmt::Debug for OwnedHandle> { + impl fmt::Debug for OwnedHandle> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.with(|handle| handle.fmt(f)) } @@ -1388,7 +1386,7 @@ fn impl_debug_for_handle_any(all_parse_nodes: &[ParseNode]) -> Src { }),) }) }); - quote!(impl<'a, 'i, I: ::gll::runtime::Input> fmt::Debug for Handle<'a, 'i, I, Any> { + quote!(impl fmt::Debug for Handle<'_, '_, I, Any> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.node.kind { #(#arms)* diff --git a/src/generate/templates/header.rs b/src/generate/templates/header.rs index 26ed0b6..6166da3 100644 --- a/src/generate/templates/header.rs +++ b/src/generate/templates/header.rs @@ -23,15 +23,15 @@ pub struct Handle<'a, 'i: 'a, I: 'a + ::gll::runtime::Input, T: ?Sized> { _marker: PhantomData, } -impl<'a, 'i, I: ::gll::runtime::Input, T: ?Sized> Copy for Handle<'a, 'i, I, T> {} +impl Copy for Handle<'_, '_, I, T> {} -impl<'a, 'i, I: ::gll::runtime::Input, T: ?Sized> Clone for Handle<'a, 'i, I, T> { +impl Clone for Handle<'_, '_, I, T> { fn clone(&self) -> Self { *self } } -impl<'a, 'i, I: ::gll::runtime::Input, T: ?Sized> Handle<'a, 'i, I, T> { +impl<'a, I: ::gll::runtime::Input, T: ?Sized> Handle<'a, '_, I, T> { pub fn source(self) -> &'a I::Slice { self.forest.input(self.node.range) } @@ -64,7 +64,7 @@ impl<'a, 'i, I: ::gll::runtime::Input, T> From> } } -impl<'a, 'i, I: ::gll::runtime::Input> fmt::Debug for Handle<'a, 'i, I, ()> { +impl fmt::Debug for Handle<'_, '_, I, ()> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{:?}", self.source_info()) } @@ -151,9 +151,7 @@ pub enum ListHead { } impl<'a, 'i, I: ::gll::runtime::Input, T> Handle<'a, 'i, I, [T]> { - fn one_list_head( - self, - ) -> ListHead, Handle<'a, 'i, I, [T]>), Ambiguity>> { + fn one_list_head(self) -> ListHead, Self), Ambiguity>> { match self.all_list_heads() { ListHead::Cons(mut iter) => { let first = iter.next().unwrap(); diff --git a/src/high.rs b/src/high.rs index 2856fd4..d04fc99 100644 --- a/src/high.rs +++ b/src/high.rs @@ -44,8 +44,8 @@ type_lambda! { // FIXME(#52812) replace with `&'a >::Out` pub struct RefApplyL<'a, 'b, T: LambdaL>(&'a >::Out); -impl<'a, 'b, T: LambdaL> Deref for RefApplyL<'a, 'b, T> { - type Target = >::Out; +impl<'a, T: LambdaL> Deref for RefApplyL<'_, 'a, T> { + type Target = >::Out; fn deref(&self) -> &Self::Target { self.0 } @@ -55,14 +55,14 @@ impl<'a, 'b, T: LambdaL> Deref for RefApplyL<'a, 'b, T> { // FIXME(#52812) replace with `&'a mut >::Out` pub struct RefMutApplyL<'a, 'b, T: LambdaL>(&'a mut >::Out); -impl<'a, 'b, T: LambdaL> Deref for RefMutApplyL<'a, 'b, T> { - type Target = >::Out; +impl<'a, T: LambdaL> Deref for RefMutApplyL<'_, 'a, T> { + type Target = >::Out; fn deref(&self) -> &Self::Target { self.0 } } -impl<'a, 'b, T: LambdaL> DerefMut for RefMutApplyL<'a, 'b, T> { +impl DerefMut for RefMutApplyL<'_, '_, T> { fn deref_mut(&mut self) -> &mut Self::Target { self.0 } @@ -76,7 +76,7 @@ pub struct ErasableL<'a> { _marker: ::std::marker::PhantomData<&'a mut &'a ()>, } -impl<'a> ErasableL<'a> { +impl ErasableL<'_> { /// Trivial proof that `'static` is erasable (it's always valid). pub const STATIC: ErasableL<'static> = ErasableL { _marker: ::std::marker::PhantomData, diff --git a/src/parse_grammar.rs b/src/parse_grammar.rs index 5a96e93..01ddfa5 100644 --- a/src/parse_grammar.rs +++ b/src/parse_grammar.rs @@ -23,7 +23,7 @@ impl> FromStr for ::grammar::Grammar { } } -impl<'a, 'i, 's> Or<'a, 'i, &'s str> { +impl Or<'_, '_, &str> { fn lower>(self) -> ::grammar::RuleWithNamedFields { let mut rules = self.rules.map(|rule| rule.unwrap().one().unwrap().lower()); let first = rules.next().unwrap(); @@ -31,7 +31,7 @@ impl<'a, 'i, 's> Or<'a, 'i, &'s str> { } } -impl<'a, 'i, 's> Concat<'a, 'i, &'s str> { +impl Concat<'_, '_, &str> { fn lower>(self) -> ::grammar::RuleWithNamedFields { self.rules .map(|rule| rule.unwrap().one().unwrap().lower()) @@ -39,7 +39,7 @@ impl<'a, 'i, 's> Concat<'a, 'i, &'s str> { } } -impl<'a, 'i, 's> Rule<'a, 'i, &'s str> { +impl Rule<'_, '_, &str> { fn lower>(self) -> ::grammar::RuleWithNamedFields { let mut rule = self.rule.one().unwrap().lower(); if let Some(modifier) = self.modifier { @@ -52,7 +52,7 @@ impl<'a, 'i, 's> Rule<'a, 'i, &'s str> { } } -impl<'a, 'i, 's> Primary<'a, 'i, &'s str> { +impl Primary<'_, '_, &str> { fn lower>(self) -> ::grammar::RuleWithNamedFields { match self { Primary::Eat(pat) => ::grammar::eat(pat.one().unwrap().lower()), @@ -67,7 +67,7 @@ impl<'a, 'i, 's> Primary<'a, 'i, &'s str> { } } -impl<'a, 'i, 's> Modifier<'a, 'i, &'s str> { +impl Modifier<'_, '_, &str> { fn lower>( self, rule: ::grammar::RuleWithNamedFields, @@ -85,7 +85,7 @@ impl<'a, 'i, 's> Modifier<'a, 'i, &'s str> { } } -impl<'a, 'i, 's> Pattern<'a, 'i, &'s str> { +impl Pattern<'_, '_, &str> { fn lower(self) -> SPat { fn unescape(handle: Handle<&str, T>) -> String { let mut out = String::new(); diff --git a/src/proc_macro.rs b/src/proc_macro.rs index 31e7dba..6a0e042 100644 --- a/src/proc_macro.rs +++ b/src/proc_macro.rs @@ -246,7 +246,7 @@ impl Input for TokenStream { } } -impl<'a> InputMatch<&'a [FlatTokenPat<&'a str>]> for [FlatToken] { +impl InputMatch<&[FlatTokenPat<&str>]> for [FlatToken] { fn match_left(&self, pat: &[FlatTokenPat<&str>]) -> Option { if self .iter() diff --git a/src/runtime.rs b/src/runtime.rs index 05ab881..365e29e 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -21,25 +21,25 @@ impl<'i> Deref for Range<'i> { } } -impl<'i> PartialOrd for Range<'i> { +impl PartialOrd for Range<'_> { fn partial_cmp(&self, other: &Self) -> Option { (self.start(), self.end()).partial_cmp(&(other.start(), other.end())) } } -impl<'i> Ord for Range<'i> { +impl Ord for Range<'_> { fn cmp(&self, other: &Self) -> Ordering { (self.start(), self.end()).cmp(&(other.start(), other.end())) } } -impl<'i> Hash for Range<'i> { +impl Hash for Range<'_> { fn hash(&self, state: &mut H) { (self.start(), self.end()).hash(state); } } -impl<'i> Range<'i> { +impl Range<'_> { pub fn subtract_suffix(self, other: Self) -> Self { assert_eq!(self.end(), other.end()); Range(self.split_at(other.start() - self.start()).0) @@ -96,7 +96,7 @@ pub trait Input: Sized { ) -> Self::SourceInfo; } -impl<'a, T> Input for &'a [T] { +impl Input for &[T] { type Container = Self; type Slice = [T]; type SourceInfo = ops::Range; @@ -149,7 +149,7 @@ pub trait InputMatch { fn match_right(&self, pat: Pat) -> Option; } -impl<'a, T: PartialEq> InputMatch<&'a [T]> for [T] { +impl InputMatch<&[T]> for [T] { fn match_left(&self, pat: &[T]) -> Option { if self.starts_with(pat) { Some(pat.len()) @@ -185,7 +185,7 @@ impl InputMatch> for [T] { } } -impl<'a> InputMatch<&'a str> for str { +impl InputMatch<&str> for str { fn match_left(&self, pat: &str) -> Option { if self.starts_with(pat) { Some(pat.len()) @@ -435,7 +435,7 @@ pub struct Call<'i, C> { pub range: Range<'i>, } -impl<'i, C: fmt::Display> fmt::Display for Call<'i, C> { +impl fmt::Display for Call<'_, C> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, @@ -447,13 +447,13 @@ impl<'i, C: fmt::Display> fmt::Display for Call<'i, C> { } } -impl<'i, C: PartialOrd> PartialOrd for Call<'i, C> { +impl PartialOrd for Call<'_, C> { fn partial_cmp(&self, other: &Self) -> Option { (Reverse(self.range), &self.callee).partial_cmp(&(Reverse(other.range), &other.callee)) } } -impl<'i, C: Ord> Ord for Call<'i, C> { +impl Ord for Call<'_, C> { fn cmp(&self, other: &Self) -> Ordering { (Reverse(self.range), &self.callee).cmp(&(Reverse(other.range), &other.callee)) } @@ -463,7 +463,7 @@ pub struct GraphStack<'i, C: CodeLabel> { returns: HashMap, BTreeSet>>, } -impl<'i, C: CodeLabel> GraphStack<'i, C> { +impl GraphStack<'_, C> { // FIXME(eddyb) figure out what to do here, now that // the GSS is no longer exposed in the public API. #[allow(unused)] @@ -680,7 +680,7 @@ pub struct ParseNode<'i, P: ParseNodeKind> { pub range: Range<'i>, } -impl<'i, P: ParseNodeKind> ParseNode<'i, P> { +impl ParseNode<'_, P> { pub fn unpack_alias(self) -> Self { match self.kind.shape() { ParseNodeShape::Alias(inner) => ParseNode { @@ -708,7 +708,7 @@ impl<'i, P: ParseNodeKind> ParseNode<'i, P> { } } -impl<'i, P: ParseNodeKind> fmt::Display for ParseNode<'i, P> { +impl fmt::Display for ParseNode<'_, P> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, @@ -720,7 +720,7 @@ impl<'i, P: ParseNodeKind> fmt::Display for ParseNode<'i, P> { } } -impl<'i, P: ParseNodeKind> fmt::Debug for ParseNode<'i, P> { +impl fmt::Debug for ParseNode<'_, P> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, diff --git a/src/scannerless.rs b/src/scannerless.rs index 4948fb4..4984764 100644 --- a/src/scannerless.rs +++ b/src/scannerless.rs @@ -16,7 +16,7 @@ impl<'a, C> From<&'a str> for Pat<&'a str, C> { } } -impl<'a, C> From<&'a str> for Pat { +impl From<&str> for Pat { fn from(s: &str) -> Self { Pat::String(s.to_string()) }