Fix internal warnings

This commit is contained in:
Sosthène Guédon 2022-11-01 21:49:20 +01:00
parent 5fa0e07cdf
commit 3e2e81b2db
2 changed files with 9 additions and 5 deletions

View File

@ -28,15 +28,14 @@ pub fn check_fn(
let name = ident.name.as_str();
let name = match sig.decl.implicit_self {
ImplicitSelfKind::ImmRef => name,
ImplicitSelfKind::MutRef => {
let Some(name) = name.strip_suffix("_mut") else {
return;
};
name
},
ImplicitSelfKind::Imm | ImplicitSelfKind::Mut => name,
_ => return,
ImplicitSelfKind::Imm | ImplicitSelfKind::Mut | ImplicitSelfKind::ImmRef => name,
ImplicitSelfKind::None => return,
};
// Body must be &(mut) <self_data>.name

View File

@ -278,16 +278,21 @@ declare_clippy_lint! {
///
/// impl A {
/// fn a(&self) -> &str{
/// self.b
/// &self.b
/// }
/// }
/// // example code where clippy issues a warning
/// ```
/// Use instead:
/// ```rust
/// struct A {
/// a: String,
/// b: String,
/// }
///
/// impl A {
/// fn a(&self) -> &str{
/// self.a
/// &self.a
/// }
/// }
/// ```