about summary refs log tree commit diff
path: root/src/libcore/ops
diff options
context:
space:
mode:
authorAriel Ben-Yehuda <ariel.byd@gmail.com>2017-08-31 22:52:49 +0300
committerAriel Ben-Yehuda <ariel.byd@gmail.com>2017-09-03 13:10:54 +0300
commit291b4eddcefd1d6da1010f8a1f02f05338a44050 (patch)
treeba9a44f1e16425d7984a1e32bade04a6f23c3323 /src/libcore/ops
parentefa09ea554575cd0b4ce01ada44fce730c0f7ac4 (diff)
downloadrust-291b4eddcefd1d6da1010f8a1f02f05338a44050.tar.gz
rust-291b4eddcefd1d6da1010f8a1f02f05338a44050.zip
add error message for the other case too
Diffstat (limited to 'src/libcore/ops')
-rw-r--r--src/libcore/ops/try.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libcore/ops/try.rs b/src/libcore/ops/try.rs
index 28e84d2fba6..e788b66a1ec 100644
--- a/src/libcore/ops/try.rs
+++ b/src/libcore/ops/try.rs
@@ -27,7 +27,12 @@
                   message="the `?` operator can only be used in a \
                            function that returns `Result` \
                            (or another type that implements `{Try}`)",
-                  label="cannot use the `?` operator in a function that returns `{Self}`")))]
+                  label="cannot use the `?` operator in a function that returns `{Self}`"),
+               on(all(from_method="into_result", from_desugaring="?"),
+                  message="the `?` operator can only be applied to values \
+                           that implement `{Try}`",
+                  label="the `?` operator cannot be applied to type `{Self}`")
+))]
 pub trait Try {
     /// The type of this value when viewed as successful.
     #[unstable(feature = "try_trait", issue = "42327")]