From acc44e40ccd860a3cae54c7b56956c3c1340182e Mon Sep 17 00:00:00 2001 From: Vitaly _Vi Shukela Date: Thu, 13 Sep 2018 20:40:39 +0300 Subject: Use span_suggestion_with_applicability for "and/or" hinter Advised by @estebank. --- src/libsyntax/parse/parser.rs | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'src/libsyntax/parse') 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 -- cgit 1.4.1-3-g733a5