Skip to content

Diagnostic about try could be better on edition 2018 #54774

Closed
@Centril

Description

@Centril

Given:

fn main() -> Result<(), ()> {
    let x = try!(Ok(1u8));
    Ok(())
}

the compiler emits the standard "reserved keyword error":

error: expected expression, found reserved keyword `try`
 --> src/main.rs:2:13
  |
2 |     let x = try!(Ok(1u8));
  |             ^^^ expected expression

However, since try! was once a macro people used (wherefore it stands to reason that some old documentation may folk astray), it might be prudent to catch this pattern somehow and refer the user to the documentation about ? somewhere.

cc @scottmcm, @estebank

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-frontendArea: Compiler frontend (errors, parsing and HIR)C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions