diff options
Diffstat (limited to 'tests/ui/consts/control-flow/try.rs')
-rw-r--r-- | tests/ui/consts/control-flow/try.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/ui/consts/control-flow/try.rs b/tests/ui/consts/control-flow/try.rs new file mode 100644 index 000000000..7d85a412b --- /dev/null +++ b/tests/ui/consts/control-flow/try.rs @@ -0,0 +1,10 @@ +// The `?` operator is still not const-evaluatable because it calls `From::from` on the error +// variant. + +const fn opt() -> Option<i32> { + let x = Some(2); + x?; //~ ERROR `?` is not allowed in a `const fn` + None +} + +fn main() {} |