Skip to content

Commit

Permalink
Fix new clippy 1.83 warnings (#2114)
Browse files Browse the repository at this point in the history
  • Loading branch information
yannham authored Dec 2, 2024
1 parent 39ad996 commit 7a03bed
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 25 deletions.
6 changes: 3 additions & 3 deletions core/src/bytecode/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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<Item = &'ast Type> {
pub fn iter(&'ast self) -> impl Iterator<Item = &'ast Type<'ast>> {
self.typ.iter().chain(self.contracts.iter())
}

Expand Down
6 changes: 3 additions & 3 deletions core/src/bytecode/ast/pattern/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;

Expand All @@ -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_
Expand Down
9 changes: 3 additions & 6 deletions core/src/bytecode/ast/primop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions core/src/bytecode/ast/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<LocIdent> {
Expand Down Expand Up @@ -97,7 +97,7 @@ pub struct FieldMetadata<'ast> {
pub priority: MergePriority,
}

impl<'ast> FieldMetadata<'ast> {
impl FieldMetadata<'_> {
pub fn new() -> Self {
Default::default()
}
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion core/src/identifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<InnerInterner<'a>>);

impl<'a> Interner<'a> {
impl Interner<'_> {
/// Creates an empty [Interner].
pub(crate) fn new() -> Self {
Self(RwLock::new(InnerInterner::new()))
Expand Down
4 changes: 2 additions & 2 deletions core/src/parser/uniterm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl<'ast> From<UniTermNode<'ast>> for UniTerm<'ast> {
}
}

impl<'ast> UniTerm<'ast> {
impl UniTerm<'_> {
pub fn with_pos(mut self, pos: TermPos) -> Self {
self.pos = pos;
self
Expand Down Expand Up @@ -201,7 +201,7 @@ impl<'ast> From<UniRecord<'ast>> for UniTerm<'ast> {
}
}

impl<'ast, T, U> TryConvert<'ast, T> for U
impl<T, U> TryConvert<'_, T> for U
where
U: TryFrom<T>,
{
Expand Down
2 changes: 1 addition & 1 deletion core/src/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 0 additions & 2 deletions core/src/term/pattern/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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% "<id>" bindings_id value_id`
Expand Down
2 changes: 1 addition & 1 deletion lsp/lsp-harness/src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub trait LspDebug {
}
}

impl<'a, T: LspDebug> LspDebug for &'a T {
impl<T: LspDebug> LspDebug for &T {
fn debug(&self, w: impl Write) -> std::io::Result<()> {
<T as LspDebug>::debug(*self, w)
}
Expand Down
2 changes: 1 addition & 1 deletion lsp/nls/src/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ pub struct ParentChainIter<'a> {
next: Option<Parent>,
}

impl<'a> ParentChainIter<'a> {
impl ParentChainIter<'_> {
pub fn next(&mut self) -> Option<RichTerm> {
if let Some(next) = self.next.take() {
if let Some((ident, path)) = next.child_name.zip(self.path.as_mut()) {
Expand Down
4 changes: 2 additions & 2 deletions lsp/nls/src/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ impl Trace {
where
F: FnOnce(MutexGuard<Trace>) -> 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) {
Expand Down

0 comments on commit 7a03bed

Please sign in to comment.