mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-01 00:49:30 +00:00
ignore mutable self reference parameters
This commit is contained in:
parent
e03f73e627
commit
bfe610cc8d
4 changed files with 9 additions and 11 deletions
|
@ -104,8 +104,12 @@ impl EarlyLintPass for NeedlessArbitrarySelfType {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
TyKind::Rptr(lifetime, mut_ty) => {
|
TyKind::Rptr(lifetime, mut_ty) => {
|
||||||
if let TyKind::Path(None, path) = &mut_ty.ty.kind {
|
if_chain! {
|
||||||
check_param_inner(cx, path, p.span.to(p.ty.span), &Mode::Ref(*lifetime), mut_ty.mutbl)
|
if let TyKind::Path(None, path) = &mut_ty.ty.kind;
|
||||||
|
if let PatKind::Ident(BindingMode::ByValue(Mutability::Not), _, _) = p.pat.kind;
|
||||||
|
then {
|
||||||
|
check_param_inner(cx, path, p.span.to(p.ty.span), &Mode::Ref(*lifetime), mut_ty.mutbl)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => {},
|
_ => {},
|
||||||
|
|
|
@ -57,7 +57,7 @@ impl ValType {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mut_ref_mut_bad(&mut self) {
|
pub fn mut_ref_mut_good(mut self: &mut Self) {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ impl ValType {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mut_ref_mut_bad(mut self: &mut Self) {
|
pub fn mut_ref_mut_good(mut self: &mut Self) {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,11 +36,5 @@ error: the type of the `self` parameter does not need to be arbitrary
|
||||||
LL | pub fn mut_ref_bad_with_lifetime<'a>(self: &'a mut Self) {
|
LL | pub fn mut_ref_bad_with_lifetime<'a>(self: &'a mut Self) {
|
||||||
| ^^^^^^^^^^^^^^^^^^ help: consider to change this parameter to: `&'a mut self`
|
| ^^^^^^^^^^^^^^^^^^ help: consider to change this parameter to: `&'a mut self`
|
||||||
|
|
||||||
error: the type of the `self` parameter does not need to be arbitrary
|
error: aborting due to 6 previous errors
|
||||||
--> $DIR/needless_arbitrary_self_type.rs:60:28
|
|
||||||
|
|
|
||||||
LL | pub fn mut_ref_mut_bad(mut self: &mut Self) {
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^ help: consider to change this parameter to: `&mut self`
|
|
||||||
|
|
||||||
error: aborting due to 7 previous errors
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue