2024-03-28 03:29:52 -05:00
|
|
|
//@no-rustfix
|
2024-05-12 09:13:17 -05:00
|
|
|
//@revisions: default extend
|
|
|
|
//@[default] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/renamed_function_params/default
|
|
|
|
//@[extend] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/renamed_function_params/extend
|
2023-09-20 06:05:37 -05:00
|
|
|
#![warn(clippy::renamed_function_params)]
|
2024-03-28 03:29:52 -05:00
|
|
|
#![allow(clippy::partialeq_ne_impl, clippy::to_string_trait_impl)]
|
2023-09-20 06:05:37 -05:00
|
|
|
#![allow(unused)]
|
|
|
|
|
|
|
|
use std::hash::{Hash, Hasher};
|
|
|
|
|
|
|
|
struct A;
|
|
|
|
impl From<A> for String {
|
|
|
|
fn from(_value: A) -> Self {
|
|
|
|
String::new()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl ToString for A {
|
|
|
|
fn to_string(&self) -> String {
|
|
|
|
String::new()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct B(u32);
|
2024-05-12 09:13:17 -05:00
|
|
|
impl std::convert::From<B> for String {
|
2023-09-20 06:05:37 -05:00
|
|
|
fn from(b: B) -> Self {
|
|
|
|
b.0.to_string()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl PartialEq for B {
|
|
|
|
fn eq(&self, rhs: &Self) -> bool {
|
2024-03-28 03:29:52 -05:00
|
|
|
//~^ ERROR: renamed function parameter of trait impl
|
2023-09-20 06:05:37 -05:00
|
|
|
self.0 == rhs.0
|
|
|
|
}
|
|
|
|
fn ne(&self, rhs: &Self) -> bool {
|
2024-03-28 03:29:52 -05:00
|
|
|
//~^ ERROR: renamed function parameter of trait impl
|
2023-09-20 06:05:37 -05:00
|
|
|
self.0 != rhs.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
trait MyTrait {
|
|
|
|
fn foo(&self, val: u8);
|
|
|
|
fn bar(a: u8, b: u8);
|
|
|
|
fn baz(self, _val: u8);
|
2024-03-28 03:29:52 -05:00
|
|
|
fn quz(&self, _: u8);
|
2023-09-20 06:05:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
impl MyTrait for B {
|
2024-05-12 09:13:17 -05:00
|
|
|
fn foo(&self, i_dont_wanna_use_your_name: u8) {} // only lint in `extend`
|
2024-03-28 03:29:52 -05:00
|
|
|
fn bar(_a: u8, _: u8) {}
|
2023-09-20 06:05:37 -05:00
|
|
|
fn baz(self, val: u8) {}
|
2024-03-28 03:29:52 -05:00
|
|
|
fn quz(&self, val: u8) {}
|
2023-09-20 06:05:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Hash for B {
|
|
|
|
fn hash<H: Hasher>(&self, states: &mut H) {
|
2024-03-28 03:29:52 -05:00
|
|
|
//~^ ERROR: renamed function parameter of trait impl
|
2023-09-20 06:05:37 -05:00
|
|
|
self.0.hash(states);
|
|
|
|
}
|
|
|
|
fn hash_slice<H: Hasher>(date: &[Self], states: &mut H) {
|
2024-03-28 03:29:52 -05:00
|
|
|
//~^ ERROR: renamed function parameters of trait impl
|
2023-09-20 06:05:37 -05:00
|
|
|
for d in date {
|
|
|
|
d.hash(states);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl B {
|
|
|
|
fn totally_irrelevant(&self, right: bool) {}
|
|
|
|
fn some_fn(&self, other: impl MyTrait) {}
|
|
|
|
}
|
|
|
|
|
2024-03-28 03:29:52 -05:00
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
enum C {
|
|
|
|
A,
|
|
|
|
B(u32),
|
|
|
|
}
|
|
|
|
|
|
|
|
impl std::ops::Add<B> for C {
|
|
|
|
type Output = C;
|
|
|
|
fn add(self, b: B) -> C {
|
2024-05-12 09:13:17 -05:00
|
|
|
// only lint in `extend`
|
2024-03-28 03:29:52 -05:00
|
|
|
C::B(b.0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<A> for C {
|
|
|
|
fn from(_: A) -> C {
|
|
|
|
C::A
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
trait CustomTraitA {
|
|
|
|
fn foo(&self, other: u32);
|
|
|
|
}
|
|
|
|
trait CustomTraitB {
|
|
|
|
fn bar(&self, value: u8);
|
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! impl_trait {
|
|
|
|
($impl_for:ident, $tr:ty, $fn_name:ident, $t:ty) => {
|
|
|
|
impl $tr for $impl_for {
|
|
|
|
fn $fn_name(&self, v: $t) {}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
impl_trait!(C, CustomTraitA, foo, u32);
|
|
|
|
impl_trait!(C, CustomTraitB, bar, u8);
|
|
|
|
|
2023-09-20 06:05:37 -05:00
|
|
|
fn main() {}
|