Skip to content

entertaining error message on bad macro syntax #15980

Closed
@dhardy

Description

@dhardy

UPDATE: Mentoring instructions below.


Try compiling this code:

use std::io;

fn main(){
    let x: io::IoResult<()> = Ok(());
    match x {
        Err(ref e) if e.kind == io::EndOfFile {
            return
        }
        _ => {}
    }
}

I (using Rust 0.11.0) get the very misleading message:

$ rustc match_syntax_err.rs
match_syntax_err.rs:7:13: 7:19 error: found `return` in ident position
match_syntax_err.rs:7             return
                                  ^~~~~~
match_syntax_err.rs:8:9: 8:10 error: expected `:` but found `}`
match_syntax_err.rs:8         }

when actually all that's wrong is a missing =>. Not really a good brain teaser on a Friday evening ;)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTC-enhancementCategory: An issue proposing an enhancement or a PR with one.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.WG-diagnosticsWorking group: Diagnostics

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions