@@ -6,8 +6,9 @@ use super::diagnostics::{
6
6
InvalidComparisonOperatorSub , InvalidLogicalOperator , InvalidLogicalOperatorSub ,
7
7
LeftArrowOperator , LifetimeInBorrowExpression , MacroInvocationWithQualifiedPath ,
8
8
MalformedLoopLabel , MissingInInForLoop , MissingInInForLoopSub , MissingSemicolonBeforeArray ,
9
- NotAsNegationOperator , OuterAttributeNotAllowedOnIfElse , RequireColonAfterLabeledExpression ,
10
- SnapshotParser , TildeAsUnaryOperator , UnexpectedTokenAfterLabel ,
9
+ NotAsNegationOperator , NotAsNegationOperatorSub , OuterAttributeNotAllowedOnIfElse ,
10
+ RequireColonAfterLabeledExpression , SnapshotParser , TildeAsUnaryOperator ,
11
+ UnexpectedTokenAfterLabel ,
11
12
} ;
12
13
use super :: pat:: { CommaRecoveryMode , RecoverColon , RecoverComma , PARAM_EXPECTED } ;
13
14
use super :: ty:: { AllowPlus , RecoverQPath , RecoverReturnSign } ;
@@ -660,21 +661,23 @@ impl<'a> Parser<'a> {
660
661
fn recover_not_expr ( & mut self , lo : Span ) -> PResult < ' a , ( Span , ExprKind ) > {
661
662
// Emit the error...
662
663
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
665
667
} else if negated_token. is_bool_lit ( ) {
666
- "logical negation"
668
+ NotAsNegationOperatorSub :: SuggestNotLogical
667
669
} else {
668
- "logical negation or bitwise not"
670
+ NotAsNegationOperatorSub :: SuggestNotDefault
669
671
} ;
670
672
671
673
self . sess . emit_err ( NotAsNegationOperator {
672
674
negated : negated_token. span ,
673
675
negated_desc : super :: token_descr ( & negated_token) ,
674
- negated_msg : negtated_msg. to_string ( ) ,
675
676
// Span the `not` plus trailing whitespace to avoid
676
677
// 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
+ ) ,
678
681
} ) ;
679
682
680
683
// ...and recover!
0 commit comments