diff options
Diffstat (limited to 'tests/ui/try-trait/option-to-result.rs')
-rw-r--r-- | tests/ui/try-trait/option-to-result.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/ui/try-trait/option-to-result.rs b/tests/ui/try-trait/option-to-result.rs new file mode 100644 index 000000000..45aaf361a --- /dev/null +++ b/tests/ui/try-trait/option-to-result.rs @@ -0,0 +1,13 @@ +fn main(){ } + +fn test_result() -> Result<(),()> { + let a:Option<()> = Some(()); + a?;//~ ERROR the `?` operator can only be used + Ok(()) +} + +fn test_option() -> Option<i32>{ + let a:Result<i32, i32> = Ok(5); + a?;//~ ERROR the `?` operator can only be used + Some(5) +} |