Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Account for use of
try!()
in 2018 edition and guide users in the ri…
…ght direction
- Loading branch information
Duddino
committed
Apr 17, 2020
1 parent
534a41a
commit ba61fe4
Showing
4 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|