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,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)
}
} }
}, },
_ => {}, _ => {},

View file

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

View file

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

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) { 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