From 883fd31d38ec0ca9e31a697c93b7daaef003dd21 Mon Sep 17 00:00:00 2001 From: John Date: Thu, 16 Jan 2025 20:57:33 -0600 Subject: [PATCH] conlang: Elide lifetimes (fixes clippy lint) --- compiler/cl-ast/src/format.rs | 6 +++--- compiler/cl-interpret/src/env.rs | 6 +++--- compiler/cl-lexer/src/lib.rs | 12 ++++++------ compiler/cl-repl/examples/yaml.rs | 6 +++--- compiler/cl-structures/src/intern.rs | 20 ++++++++++---------- compiler/cl-typeck/src/source.rs | 2 +- compiler/cl-typeck/src/table.rs | 2 +- 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/compiler/cl-ast/src/format.rs b/compiler/cl-ast/src/format.rs index 13f8fa4..9db5e9e 100644 --- a/compiler/cl-ast/src/format.rs +++ b/compiler/cl-ast/src/format.rs @@ -21,7 +21,7 @@ pub struct Indent<'f, F: Write + ?Sized> { f: &'f mut F, } -impl<'f, F: Write + ?Sized> Write for Indent<'f, F> { +impl Write for Indent<'_, F> { fn write_str(&mut self, s: &str) -> std::fmt::Result { for s in s.split_inclusive('\n') { self.f.write_str(s)?; @@ -45,14 +45,14 @@ impl<'f, F: Write + ?Sized> Delimit<'f, F> { Self { f, delim } } } -impl<'f, F: Write + ?Sized> Drop for Delimit<'f, F> { +impl Drop for Delimit<'_, F> { fn drop(&mut self) { let Self { f: Indent { f, .. }, delim } = self; let _ = f.write_str(delim.close); } } -impl<'f, F: Write + ?Sized> Write for Delimit<'f, F> { +impl Write for Delimit<'_, F> { fn write_str(&mut self, s: &str) -> std::fmt::Result { self.f.write_str(s) } diff --git a/compiler/cl-interpret/src/env.rs b/compiler/cl-interpret/src/env.rs index 8003661..3ff240b 100644 --- a/compiler/cl-interpret/src/env.rs +++ b/compiler/cl-interpret/src/env.rs @@ -147,18 +147,18 @@ impl<'scope> Frame<'scope> { Self { scope: scope.enter(name) } } } -impl<'scope> Deref for Frame<'scope> { +impl Deref for Frame<'_> { type Target = Environment; fn deref(&self) -> &Self::Target { self.scope } } -impl<'scope> DerefMut for Frame<'scope> { +impl DerefMut for Frame<'_> { fn deref_mut(&mut self) -> &mut Self::Target { self.scope } } -impl<'scope> Drop for Frame<'scope> { +impl Drop for Frame<'_> { fn drop(&mut self) { self.scope.exit(); } diff --git a/compiler/cl-lexer/src/lib.rs b/compiler/cl-lexer/src/lib.rs index 7e0c867..abfbddb 100644 --- a/compiler/cl-lexer/src/lib.rs +++ b/compiler/cl-lexer/src/lib.rs @@ -23,7 +23,7 @@ pub mod lexer_iter { pub struct LexerIter<'t> { lexer: Lexer<'t>, } - impl<'t> Iterator for LexerIter<'t> { + impl Iterator for LexerIter<'_> { type Item = LResult; fn next(&mut self) -> Option { match self.lexer.scan() { @@ -192,7 +192,7 @@ impl<'t> Lexer<'t> { } } /// Digraphs and trigraphs -impl<'t> Lexer<'t> { +impl Lexer<'_> { fn amp(&mut self) -> LResult { match self.peek() { Ok('&') => self.consume()?.produce_op(Kind::AmpAmp), @@ -319,7 +319,7 @@ impl<'t> Lexer<'t> { } } /// Comments -impl<'t> Lexer<'t> { +impl Lexer<'_> { fn line_comment(&mut self) -> LResult { let mut comment = String::new(); while Ok('\n') != self.peek() { @@ -339,7 +339,7 @@ impl<'t> Lexer<'t> { } } /// Identifiers -impl<'t> Lexer<'t> { +impl Lexer<'_> { fn identifier(&mut self) -> LResult { let mut out = String::from(self.xid_start()?); while let Ok(c) = self.xid_continue() { @@ -371,7 +371,7 @@ impl<'t> Lexer<'t> { } } /// Integers -impl<'t> Lexer<'t> { +impl Lexer<'_> { fn int_with_base(&mut self) -> LResult { match self.peek() { Ok('x') => self.consume()?.digits::<16>(), @@ -414,7 +414,7 @@ impl<'t> Lexer<'t> { } } /// Strings and characters -impl<'t> Lexer<'t> { +impl Lexer<'_> { fn string(&mut self) -> LResult { let mut value = String::new(); while '"' diff --git a/compiler/cl-repl/examples/yaml.rs b/compiler/cl-repl/examples/yaml.rs index 6169f64..b297d80 100644 --- a/compiler/cl-repl/examples/yaml.rs +++ b/compiler/cl-repl/examples/yaml.rs @@ -120,19 +120,19 @@ pub mod yamler { } } - impl<'y> Deref for Section<'y> { + impl Deref for Section<'_> { type Target = Yamler; fn deref(&self) -> &Self::Target { self.yamler } } - impl<'y> DerefMut for Section<'y> { + impl DerefMut for Section<'_> { fn deref_mut(&mut self) -> &mut Self::Target { self.yamler } } - impl<'y> Drop for Section<'y> { + impl Drop for Section<'_> { fn drop(&mut self) { let Self { yamler } = self; yamler.decrease(); diff --git a/compiler/cl-structures/src/intern.rs b/compiler/cl-structures/src/intern.rs index a87552d..5c04d8b 100644 --- a/compiler/cl-structures/src/intern.rs +++ b/compiler/cl-structures/src/intern.rs @@ -37,7 +37,7 @@ pub mod interned { } } - impl<'a, T: ?Sized + Debug> Debug for Interned<'a, T> { + impl Debug for Interned<'_, T> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("Interned") .field("value", &self.value) @@ -49,14 +49,14 @@ pub mod interned { Self { value } } } - impl<'a, T: ?Sized> Deref for Interned<'a, T> { + impl Deref for Interned<'_, T> { type Target = T; fn deref(&self) -> &Self::Target { self.value } } - impl<'a, T: ?Sized> Copy for Interned<'a, T> {} - impl<'a, T: ?Sized> Clone for Interned<'a, T> { + impl Copy for Interned<'_, T> {} + impl Clone for Interned<'_, T> { fn clone(&self) -> Self { *self } @@ -79,13 +79,13 @@ pub mod interned { // } // } - impl<'a, T: ?Sized> Eq for Interned<'a, T> {} - impl<'a, T: ?Sized> PartialEq for Interned<'a, T> { + impl Eq for Interned<'_, T> {} + impl PartialEq for Interned<'_, T> { fn eq(&self, other: &Self) -> bool { std::ptr::eq(self.value, other.value) } } - impl<'a, T: ?Sized> Hash for Interned<'a, T> { + impl Hash for Interned<'_, T> { fn hash(&self, state: &mut H) { Self::as_ptr(self).hash(state) } @@ -208,8 +208,8 @@ pub mod string_interner { // This is fine because StringInterner::get_or_insert(v) holds a RwLock // for its entire duration, and doesn't touch the non-(Send+Sync) arena // unless the lock is held by a write guard. - unsafe impl<'a> Send for StringInterner<'a> {} - unsafe impl<'a> Sync for StringInterner<'a> {} + unsafe impl Send for StringInterner<'_> {} + unsafe impl Sync for StringInterner<'_> {} #[cfg(test)] mod tests { @@ -306,5 +306,5 @@ pub mod typed_interner { /// [get_or_insert](TypedInterner::get_or_insert) are unique, and the function uses /// the [RwLock] around the [HashSet] to ensure mutual exclusion unsafe impl<'a, T: Eq + Hash + Send> Send for TypedInterner<'a, T> where &'a T: Send {} - unsafe impl<'a, T: Eq + Hash + Send + Sync> Sync for TypedInterner<'a, T> {} + unsafe impl Sync for TypedInterner<'_, T> {} } diff --git a/compiler/cl-typeck/src/source.rs b/compiler/cl-typeck/src/source.rs index 90fdca7..fbe175b 100644 --- a/compiler/cl-typeck/src/source.rs +++ b/compiler/cl-typeck/src/source.rs @@ -20,7 +20,7 @@ pub enum Source<'a> { Ty(&'a TyKind), } -impl<'a> Source<'a> { +impl Source<'_> { pub fn name(&self) -> Option { match self { Source::Root => None, diff --git a/compiler/cl-typeck/src/table.rs b/compiler/cl-typeck/src/table.rs index 3df9934..ea375db 100644 --- a/compiler/cl-typeck/src/table.rs +++ b/compiler/cl-typeck/src/table.rs @@ -268,7 +268,7 @@ impl<'a> Table<'a> { } } -impl<'a> Default for Table<'a> { +impl Default for Table<'_> { fn default() -> Self { Self::new() }