2022-04-23 00:05:18 +00:00
|
|
|
#![allow(dead_code, clippy::extra_unused_lifetimes)]
|
2018-07-28 15:34:52 +00:00
|
|
|
#![warn(clippy::multiple_inherent_impl)]
|
2018-05-29 00:17:55 +00:00
|
|
|
|
|
|
|
struct MyStruct;
|
|
|
|
|
|
|
|
impl MyStruct {
|
|
|
|
fn first() {}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl MyStruct {
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: multiple implementations of this structure
|
2018-05-29 00:17:55 +00:00
|
|
|
fn second() {}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> MyStruct {
|
|
|
|
fn lifetimed() {}
|
|
|
|
}
|
|
|
|
|
|
|
|
mod submod {
|
|
|
|
struct MyStruct;
|
|
|
|
impl MyStruct {
|
|
|
|
fn other() {}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl super::MyStruct {
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: multiple implementations of this structure
|
2018-05-29 00:17:55 +00:00
|
|
|
fn third() {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
use std::fmt;
|
|
|
|
impl fmt::Debug for MyStruct {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
|
|
write!(f, "MyStruct {{ }}")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-15 16:20:43 +00:00
|
|
|
// issue #5772
|
|
|
|
struct WithArgs<T>(T);
|
|
|
|
impl WithArgs<u32> {
|
|
|
|
fn f1() {}
|
|
|
|
}
|
|
|
|
impl WithArgs<u64> {
|
|
|
|
fn f2() {}
|
|
|
|
}
|
|
|
|
impl WithArgs<u64> {
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: multiple implementations of this structure
|
2021-04-15 16:20:43 +00:00
|
|
|
fn f3() {}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ok, the struct is allowed to have multiple impls.
|
|
|
|
#[allow(clippy::multiple_inherent_impl)]
|
|
|
|
struct Allowed;
|
|
|
|
impl Allowed {}
|
|
|
|
impl Allowed {}
|
|
|
|
impl Allowed {}
|
|
|
|
|
|
|
|
struct AllowedImpl;
|
|
|
|
#[allow(clippy::multiple_inherent_impl)]
|
|
|
|
impl AllowedImpl {}
|
|
|
|
// Ok, the first block is skipped by this lint.
|
|
|
|
impl AllowedImpl {}
|
|
|
|
|
|
|
|
struct OneAllowedImpl;
|
|
|
|
impl OneAllowedImpl {}
|
|
|
|
#[allow(clippy::multiple_inherent_impl)]
|
|
|
|
impl OneAllowedImpl {}
|
|
|
|
impl OneAllowedImpl {} // Lint, only one of the three blocks is allowed.
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: multiple implementations of this structure
|
2021-04-15 16:20:43 +00:00
|
|
|
|
2018-05-29 00:17:55 +00:00
|
|
|
fn main() {}
|