@@ -350,3 +350,97 @@ fn factory() -> Box<Fn(i32) -> i32> {
350
350
// ^^^ storage.type
351
351
Box :: new ( |x| x + 1 )
352
352
}
353
+
354
+ // Const generics.
355
+ trait Foo < const N : usize > {
356
+ // ^^^^^^^^^^^^^^^^ meta.trait meta.generic
357
+ // ^ punctuation.definition.generic.begin
358
+ // ^^^^^ storage.modifier
359
+ // ^ meta.trait meta.generic punctuation.separator
360
+ // ^^^^^ storage.type
361
+ // ^ punctuation.definition.generic.end
362
+ fn method < const M : usize > ( & mut self , arr : [ [ u8 ; M ] ; N ] ) ;
363
+ // ^^^^^^^^^^^^^^^^ meta.generic
364
+ // ^ punctuation.definition.generic.begin
365
+ // ^^^^^ storage.modifier
366
+ // ^ punctuation.separator
367
+ // ^^^^^ storage.type
368
+ // ^ punctuation.definition.generic.end
369
+ }
370
+
371
+ struct Bar < T , const N : usize > {
372
+ // ^^^^^^^^^^^^^^^^^^^ meta.struct meta.generic
373
+ // ^ punctuation.definition.generic.begin
374
+ // ^ punctuation.separator
375
+ // ^^^^^ storage.modifier
376
+ // ^ punctuation.separator
377
+ // ^^^^^ storage.type
378
+ // ^ punctuation.definition.generic.end
379
+ inner : [ T ; N ] ,
380
+ }
381
+
382
+ impl < const N : usize > Foo < N > for Bar < u8 , N > {
383
+ // ^^^^^^^^^^^^^^^^ meta.impl meta.generic
384
+ // ^ punctuation.definition.generic.begin
385
+ // ^^^^^ storage.modifier
386
+ // ^ punctuation.separator
387
+ // ^^^^^ storage.type
388
+ // ^ punctuation.definition.generic.end
389
+ fn method < const M : usize > ( & mut self , arr : [ [ u8 ; M ] ; N ] ) { }
390
+ }
391
+
392
+ struct Bool < const N : bool > ;
393
+ // ^^^^^^^^^^^^^^^ meta.struct meta.generic
394
+ // ^ punctuation.definition.generic.begin
395
+ // ^^^^^ storage.modifier
396
+ // ^ punctuation.separator
397
+ // ^^^^ storage.type
398
+ // ^ punctuation.definition.generic.end
399
+ struct Char < const N : char > ;
400
+ struct Int < const N : i32 > ;
401
+ struct Byte < const N : u8 > ;
402
+
403
+ fn function < const N : u16 > ( ) {
404
+ const fn foo ( x : bool ) -> usize { 2 }
405
+ let x: Bar < i32 , 1 > = Bar { inner : [ 1 ; 1 ] } ;
406
+ // ^^^^^^^^ meta.function meta.block meta.generic
407
+ // ^ meta.function meta.block meta.generic punctuation.definition.generic.begin
408
+ // ^^^ meta.function meta.block meta.generic storage.type
409
+ // ^ meta.function meta.block meta.generic punctuation.separator
410
+ // ^ meta.function meta.block meta.generic constant.numeric.integer.decimal
411
+ // ^ meta.function meta.block meta.generic punctuation.definition.generic.end
412
+ let y: Bar < i32 , { foo ( 1 > 2 ) / 2 } > = Bar { inner : [ 1 ; 1 ] } ;
413
+ // ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function meta.block meta.generic
414
+ // ^ punctuation.definition.generic.begin
415
+ // ^^^^^^^^^^^^^^^^^^ meta.block
416
+ // ^^^ support.function
417
+ // ^ meta.group punctuation.section.group.begin
418
+ // ^ keyword.operator.comparison
419
+ // ^ punctuation.section.group.end
420
+ // ^ keyword.operator.arithmetic
421
+ // ^ constant.numeric.integer.decimal
422
+ // ^ punctuation.section.block.end
423
+ // ^ punctuation.definition.generic.end
424
+ let b: Bool < true > ;
425
+ // ^^^^ meta.function meta.block meta.generic constant.language
426
+ let c: Char < '∂' > ;
427
+ // ^^^ meta.function meta.block meta.generic string.quoted.single
428
+ // ^ punctuation.definition.string.begin
429
+ // ^ punctuation.definition.string.end
430
+ let i: Int < -1 > ;
431
+ // ^^^^ meta.function meta.block meta.generic
432
+ // ^ keyword.operator.arithmetic
433
+ // ^ constant.numeric.integer.decimal
434
+ let i: Int < 0b1011 > ;
435
+ // ^^^^^^ meta.function meta.block meta.generic constant.numeric.integer.binary
436
+ let i: Int < 4i32 > ;
437
+ // ^^^^^^ meta.function meta.block meta.generic
438
+ // ^ constant.numeric.integer.decimal
439
+ // ^^^ storage.type.numeric
440
+ let b: Byte < b'a' > ;
441
+ // ^^^^^^ meta.function meta.block meta.generic
442
+ // ^^^^ string.quoted.single.rust
443
+ // ^ storage.type.string
444
+ // ^ punctuation.definition.string.begin
445
+ // ^ punctuation.definition.string.end
446
+ }
0 commit comments