about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-04-17 23:56:04 +0200
committerGitHub <noreply@github.com>2020-04-17 23:56:04 +0200
commit4b9eeca5c55f4064731a963674fa4056a9a50ce5 (patch)
treed763343c30cab7190d2280146cc464515c13cca3 /src/test
parent6a140a31df14b7008c4f4ac5a691b068fc91cbf4 (diff)
parent79abac863e6ef0077d70063518bd34a20f75eae6 (diff)
downloadrust-4b9eeca5c55f4064731a963674fa4056a9a50ce5.tar.gz
rust-4b9eeca5c55f4064731a963674fa4056a9a50ce5.zip
Rollup merge of #71243 - Duddino:Fix2, r=estebank
Account for use of `try!()` in 2018 edition and guide users in the right direction

fixes #71155
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/try-macro-suggestion.rs9
-rw-r--r--src/test/ui/try-macro-suggestion.stderr30
2 files changed, 39 insertions, 0 deletions
diff --git a/src/test/ui/try-macro-suggestion.rs b/src/test/ui/try-macro-suggestion.rs
new file mode 100644
index 00000000000..635ceac0b19
--- /dev/null
+++ b/src/test/ui/try-macro-suggestion.rs
@@ -0,0 +1,9 @@
+// compile-flags: --edition 2018
+fn foo() -> Result<(), ()> {
+    Ok(try!()); //~ ERROR use of deprecated `try` macro
+    Ok(try!(Ok(()))) //~ ERROR use of deprecated `try` macro
+}
+
+fn main() {
+    let _ = foo();
+}
diff --git a/src/test/ui/try-macro-suggestion.stderr b/src/test/ui/try-macro-suggestion.stderr
new file mode 100644
index 00000000000..9d833ef5ed9
--- /dev/null
+++ b/src/test/ui/try-macro-suggestion.stderr
@@ -0,0 +1,30 @@
+error: use of deprecated `try` macro
+  --> $DIR/try-macro-suggestion.rs:3:8
+   |
+LL |     Ok(try!());
+   |        ^^^^^^
+   |
+   = note: in the 2018 edition `try` is a reserved keyword, and the `try!()` macro is deprecated
+help: you can still access the deprecated `try!()` macro using the "raw identifier" syntax
+   |
+LL |     Ok(r#try!());
+   |        ^^
+
+error: use of deprecated `try` macro
+  --> $DIR/try-macro-suggestion.rs:4:8
+   |
+LL |     Ok(try!(Ok(())))
+   |        ^^^^^^^^^^^^
+   |
+   = note: in the 2018 edition `try` is a reserved keyword, and the `try!()` macro is deprecated
+help: you can use the `?` operator instead
+   |
+LL |     Ok(Ok(())?)
+   |       --     ^
+help: alternatively, you can still access the deprecated `try!()` macro using the "raw identifier" syntax
+   |
+LL |     Ok(r#try!(Ok(())))
+   |        ^^
+
+error: aborting due to 2 previous errors
+