diff options
| author | Vitaly _Vi Shukela <vi0oss@gmail.com> | 2018-09-13 20:40:39 +0300 |
|---|---|---|
| committer | Vitaly _Vi Shukela <vi0oss@gmail.com> | 2018-09-13 20:44:07 +0300 |
| commit | acc44e40ccd860a3cae54c7b56956c3c1340182e (patch) | |
| tree | 7e451b9215ed2934e5b74f6af7473e550cf3c8c2 /src/libsyntax/parse/parser.rs | |
| parent | 888b8c9451a41cccc8bdceee6423ee9d9e66bb43 (diff) | |
| download | rust-acc44e40ccd860a3cae54c7b56956c3c1340182e.tar.gz rust-acc44e40ccd860a3cae54c7b56956c3c1340182e.zip | |
Use span_suggestion_with_applicability for "and/or" hinter
Advised by @estebank.
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index a28157106ba..429d1b6bf5e 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -733,10 +733,20 @@ impl<'a> Parser<'a> { }; let mut err = self.fatal(&msg_exp); if self.token.is_ident_named("and") { - err.help("Use `&&` instead of `and` for the boolean operator"); + err.span_suggestion_with_applicability( + self.span, + "use `&&` instead of `and` for the boolean operator", + "&&".to_string(), + Applicability::MaybeIncorrect, + ); } if self.token.is_ident_named("or") { - err.help("Use `||` instead of `or` for the boolean operator"); + err.span_suggestion_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 @@ -4758,10 +4768,20 @@ impl<'a> Parser<'a> { } if self.token.is_ident_named("and") { - e.help("Use `&&` instead of `and` for the boolean operator"); + e.span_suggestion_with_applicability( + self.span, + "use `&&` instead of `and` for the boolean operator", + "&&".to_string(), + Applicability::MaybeIncorrect, + ); } if self.token.is_ident_named("or") { - e.help("Use `||` instead of `or` for the boolean operator"); + e.span_suggestion_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 |
