ignore mutable self reference parameters

This commit is contained in:
Christoph Walcher 2020-08-07 18:03:12 +02:00
parent e03f73e627
commit bfe610cc8d
No known key found for this signature in database
GPG key ID: A193164A4D05EE44
4 changed files with 9 additions and 11 deletions

View file

@ -104,9 +104,13 @@ impl EarlyLintPass for NeedlessArbitrarySelfType {
}
},
TyKind::Rptr(lifetime, mut_ty) => {
if let TyKind::Path(None, path) = &mut_ty.ty.kind {
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)
}
}
},
_ => {},
}

View file

@ -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!();
}

View file

@ -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!();
}

View file

@ -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