Skip to content

Weird trigger condition for wrong_self_convention #9038

Open
@crumblingstatue

Description

@crumblingstatue

Description

The following code triggers wrong_self_convention

mod foo {
    #[derive(Clone, Copy)]
    pub struct Foo<T>(std::marker::PhantomData<T>);

    impl<T> Foo<T> {
        pub fn to_bar(self) -> i32 {
            42
        }
    }
}
warning: methods with the following characteristics: (`to_*` and `self` type is not `Copy`) usually take `self` by reference
 --> src/lib.rs:6:23
  |
6 |         pub fn to_bar(self) -> i32 {
  |                       ^^^^

However, if it's not in a module, or the module is public, the lint doesn't trigger.

Version

rustc 1.63.0-nightly (10f4ce324 2022-06-22)
binary: rustc
commit-hash: 10f4ce324baf7cfb7ce2b2096662b82b79204944
commit-date: 2022-06-22
host: x86_64-unknown-linux-gnu
release: 1.63.0-nightly
LLVM version: 14.0.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions