diff options
Diffstat (limited to 'src/tools/clippy/tests/ui/option_map_or_none.stderr')
-rw-r--r-- | src/tools/clippy/tests/ui/option_map_or_none.stderr | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/option_map_or_none.stderr b/src/tools/clippy/tests/ui/option_map_or_none.stderr new file mode 100644 index 000000000..7befcb890 --- /dev/null +++ b/src/tools/clippy/tests/ui/option_map_or_none.stderr @@ -0,0 +1,53 @@ +error: called `map_or(None, ..)` on an `Option` value. This can be done more directly by calling `map(..)` instead + --> $DIR/option_map_or_none.rs:12:26 + | +LL | let _: Option<i32> = opt.map_or(None, |x| Some(x + 1)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `map` instead: `opt.map(|x| x + 1)` + | + = note: `-D clippy::option-map-or-none` implied by `-D warnings` + +error: called `map_or(None, ..)` on an `Option` value. This can be done more directly by calling `map(..)` instead + --> $DIR/option_map_or_none.rs:15:26 + | +LL | let _: Option<i32> = opt.map_or(None, |x| { + | __________________________^ +LL | | Some(x + 1) +LL | | }); + | |_________________________^ help: try using `map` instead: `opt.map(|x| x + 1)` + +error: called `map_or(None, ..)` on an `Option` value. This can be done more directly by calling `and_then(..)` instead + --> $DIR/option_map_or_none.rs:19:26 + | +LL | let _: Option<i32> = opt.map_or(None, bar); + | ^^^^^^^^^^^^^^^^^^^^^ help: try using `and_then` instead: `opt.and_then(bar)` + +error: called `map_or(None, ..)` on an `Option` value. This can be done more directly by calling `and_then(..)` instead + --> $DIR/option_map_or_none.rs:20:26 + | +LL | let _: Option<i32> = opt.map_or(None, |x| { + | __________________________^ +LL | | let offset = 0; +LL | | let height = x; +LL | | Some(offset + height) +LL | | }); + | |______^ + | +help: try using `and_then` instead + | +LL ~ let _: Option<i32> = opt.and_then(|x| { +LL + let offset = 0; +LL + let height = x; +LL + Some(offset + height) +LL ~ }); + | + +error: called `map_or(None, Some)` on a `Result` value. This can be done more directly by calling `ok()` instead + --> $DIR/option_map_or_none.rs:27:26 + | +LL | let _: Option<i32> = r.map_or(None, Some); + | ^^^^^^^^^^^^^^^^^^^^ help: try using `ok` instead: `r.ok()` + | + = note: `-D clippy::result-map-or-into-option` implied by `-D warnings` + +error: aborting due to 5 previous errors + |