We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7e2043d commit b03cf3fCopy full SHA for b03cf3f
tests/ui/methods.rs
@@ -268,3 +268,21 @@ fn main() {
268
let opt = Some(0);
269
let _ = opt.unwrap();
270
}
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