summaryrefslogtreecommitdiffstats
path: root/src/test/ui/try-trait/option-to-result.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/try-trait/option-to-result.rs')
-rw-r--r--src/test/ui/try-trait/option-to-result.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/test/ui/try-trait/option-to-result.rs b/src/test/ui/try-trait/option-to-result.rs
new file mode 100644
index 000000000..45aaf361a
--- /dev/null
+++ b/src/test/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)
+}