mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 23:24:24 +00:00
Add test
This commit is contained in:
parent
7e2043de2f
commit
b03cf3ff97
1 changed files with 18 additions and 0 deletions
|
@ -268,3 +268,21 @@ fn main() {
|
|||
let opt = Some(0);
|
||||
let _ = opt.unwrap();
|
||||
}
|
||||
|
||||
struct Foo(u8);
|
||||
#[rustfmt::skip]
|
||||
fn test_or_with_ctors() {
|
||||
let opt = Some(1);
|
||||
let opt_opt = Some(Some(1));
|
||||
// we also test for const promotion, this makes sure we don't hit that
|
||||
let two = 2;
|
||||
|
||||
let _ = opt_opt.unwrap_or(Some(2));
|
||||
let _ = opt_opt.unwrap_or(Some(two));
|
||||
let _ = opt.ok_or(Some(2));
|
||||
let _ = opt.ok_or(Some(two));
|
||||
let _ = opt.ok_or(Foo(2));
|
||||
let _ = opt.ok_or(Foo(two));
|
||||
let _ = opt.or(Some(2));
|
||||
let _ = opt.or(Some(two));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue