@@ -254,9 +254,11 @@ macro_rules! json_internal {
254
254
1 + json_internal!( @object_capacity ( ) ( $( $rest) * ) ( $( $rest) * ) )
255
255
} ;
256
256
257
- // Current entry followed by unexpected token.
257
+ // Current entry followed by unexpected token. The part that parses the values
258
+ // will trigger a reasonable error message; here, we just return 0
259
+ // so that there is not a duplicated error message.
258
260
( @object_capacity entry $unexpected: tt $( $rest: tt) * ) => {
259
- json_unexpected! ( $unexpected )
261
+ 0
260
262
} ;
261
263
262
264
// Insert the last entry without trailing comma.
@@ -299,29 +301,32 @@ macro_rules! json_internal {
299
301
json_internal!( @object_capacity entry)
300
302
} ;
301
303
302
- // Missing value for last entry. Trigger a reasonable error message.
304
+ // Missing value for last entry. The part that parses the values
305
+ // will trigger a reasonable error message; here, we just return 0
306
+ // so that there is not a duplicated error message.
303
307
( @object_capacity ( $( $key: tt) +) ( : ) $copy: tt) => {
304
- // "unexpected end of macro invocation"
305
- json_internal!( )
308
+ 0
306
309
} ;
307
310
308
- // Missing colon and value for last entry. Trigger a reasonable error
309
- // message.
311
+ // Missing colon and value for last entry. The part that parses the values
312
+ // will trigger a reasonable error message; here, we just return 0
313
+ // so that there is not a duplicated error message.
310
314
( @object_capacity ( $( $key: tt) +) ( ) $copy: tt) => {
311
- // "unexpected end of macro invocation"
312
- json_internal!( )
315
+ 0
313
316
} ;
314
317
315
- // Misplaced colon. Trigger a reasonable error message.
318
+ // Misplaced colon. The part that parses the values
319
+ // will trigger a reasonable error message; here, we just return 0
320
+ // so that there is not a duplicated error message.
316
321
( @object_capacity ( ) ( : $( $rest: tt) * ) ( $colon: tt $( $copy: tt) * ) ) => {
317
- // Takes no arguments so "no rules expected the token `:`".
318
- json_unexpected!( $colon)
322
+ 0
319
323
} ;
320
324
321
- // Found a comma inside a key. Trigger a reasonable error message.
325
+ // Found a comma inside a key. The part that parses the values
326
+ // will trigger a reasonable error message; here, we just return 0
327
+ // so that there is not a duplicated error message.
322
328
( @object_capacity ( $( $key: tt) * ) ( , $( $rest: tt) * ) ( $comma: tt $( $copy: tt) * ) ) => {
323
- // Takes no arguments so "no rules expected the token `,`".
324
- json_unexpected!( $comma)
329
+ 0
325
330
} ;
326
331
327
332
// Key is fully parenthesized. This is not necessary for counting capacity
@@ -331,8 +336,10 @@ macro_rules! json_internal {
331
336
// };
332
337
333
338
// Refuse to absorb colon token into key expression.
339
+ // The part that parses the values will trigger a reasonable error message;
340
+ // here, we just return 0 so that there is not a duplicated error message.
334
341
( @object_capacity ( $( $key: tt) * ) ( : $( $unexpected: tt) +) $copy: tt) => {
335
- json_expect_expr_comma! ( $ ( $unexpected ) + )
342
+ 0
336
343
} ;
337
344
338
345
// Munch a token into the current key.
0 commit comments