-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Improve needless_pass_by_value #2117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Excluding a type whose reference also fulfills the trait bound.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except for a style nit, this looks absolutely flawless to me
let preds = preds | ||
.iter() | ||
.filter_map(|pred| if let ty::Predicate::Trait(ref poly_trait_ref) = *pred { | ||
Some(poly_trait_ref.skip_binder()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move the filter condition from below to here as an if
.filter(|p| !p.is_global()) | ||
.collect() | ||
}; | ||
let preds = traits::elaborate_predicates(cx.tcx, cx.param_env.caller_bounds.to_vec()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is there an intermediate vec?
Done. |
Thanks! |
serde::Serialize
which has a blanket implimpl Serialize for &S where S:Serialize
).ptr_arg
's logic forString
andVec
. Fixes needless_pass_by_value false positive with String #2114.&String
is suggested if.capacity()
is found.