ignore mutable self reference parameters

This commit is contained in:
Christoph Walcher
2020-08-07 18:03:12 +02:00
parent e03f73e627
commit bfe610cc8d
4 changed files with 9 additions and 11 deletions
@@ -104,8 +104,12 @@ fn check_param(&mut self, cx: &EarlyContext<'_>, p: &Param) {
}
},
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)
}
}
},
_ => {},
+1 -1
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!();
}
+1 -1
View File
@@ -57,7 +57,7 @@ pub fn mut_ref_good_with_lifetime<'a>(&'a mut self) {
unimplemented!();
}
pub fn mut_ref_mut_bad(mut self: &mut Self) {
pub fn mut_ref_mut_good(mut self: &mut Self) {
unimplemented!();
}
+1 -7
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