Skip to content

Commit fb276dc

Browse files
committed
result_map_or_into_option: add opt.map_or(None, |_| Some(y)) test
1 parent d0738bd commit fb276dc

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

tests/ui/result_map_or_into_option.fixed

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,9 @@ fn main() {
1111
// A non-Some `f` arg should not emit the lint
1212
let opt: Result<u32, &str> = Ok(1);
1313
let _ = opt.map_or(None, rewrap);
14+
15+
// A non-Some `f` closure where the argument is not used as the
16+
// return should not emit the lint
17+
let opt: Result<u32, &str> = Ok(1);
18+
opt.map_or(None, |_x| Some(1));
1419
}

tests/ui/result_map_or_into_option.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,9 @@ fn main() {
1111
// A non-Some `f` arg should not emit the lint
1212
let opt: Result<u32, &str> = Ok(1);
1313
let _ = opt.map_or(None, rewrap);
14+
15+
// A non-Some `f` closure where the argument is not used as the
16+
// return should not emit the lint
17+
let opt: Result<u32, &str> = Ok(1);
18+
opt.map_or(None, |_x| Some(1));
1419
}

0 commit comments

Comments
 (0)