Skip to content

Commit b03cf3f

Browse files
committed
Add test
1 parent 7e2043d commit b03cf3f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/ui/methods.rs

+18
Original file line numberDiff line numberDiff line change
@@ -268,3 +268,21 @@ fn main() {
268268
let opt = Some(0);
269269
let _ = opt.unwrap();
270270
}
271+
272+
struct Foo(u8);
273+
#[rustfmt::skip]
274+
fn test_or_with_ctors() {
275+
let opt = Some(1);
276+
let opt_opt = Some(Some(1));
277+
// we also test for const promotion, this makes sure we don't hit that
278+
let two = 2;
279+
280+
let _ = opt_opt.unwrap_or(Some(2));
281+
let _ = opt_opt.unwrap_or(Some(two));
282+
let _ = opt.ok_or(Some(2));
283+
let _ = opt.ok_or(Some(two));
284+
let _ = opt.ok_or(Foo(2));
285+
let _ = opt.ok_or(Foo(two));
286+
let _ = opt.or(Some(2));
287+
let _ = opt.or(Some(two));
288+
}

0 commit comments

Comments
 (0)