mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-21 03:14:11 +00:00
Fix internal warnings
This commit is contained in:
parent
5fa0e07cdf
commit
3e2e81b2db
@ -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
|
||||
|
@ -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
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
|
Loading…
Reference in New Issue
Block a user