mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-24 13:43:17 +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) => {
|
||||
if let TyKind::Path(None, path) = &mut_ty.ty.kind {
|
||||
check_param_inner(cx, path, p.span.to(p.ty.span), &Mode::Ref(*lifetime), mut_ty.mutbl)
|
||||
if_chain! {
|
||||
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!();
|
||||
}
|
||||
|
||||
pub fn mut_ref_mut_bad(&mut self) {
|
||||
pub fn mut_ref_mut_good(mut self: &mut Self) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ impl ValType {
|
|||
unimplemented!();
|
||||
}
|
||||
|
||||
pub fn mut_ref_mut_bad(mut self: &mut Self) {
|
||||
pub fn mut_ref_mut_good(mut self: &mut Self) {
|
||||
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) {
|
||||
| ^^^^^^^^^^^^^^^^^^ help: consider to change this parameter to: `&'a mut self`
|
||||
|
||||
error: the type of the `self` parameter does not need to be arbitrary
|
||||
--> $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
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
|
|
Loading…
Reference in a new issue