Skip to content

unconditional_recursion false positive in PartialEq field comparison (2)Β #12133

Closed
@dtolnay

Description

@dtolnay

Summary

Not the same as #12052. This happens with a nightly in which the other false positive is fixed already.

Lint Name

unconditional_recursion

Reproducer

pub struct Struct {
    field: String,
}

impl PartialEq for Struct {
    fn eq(&self, other: &Self) -> bool {
        self.field.eq(&other.field)
    }
}
warning: function cannot return without recursing
 --> src/main.rs:6:5
  |
6 | /     fn eq(&self, other: &Self) -> bool {
7 | |         self.field.eq(&other.field)
8 | |     }
  | |_____^
  |
note: recursive call site
 --> src/main.rs:7:9
  |
7 |         self.field.eq(&other.field)
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unconditional_recursion
  = note: `#[warn(clippy::unconditional_recursion)]` on by default

Version

rustc 1.77.0-nightly (62d7ed4a6 2024-01-11)
binary: rustc
commit-hash: 62d7ed4a6775c4490e493093ca98ef7c215b835b
commit-date: 2024-01-11
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6

Additional Labels

@GuillaumeGomez @xFrednet

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions