From 7a03bed7a8f00a50e5b2b22b28afa2003d3a8a0f Mon Sep 17 00:00:00 2001 From: Yann Hamdaoui Date: Mon, 2 Dec 2024 11:59:37 +0100 Subject: [PATCH] Fix new clippy 1.83 warnings (#2114) --- core/src/bytecode/ast/mod.rs | 6 +++--- core/src/bytecode/ast/pattern/mod.rs | 6 +++--- core/src/bytecode/ast/primop.rs | 9 +++------ core/src/bytecode/ast/record.rs | 6 +++--- core/src/identifier.rs | 2 +- core/src/parser/uniterm.rs | 4 ++-- core/src/pretty.rs | 2 +- core/src/term/pattern/compile.rs | 2 -- lsp/lsp-harness/src/output.rs | 2 +- lsp/nls/src/analysis.rs | 2 +- lsp/nls/src/trace.rs | 4 ++-- 11 files changed, 20 insertions(+), 25 deletions(-) diff --git a/core/src/bytecode/ast/mod.rs b/core/src/bytecode/ast/mod.rs index 16b38f73ab..523c693af8 100644 --- a/core/src/bytecode/ast/mod.rs +++ b/core/src/bytecode/ast/mod.rs @@ -225,7 +225,7 @@ pub struct Ast<'ast> { pub pos: TermPos, } -impl<'ast> Ast<'ast> { +impl Ast<'_> { /// Sets a new position for this AST node. pub fn with_pos(self, pos: TermPos) -> Self { Ast { pos, ..self } @@ -265,12 +265,12 @@ pub struct Annotation<'ast> { impl<'ast> Annotation<'ast> { /// Returns the main annotation, which is either the type annotation if any, or the first /// contract annotation. - pub fn first(&'ast self) -> Option<&'ast Type> { + pub fn first(&'ast self) -> Option<&'ast Type<'ast>> { self.typ.as_ref().or(self.contracts.iter().next()) } /// Iterates over the annotations, starting by the type and followed by the contracts. - pub fn iter(&'ast self) -> impl Iterator { + pub fn iter(&'ast self) -> impl Iterator> { self.typ.iter().chain(self.contracts.iter()) } diff --git a/core/src/bytecode/ast/pattern/mod.rs b/core/src/bytecode/ast/pattern/mod.rs index e682c58cf4..51d0123af2 100644 --- a/core/src/bytecode/ast/pattern/mod.rs +++ b/core/src/bytecode/ast/pattern/mod.rs @@ -88,7 +88,7 @@ pub struct ArrayPattern<'ast> { pub pos: TermPos, } -impl<'ast> ArrayPattern<'ast> { +impl ArrayPattern<'_> { /// Check if this record contract is open, meaning that it accepts additional fields to be /// present, whether the rest is captured or not. pub fn is_open(&self) -> bool { @@ -130,7 +130,7 @@ pub enum TailPattern { Capture(LocIdent), } -impl<'ast> Pattern<'ast> { +impl Pattern<'_> { pub fn any(id: LocIdent) -> Self { let pos = id.pos; @@ -150,7 +150,7 @@ impl TailPattern { } } -impl<'ast> RecordPattern<'ast> { +impl RecordPattern<'_> { /// Check the matches for duplication, and raise an error if any occurs. /// /// Note that for backwards-compatibility reasons this function _only_ diff --git a/core/src/bytecode/ast/primop.rs b/core/src/bytecode/ast/primop.rs index 4fc7cbb8bf..bb45ce9a77 100644 --- a/core/src/bytecode/ast/primop.rs +++ b/core/src/bytecode/ast/primop.rs @@ -10,8 +10,7 @@ pub use crate::term::RecordOpKind; /// Nickel primitive operations. #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum PrimOp { - /// Unary operators or operator that are eager only in their first argument. - + // Unary operators or operator that are eager only in their first argument. /// Return an enum tag representing the type of the term. /// /// # Arguments @@ -441,8 +440,7 @@ pub enum PrimOp { /// 1. The numeral argument. NumberTan, - /// Binary operators or multi-ary operators that are eager in their two first arguments. - + // Binary operators or multi-ary operators that are eager in their two first arguments. /// Addition of numerals. /// /// # Arguments @@ -842,8 +840,7 @@ pub enum PrimOp { /// 2. The label. LabelLookupTypeVar, - /// N-ary primops for `n > 2`. - + // N-ary primops for `n > 2`. /// Replace a substring by another one in a string. /// /// # Arguments diff --git a/core/src/bytecode/ast/record.rs b/core/src/bytecode/ast/record.rs index 4b8118a2a1..b0569cf8a5 100644 --- a/core/src/bytecode/ast/record.rs +++ b/core/src/bytecode/ast/record.rs @@ -69,7 +69,7 @@ pub struct FieldDef<'ast> { pub pos: TermPos, } -impl<'ast> FieldDef<'ast> { +impl FieldDef<'_> { /// Returns the identifier corresponding to this definition if the path is composed of exactly /// one element which is a static identifier. Returns `None` otherwise. pub fn path_as_ident(&self) -> Option { @@ -97,7 +97,7 @@ pub struct FieldMetadata<'ast> { pub priority: MergePriority, } -impl<'ast> FieldMetadata<'ast> { +impl FieldMetadata<'_> { pub fn new() -> Self { Default::default() } @@ -129,7 +129,7 @@ pub struct Record<'ast> { pub open: bool, } -impl<'ast> Record<'ast> { +impl Record<'_> { /// A record with no fields and the default set of attributes. pub fn empty() -> Self { Default::default() diff --git a/core/src/identifier.rs b/core/src/identifier.rs index 84df011d7d..705bdecfb4 100644 --- a/core/src/identifier.rs +++ b/core/src/identifier.rs @@ -252,7 +252,7 @@ mod interner { /// and it makes it so that labels are stored only once, saving space. pub(crate) struct Interner<'a>(RwLock>); - impl<'a> Interner<'a> { + impl Interner<'_> { /// Creates an empty [Interner]. pub(crate) fn new() -> Self { Self(RwLock::new(InnerInterner::new())) diff --git a/core/src/parser/uniterm.rs b/core/src/parser/uniterm.rs index ddd3ec3157..6c1dc7eb38 100644 --- a/core/src/parser/uniterm.rs +++ b/core/src/parser/uniterm.rs @@ -71,7 +71,7 @@ impl<'ast> From> for UniTerm<'ast> { } } -impl<'ast> UniTerm<'ast> { +impl UniTerm<'_> { pub fn with_pos(mut self, pos: TermPos) -> Self { self.pos = pos; self @@ -201,7 +201,7 @@ impl<'ast> From> for UniTerm<'ast> { } } -impl<'ast, T, U> TryConvert<'ast, T> for U +impl TryConvert<'_, T> for U where U: TryFrom, { diff --git a/core/src/pretty.rs b/core/src/pretty.rs index cc0b316801..50077d9344 100644 --- a/core/src/pretty.rs +++ b/core/src/pretty.rs @@ -613,7 +613,7 @@ trait NickelDocBuilderExt { fn parens_if(self, parens: bool) -> Self; } -impl<'a> NickelDocBuilderExt for DocBuilder<'a, Allocator> { +impl NickelDocBuilderExt for DocBuilder<'_, Allocator> { fn parens_if(self, parens: bool) -> Self { if parens { self.parens() diff --git a/core/src/term/pattern/compile.rs b/core/src/term/pattern/compile.rs index c78319e697..402b86bd56 100644 --- a/core/src/term/pattern/compile.rs +++ b/core/src/term/pattern/compile.rs @@ -43,8 +43,6 @@ fn record_insert() -> BinaryOp { } } -/// Generate a record update - /// Generate a Nickel expression which inserts a new binding in the working dictionary. /// /// `%record/insert% "" bindings_id value_id` diff --git a/lsp/lsp-harness/src/output.rs b/lsp/lsp-harness/src/output.rs index 2c030bac02..de0cdae111 100644 --- a/lsp/lsp-harness/src/output.rs +++ b/lsp/lsp-harness/src/output.rs @@ -16,7 +16,7 @@ pub trait LspDebug { } } -impl<'a, T: LspDebug> LspDebug for &'a T { +impl LspDebug for &T { fn debug(&self, w: impl Write) -> std::io::Result<()> { ::debug(*self, w) } diff --git a/lsp/nls/src/analysis.rs b/lsp/nls/src/analysis.rs index 61d96b6f61..248f0bb420 100644 --- a/lsp/nls/src/analysis.rs +++ b/lsp/nls/src/analysis.rs @@ -170,7 +170,7 @@ pub struct ParentChainIter<'a> { next: Option, } -impl<'a> ParentChainIter<'a> { +impl ParentChainIter<'_> { pub fn next(&mut self) -> Option { if let Some(next) = self.next.take() { if let Some((ident, path)) = next.child_name.zip(self.path.as_mut()) { diff --git a/lsp/nls/src/trace.rs b/lsp/nls/src/trace.rs index 310da65876..e9c59f3b60 100644 --- a/lsp/nls/src/trace.rs +++ b/lsp/nls/src/trace.rs @@ -153,10 +153,10 @@ impl Trace { where F: FnOnce(MutexGuard) -> Result<()>, { - return TRACE + TRACE .lock() .or_else(|_| anyhow::bail!("Could not lock tracer mutex")) - .and_then(f); + .and_then(f) } pub fn receive(id: RequestId, method: impl ToString) {