diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
commit | 698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch) | |
tree | 173a775858bd501c378080a10dca74132f05bc50 /src/tools/clippy/tests/ui/map_flatten.stderr | |
parent | Initial commit. (diff) | |
download | rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip |
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/clippy/tests/ui/map_flatten.stderr')
-rw-r--r-- | src/tools/clippy/tests/ui/map_flatten.stderr | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/map_flatten.stderr b/src/tools/clippy/tests/ui/map_flatten.stderr new file mode 100644 index 000000000..4b2630d68 --- /dev/null +++ b/src/tools/clippy/tests/ui/map_flatten.stderr @@ -0,0 +1,100 @@ +error: called `map(..).flatten()` on `Option` + --> $DIR/map_flatten.rs:8:10 + | +LL | .map(|x| { + | __________^ +LL | | if x <= 5 { +LL | | Some(x) +LL | | } else { +... | +LL | | }) +LL | | .flatten(); + | |__________________^ + | + = note: `-D clippy::map-flatten` implied by `-D warnings` +help: try replacing `map` with `and_then` and remove the `.flatten()` + | +LL ~ .and_then(|x| { +LL + if x <= 5 { +LL + Some(x) +LL + } else { +LL + None +LL + } +LL ~ }); + | + +error: called `map(..).flatten()` on `Result` + --> $DIR/map_flatten.rs:18:10 + | +LL | .map(|x| { + | __________^ +LL | | if x == 1 { +LL | | Ok(x) +LL | | } else { +... | +LL | | }) +LL | | .flatten(); + | |__________________^ + | +help: try replacing `map` with `and_then` and remove the `.flatten()` + | +LL ~ .and_then(|x| { +LL + if x == 1 { +LL + Ok(x) +LL + } else { +LL + Err(0) +LL + } +LL ~ }); + | + +error: called `map(..).flatten()` on `Result` + --> $DIR/map_flatten.rs:30:10 + | +LL | .map(|res| { + | __________^ +LL | | if res > 0 { +LL | | do_something(); +LL | | Ok(res) +... | +LL | | }) +LL | | .flatten(); + | |__________________^ + | +help: try replacing `map` with `and_then` and remove the `.flatten()` + | +LL ~ .and_then(|res| { +LL + if res > 0 { +LL + do_something(); +LL + Ok(res) +LL + } else { +LL + Err(0) +LL + } +LL ~ }); + | + +error: called `map(..).flatten()` on `Iterator` + --> $DIR/map_flatten.rs:42:10 + | +LL | .map(|some_value| { + | __________^ +LL | | if some_value > 3 { +LL | | Some(some_value) +LL | | } else { +... | +LL | | }) +LL | | .flatten() + | |__________________^ + | +help: try replacing `map` with `filter_map` and remove the `.flatten()` + | +LL ~ .filter_map(|some_value| { +LL + if some_value > 3 { +LL + Some(some_value) +LL + } else { +LL + None +LL + } +LL + }) + | + +error: aborting due to 4 previous errors + |