-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-edition-2018Area: The 2018 editionArea: The 2018 editionA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.A-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-editionDiagnostics: An error or lint that should account for edition differences.Diagnostics: An error or lint that should account for edition differences.D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: Confusing error or lint; hard to understand for new users.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.F-try_blocks`#![feature(try_blocks)]``#![feature(try_blocks)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Old documentation and blogposts will never be updated to not talk about the try
macro. The current output of the following code
fn foo() -> Result<(), ()> {
Ok(try!(Ok(())))
}
is
error: expected expression, found reserved keyword `try`
--> src/main.rs:2:8
|
2 | Ok(try!(Ok(())))
| ^^^ expected expression
It should provide structured suggestions to either use r#try
or ?
:
error: use of deprecated `try` macro
--> src/main.rs:2:8
|
2 | Ok(try!(Ok(())))
| ^^^^^ ^
| |
| deprecated `try` macro
= note: in the 2018 edition `try` is a reserved keyword, and the `try!()` macro is deprecated
help: you can use the `?` operator instead
|
2 | Ok(Ok(())?))
| -- ^
help: alternatively, you can still access the deprecated `try!()` macro using the "raw identifier" syntax
|
2 | Ok(r#try!(Ok(())))
| ^^
This request is similar in spirit to #67204 and feels like a subset of #65148.
This issue has been assigned to @Duddino via this comment.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-edition-2018Area: The 2018 editionArea: The 2018 editionA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.A-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-editionDiagnostics: An error or lint that should account for edition differences.Diagnostics: An error or lint that should account for edition differences.D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: Confusing error or lint; hard to understand for new users.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.F-try_blocks`#![feature(try_blocks)]``#![feature(try_blocks)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.