@@ -6,8 +6,9 @@ use super::diagnostics::{
66 InvalidComparisonOperatorSub , InvalidLogicalOperator , InvalidLogicalOperatorSub ,
77 LeftArrowOperator , LifetimeInBorrowExpression , MacroInvocationWithQualifiedPath ,
88 MalformedLoopLabel , MissingInInForLoop , MissingInInForLoopSub , MissingSemicolonBeforeArray ,
9- NotAsNegationOperator , OuterAttributeNotAllowedOnIfElse , RequireColonAfterLabeledExpression ,
10- SnapshotParser , TildeAsUnaryOperator , UnexpectedTokenAfterLabel ,
9+ NotAsNegationOperator , NotAsNegationOperatorSub , OuterAttributeNotAllowedOnIfElse ,
10+ RequireColonAfterLabeledExpression , SnapshotParser , TildeAsUnaryOperator ,
11+ UnexpectedTokenAfterLabel ,
1112} ;
1213use super :: pat:: { CommaRecoveryMode , RecoverColon , RecoverComma , PARAM_EXPECTED } ;
1314use super :: ty:: { AllowPlus , RecoverQPath , RecoverReturnSign } ;
@@ -660,21 +661,23 @@ impl<'a> Parser<'a> {
660661 fn recover_not_expr ( & mut self , lo : Span ) -> PResult < ' a , ( Span , ExprKind ) > {
661662 // Emit the error...
662663 let negated_token = self . look_ahead ( 1 , |t| t. clone ( ) ) ;
663- let negtated_msg = if negated_token. is_numeric_lit ( ) {
664- "bitwise not"
664+
665+ let sub_diag = if negated_token. is_numeric_lit ( ) {
666+ NotAsNegationOperatorSub :: SuggestNotBitwise
665667 } else if negated_token. is_bool_lit ( ) {
666- "logical negation"
668+ NotAsNegationOperatorSub :: SuggestNotLogical
667669 } else {
668- "logical negation or bitwise not"
670+ NotAsNegationOperatorSub :: SuggestNotDefault
669671 } ;
670672
671673 self . sess . emit_err ( NotAsNegationOperator {
672674 negated : negated_token. span ,
673675 negated_desc : super :: token_descr ( & negated_token) ,
674- negated_msg : negtated_msg. to_string ( ) ,
675676 // Span the `not` plus trailing whitespace to avoid
676677 // trailing whitespace after the `!` in our suggestion
677- not : self . sess . source_map ( ) . span_until_non_whitespace ( lo. to ( negated_token. span ) ) ,
678+ sub : sub_diag (
679+ self . sess . source_map ( ) . span_until_non_whitespace ( lo. to ( negated_token. span ) ) ,
680+ ) ,
678681 } ) ;
679682
680683 // ...and recover!
0 commit comments