Skip to content

Commit 300282c

Browse files
committed
fix fmt
1 parent cd57816 commit 300282c

File tree

4 files changed

+16
-19
lines changed

4 files changed

+16
-19
lines changed

clippy_lints/src/methods/option_map_or_none.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ use rustc_span::symbol::sym;
1111
use super::OPTION_MAP_OR_NONE;
1212
use super::RESULT_MAP_OR_INTO_OPTION;
1313

14-
/// The expression inside a closure may or may not have surrounding braces
14+
// The expression inside a closure may or may not have surrounding braces
15+
// which causes problems when generating a suggestion.
1516
fn reduce_unit_expression<'a>(
1617
cx: &LateContext<'_>,
1718
expr: &'a hir::Expr<'_>,

tests/ui/option_map_or_none.fixed

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@
44

55
fn main() {
66
let opt = Some(1);
7-
let bar = |_| {
8-
Some(1)
9-
};
7+
let bar = |_| Some(1);
108

119
// Check `OPTION_MAP_OR_NONE`.
1210
// Single line case.
13-
let _ :Option<i32> = opt.map(|x| x + 1);
11+
let _: Option<i32> = opt.map(|x| x + 1);
1412
// Multi-line case.
1513
#[rustfmt::skip]
16-
let _ :Option<i32> = opt.map(|x| x + 1);
14+
let _: Option<i32> = opt.map(|x| x + 1);
1715
// function returning `Option`
18-
let _ :Option<i32> = opt.and_then(bar);
16+
let _: Option<i32> = opt.and_then(bar);
1917
}

tests/ui/option_map_or_none.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@
44

55
fn main() {
66
let opt = Some(1);
7-
let bar = |_| {
8-
Some(1)
9-
};
7+
let bar = |_| Some(1);
108

119
// Check `OPTION_MAP_OR_NONE`.
1210
// Single line case.
13-
let _ :Option<i32> = opt.map_or(None, |x| Some(x + 1));
11+
let _: Option<i32> = opt.map_or(None, |x| Some(x + 1));
1412
// Multi-line case.
1513
#[rustfmt::skip]
16-
let _ :Option<i32> = opt.map_or(None, |x| {
14+
let _: Option<i32> = opt.map_or(None, |x| {
1715
Some(x + 1)
1816
});
1917
// function returning `Option`
20-
let _ :Option<i32> = opt.map_or(None, bar);
18+
let _: Option<i32> = opt.map_or(None, bar);
2119
}

tests/ui/option_map_or_none.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
error: called `map_or(None, ..)` on an `Option` value. This can be done more directly by calling `map(..)` instead
2-
--> $DIR/option_map_or_none.rs:13:26
2+
--> $DIR/option_map_or_none.rs:11:26
33
|
4-
LL | let _ :Option<i32> = opt.map_or(None, |x| Some(x + 1));
4+
LL | let _: Option<i32> = opt.map_or(None, |x| Some(x + 1));
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `map` instead: `opt.map(|x| x + 1)`
66
|
77
= note: `-D clippy::option-map-or-none` implied by `-D warnings`
88

99
error: called `map_or(None, ..)` on an `Option` value. This can be done more directly by calling `map(..)` instead
10-
--> $DIR/option_map_or_none.rs:16:26
10+
--> $DIR/option_map_or_none.rs:14:26
1111
|
12-
LL | let _ :Option<i32> = opt.map_or(None, |x| {
12+
LL | let _: Option<i32> = opt.map_or(None, |x| {
1313
| __________________________^
1414
LL | | Some(x + 1)
1515
LL | | });
1616
| |_________________________^ help: try using `map` instead: `opt.map(|x| x + 1)`
1717

1818
error: called `map_or(None, ..)` on an `Option` value. This can be done more directly by calling `and_then(..)` instead
19-
--> $DIR/option_map_or_none.rs:20:26
19+
--> $DIR/option_map_or_none.rs:18:26
2020
|
21-
LL | let _ :Option<i32> = opt.map_or(None, bar);
21+
LL | let _: Option<i32> = opt.map_or(None, bar);
2222
| ^^^^^^^^^^^^^^^^^^^^^ help: try using `and_then` instead: `opt.and_then(bar)`
2323

2424
error: aborting due to 3 previous errors

0 commit comments

Comments
 (0)