-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
unnecessary_to_owned
: don't call iter()
on a temporary object
#14243
base: master
Are you sure you want to change the base?
Conversation
95a5ce9
to
d8286f5
Compare
d8286f5
to
9be2d63
Compare
9be2d63
to
6651fac
Compare
6651fac
to
5a849d9
Compare
@@ -2331,6 +2331,16 @@ pub fn is_expr_final_block_expr(tcx: TyCtxt<'_>, expr: &Expr<'_>) -> bool { | |||
matches!(tcx.parent_hir_node(expr.hir_id), Node::Block(..)) | |||
} | |||
|
|||
/// Checks if the expression is a temporary value. | |||
pub fn is_expr_temporary_value(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { | |||
expr.is_place_expr(|base| { |
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.
I think noting that this is the exact same code rustc uses would be helpful for people viewing this later. My main idea is that this looks a bit like a (maybe incorrect) heuristic at first, vs just copying the code, and this change can clear up that hypothetical confusion.
After that, I'll merge this quickly
fix #14242
changelog: [
unnecessary_to_owned
]: don't calliter
on a temporary object