Skip to content

wrong_self_convention: FN with is_* taking &mut self #8142

@jendrikw

Description

@jendrikw

Summary

My interpretation of the table at https://rust-lang.github.io/rust-clippy/master/index.html#wrong_self_convention is that a method called is_* is allowed to take no self, or &self, but not self or &mut self. In reality, only self produces a warning. Is this intentional?

Lint Name

wrong_self_convention

Reproducer

I tried this code:

#![allow(unused)] struct S { field: String } impl S { fn is_foo(&mut self) -> bool { todo!() } } fn main() {}

I expected to see this happen:

warning: methods called `is_*` usually take `self` by reference or no `self` --> src/main.rs:16:15 | 16 | fn is_foo(&mut self) -> bool { | ^^^^ 

Instead, this happened:

No warning

Version

rustc 1.57.0 (f1edd0429 2021-11-29) binary: rustc commit-hash: f1edd0429582dd29cccacaf50fd134b05593bd9c commit-date: 2021-11-29 host: x86_64-unknown-linux-gnu release: 1.57.0 LLVM version: 13.0.0 

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn't

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions