diff options
| author | bors <bors@rust-lang.org> | 2018-09-16 15:42:02 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-09-16 15:42:02 +0000 |
| commit | d3cba9b4b4959d63eaaf5ffd647e4a5fc6d43e17 (patch) | |
| tree | 40497aff8f7d707791844dd498118d20653e0779 /src/libsyntax/parse | |
| parent | 32dc5a0783560c97f3c42dafad25dcee9cf6d723 (diff) | |
| parent | 8b1e5e1f01d0250b7bfd843b2035c3fbf7fbafd5 (diff) | |
| download | rust-d3cba9b4b4959d63eaaf5ffd647e4a5fc6d43e17.tar.gz rust-d3cba9b4b4959d63eaaf5ffd647e4a5fc6d43e17.zip | |
Auto merge of #54270 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 5 pull requests
Successful merges:
- #53941 (rustdoc: Sort implementors)
- #54181 (Suggest && and || instead of 'and' and 'or')
- #54209 (Partially revert 674a5db "Fix undesirable fallout [from macro modularization]")
- #54213 (De-overlap the lifetimes of `flow_inits` and `flow_{un,ever_}inits`.)
- #54244 (Add a small search box to seach Rust's standary library)
Failed merges:
r? @ghost
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index f57fca2cfcf..48e034b117f 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -732,6 +732,22 @@ impl<'a> Parser<'a> { format!("expected {} here", expect))) }; let mut err = self.fatal(&msg_exp); + if self.token.is_ident_named("and") { + err.span_suggestion_short_with_applicability( + self.span, + "use `&&` instead of `and` for the boolean operator", + "&&".to_string(), + Applicability::MaybeIncorrect, + ); + } + if self.token.is_ident_named("or") { + err.span_suggestion_short_with_applicability( + self.span, + "use `||` instead of `or` for the boolean operator", + "||".to_string(), + Applicability::MaybeIncorrect, + ); + } let sp = if self.token == token::Token::Eof { // This is EOF, don't want to point at the following char, but rather the last token self.prev_span @@ -4751,6 +4767,23 @@ impl<'a> Parser<'a> { e.span_label(sp, "expected `{`"); } + if self.token.is_ident_named("and") { + e.span_suggestion_short_with_applicability( + self.span, + "use `&&` instead of `and` for the boolean operator", + "&&".to_string(), + Applicability::MaybeIncorrect, + ); + } + if self.token.is_ident_named("or") { + e.span_suggestion_short_with_applicability( + self.span, + "use `||` instead of `or` for the boolean operator", + "||".to_string(), + Applicability::MaybeIncorrect, + ); + } + // Check to see if the user has written something like // // if (cond) |
