conlang: Elide lifetimes (fixes clippy lint)
This commit is contained in:
parent
d71276b477
commit
883fd31d38
@ -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<F: Write + ?Sized> 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<F: Write + ?Sized> 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<F: Write + ?Sized> Write for Delimit<'_, F> {
|
||||
fn write_str(&mut self, s: &str) -> std::fmt::Result {
|
||||
self.f.write_str(s)
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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<Token>;
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
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<Token> {
|
||||
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<Token> {
|
||||
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<Token> {
|
||||
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<Token> {
|
||||
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<Token> {
|
||||
let mut value = String::new();
|
||||
while '"'
|
||||
|
@ -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();
|
||||
|
@ -37,7 +37,7 @@ pub mod interned {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T: ?Sized + Debug> Debug for Interned<'a, T> {
|
||||
impl<T: ?Sized + Debug> 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<T: ?Sized> 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<T: ?Sized> Copy for Interned<'_, T> {}
|
||||
impl<T: ?Sized> 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<T: ?Sized> Eq for Interned<'_, T> {}
|
||||
impl<T: ?Sized> 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<T: ?Sized> Hash for Interned<'_, T> {
|
||||
fn hash<H: std::hash::Hasher>(&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<T: Eq + Hash + Send + Sync> Sync for TypedInterner<'_, T> {}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ pub enum Source<'a> {
|
||||
Ty(&'a TyKind),
|
||||
}
|
||||
|
||||
impl<'a> Source<'a> {
|
||||
impl Source<'_> {
|
||||
pub fn name(&self) -> Option<Sym> {
|
||||
match self {
|
||||
Source::Root => None,
|
||||
|
@ -268,7 +268,7 @@ impl<'a> Table<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Default for Table<'a> {
|
||||
impl Default for Table<'_> {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user