about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorAriel Ben-Yehuda <ariel.byd@gmail.com>2017-08-31 21:46:03 +0300
committerAriel Ben-Yehuda <ariel.byd@gmail.com>2017-09-03 13:10:54 +0300
commitefa09ea554575cd0b4ce01ada44fce730c0f7ac4 (patch)
tree896816568ac690f302bad2440a353a0f13eb91ad /src/test
parent6dec953c5ad7357a9f2d90626e56bc0dc30127a9 (diff)
downloadrust-efa09ea554575cd0b4ce01ada44fce730c0f7ac4.tar.gz
rust-efa09ea554575cd0b4ce01ada44fce730c0f7ac4.zip
on_unimplemented: add method-name checks and use them in Try
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/suggestions/try-operator-on-main.rs14
-rw-r--r--src/test/ui/suggestions/try-operator-on-main.stderr32
2 files changed, 40 insertions, 6 deletions
diff --git a/src/test/ui/suggestions/try-operator-on-main.rs b/src/test/ui/suggestions/try-operator-on-main.rs
index d81f773442c..473efea54de 100644
--- a/src/test/ui/suggestions/try-operator-on-main.rs
+++ b/src/test/ui/suggestions/try-operator-on-main.rs
@@ -13,9 +13,21 @@
 use std::ops::Try;
 
 fn main() {
+    // error for a `Try` type on a non-`Try` fn
     std::fs::File::open("foo")?;
 
+    // a non-`Try` type on a `Try` fn
+    ()?;
+
+    // an unrelated use of `Try`
     try_trait_generic::<()>();
 }
 
-fn try_trait_generic<T: Try>() {}
+
+
+fn try_trait_generic<T: Try>() -> T {
+    // and a non-`Try` object on a `Try` fn.
+    ()?;
+
+    loop {}
+}
diff --git a/src/test/ui/suggestions/try-operator-on-main.stderr b/src/test/ui/suggestions/try-operator-on-main.stderr
index 0d3e67e99a8..5fc24e46fa7 100644
--- a/src/test/ui/suggestions/try-operator-on-main.stderr
+++ b/src/test/ui/suggestions/try-operator-on-main.stderr
@@ -1,7 +1,7 @@
 error[E0277]: the `?` operator can only be used in a function that returns `Result` (or another type that implements `std::ops::Try`)
-  --> $DIR/try-operator-on-main.rs:16:5
+  --> $DIR/try-operator-on-main.rs:17:5
    |
-16 |     std::fs::File::open("foo")?;
+17 |     std::fs::File::open("foo")?;
    |     ---------------------------
    |     |
    |     cannot use the `?` operator in a function that returns `()`
@@ -11,12 +11,34 @@ error[E0277]: the `?` operator can only be used in a function that returns `Resu
    = note: required by `std::ops::Try::from_error`
 
 error[E0277]: the trait bound `(): std::ops::Try` is not satisfied
-  --> $DIR/try-operator-on-main.rs:18:5
+  --> $DIR/try-operator-on-main.rs:20:5
    |
-18 |     try_trait_generic::<()>();
+20 |     ()?;
+   |     ---
+   |     |
+   |     the trait `std::ops::Try` is not implemented for `()`
+   |     in this macro invocation
+   |
+   = note: required by `std::ops::Try::into_result`
+
+error[E0277]: the trait bound `(): std::ops::Try` is not satisfied
+  --> $DIR/try-operator-on-main.rs:23:5
+   |
+23 |     try_trait_generic::<()>();
    |     ^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::ops::Try` is not implemented for `()`
    |
    = note: required by `try_trait_generic`
 
-error: aborting due to 2 previous errors
+error[E0277]: the trait bound `(): std::ops::Try` is not satisfied
+  --> $DIR/try-operator-on-main.rs:30:5
+   |
+30 |     ()?;
+   |     ---
+   |     |
+   |     the trait `std::ops::Try` is not implemented for `()`
+   |     in this macro invocation
+   |
+   = note: required by `std::ops::Try::into_result`
+
+error: aborting due to 4 previous errors