Auto merge of #13113 - nyurik:ignore-pass-by-val-for-pfx, r=blyxyas
Ignore underscore-prefixed args for needless_pass_by_value lint When a user explicitly tags a param as unused (yet?), there is no need to raise another lint on it. fixes #7295 Note that I had to rename all `_*` params in the tests, but kept the variable name length to avoid extra changes in the expected output. changelog: [`needless_pass_by_value`]: do not warn if the argument name starts with an `_`
This commit is contained in:
commit
083e20a6dc
3 changed files with 21 additions and 16 deletions
|
|
@ -129,7 +129,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
|
|||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
// Collect moved variables and spans which will need dereferencings from the
|
||||
// Collect moved variables and spans which will need dereferencing from the
|
||||
// function body.
|
||||
let MovedVariablesCtxt { moved_vars } = {
|
||||
let mut ctx = MovedVariablesCtxt::default();
|
||||
|
|
@ -148,12 +148,13 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
|
|||
return;
|
||||
}
|
||||
|
||||
// Ignore `self`s.
|
||||
if idx == 0 {
|
||||
if let PatKind::Binding(.., ident, _) = arg.pat.kind {
|
||||
if ident.name == kw::SelfLower {
|
||||
continue;
|
||||
}
|
||||
// Ignore `self`s and params whose variable name starts with an underscore
|
||||
if let PatKind::Binding(.., ident, _) = arg.pat.kind {
|
||||
if idx == 0 && ident.name == kw::SelfLower {
|
||||
continue;
|
||||
}
|
||||
if ident.name.as_str().starts_with('_') {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue