Merge pull request #2209 from sinkuu/trait_methods

Fix false positive in needless_pass_by_value trait methods
This commit is contained in:
Oliver Schneider 2017-11-07 08:26:32 +01:00 committed by GitHub
commit 088555c4ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -87,7 +87,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
// Exclude non-inherent impls
if let Some(NodeItem(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(node_id)) {
if matches!(item.node, ItemImpl(_, _, _, _, Some(_), _, _) | ItemAutoImpl(..)) {
if matches!(item.node, ItemImpl(_, _, _, _, Some(_), _, _) | ItemAutoImpl(..) |
ItemTrait(..))
{
return;
}
}

View File

@ -103,4 +103,11 @@ impl<T: Serialize, U> S<T, U> {
}
}
trait FalsePositive {
fn visit_str(s: &str);
fn visit_string(s: String) {
Self::visit_str(&s);
}
}
fn main() {}