Skip to content

Conversation

matklad
Copy link
Contributor

@matklad matklad commented Sep 25, 2019

No description provided.

@rust-highfive
Copy link
Contributor

r? @petrochenkov

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 25, 2019
@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Sep 25, 2019

📌 Commit f60a873 has been approved by petrochenkov

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 25, 2019

/// Generates an appropriate parsing failure message. For EOF, this is "unexpected end...". For
/// other tokens, this is "unexpected token...".
fn parse_failure_msg(tok: &Token) -> String {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not

fn parse_failure_msg(tok: &Token) -> String {
    if let token::Eof = tok.kind {
        return "unexpected end of macro invocation".to_string();
    }
    format!("no rules expected the token `{}`", pprust::token_to_string(tok))
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just haven't looked into the function body at all :-) I think that the best way to format it would probably be

fn parse_failure_msg(tok: &Token) -> String {
    match tok.kind {
        token::Eof => "unexpected end of macro invocation".to_string(),
        _ => format!("no rules expected the token `{}`", pprust::token_to_string(tok)),
    }
}

Not a fan of if let with an else case

Centril added a commit to Centril/rust that referenced this pull request Sep 25, 2019
bors added a commit that referenced this pull request Sep 25, 2019
Rollup of 6 pull requests

Successful merges:

 - #62975 (Almost fully deprecate hir::map::Map.hir_to_node_id)
 - #64386 (use `sign` variable in abs and wrapping_abs methods)
 - #64508 (or-patterns: Push `PatKind/PatternKind::Or` at top level to HIR & HAIR)
 - #64738 (Add const-eval support for SIMD types, insert, and extract)
 - #64759 (Refactor mbe a tiny bit)
 - #64764 (Master is now 1.40 )

Failed merges:

r? @ghost
@bors bors merged commit f60a873 into rust-lang:master Sep 25, 2019
@matklad matklad deleted the simplify-macro branch September 25, 2019 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants