-
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
or_fun_call bad output with vec![] #1667
Comments
This potentially could recommend |
A variation on this: warning: use of `or_insert` followed by a function call
--> src/bin/04.rs:88:60
|
88 | let minutes = &mut minutes_frequency.entry(*guard).or_insert(vec![0; 60]);
| ^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(|| $ crate :: vec :: from_elem ( $ elem , $ n ))`
|
in that case, you are actually allocating the |
Yup, that's what I've meant; updated the comment to be less vague. |
Ah, gotcha! |
Current output: warning: use of `or_insert` followed by a function call
--> src/main.rs:5:29
|
5 | let foo = hash.entry(1).or_insert(vec![0; 60]);
| ^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(|| vec![0; 60])`
|
= note: `#[warn(clippy::or_fun_call)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#or_fun_call So this issue is fixed? @phansch |
Gives:
A nicer looking warning should show
.or_insert_with(|| vec![]);
The text was updated successfully, but these errors were encountered: