Closed
Description
Description
Desctiption
Following code snippet was correctly marked by clippy as or_fun_call
. However it's output could be better. Problem here is at the last line of this block, but clippy's hint is cropped and this bottom part is not shown. It seams that clippy is omitting different lines in the warning and in the hint.
Code
self.frames
.iter()
.map(|f| f.encode())
.reduce(|mut acc, mut f| {
acc.append(&mut f);
acc
})
.unwrap_or(Vec::new())
Clippy's output
warning: use of `unwrap_or` followed by a call to `new`
--> src/server/frame.rs:89:9
|
89 | / self.frames
90 | | .iter()
91 | | .map(|f| f.encode())
92 | | .reduce(|mut acc, mut f| {
... |
95 | | })
96 | | .unwrap_or(Vec::new())
| |__________________________________^
|
= 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
help: try this
|
89 ~ self.frames
90 + .iter()
91 + .map(|f| f.encode())
92 + .reduce(|mut acc, mut f| {
93 + acc.append(&mut f);
94 + acc
...
Version
rustc 1.57.0 (f1edd0429 2021-11-29)
binary: rustc
commit-hash: f1edd0429582dd29cccacaf50fd134b05593bd9c
commit-date: 2021-11-29
host: x86_64-unknown-linux-gnu
release: 1.57.0
LLVM version: 13.0.0
Additional Labels
@rustbot label +C-enhancement