Skip to content

Commit 654faff

Browse files
committed
Add use bounds
1 parent e8999c1 commit 654faff

File tree

2 files changed

+32
-12
lines changed

2 files changed

+32
-12
lines changed

RustEnhanced.sublime-syntax

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -364,13 +364,6 @@ contexts:
364364
scope: support.type.rust
365365

366366
return-type:
367-
- match: '\bimpl\b'
368-
scope: storage.type.impl.rust
369-
push:
370-
- include: comments
371-
- include: impl-generic
372-
- match: '(?=\S)'
373-
pop: true
374367
- match: '->'
375368
scope: punctuation.separator.rust
376369
push:
@@ -578,6 +571,31 @@ contexts:
578571
- match: '[-+%/*]'
579572
scope: keyword.operator.arithmetic.rust
580573

574+
impl-trait:
575+
- match: '\bimpl\b'
576+
scope: storage.type.impl.rust
577+
push:
578+
- match: '\buse\b'
579+
scope: keyword.other.rust
580+
push:
581+
- match: '<'
582+
scope: punctuation.definition.generic.begin.rust
583+
set:
584+
- match: '>'
585+
scope: punctuation.definition.generic.end.rust
586+
pop: true
587+
- include: lifetime
588+
- match: ','
589+
scope: punctuation.separator.rust
590+
- match: \b(Self)\b
591+
scope: keyword.other.rust
592+
- match: '{{identifier}}'
593+
- match: '(?=\S)'
594+
pop: true
595+
- include: type-any-identifier
596+
- match: '(?=\S)'
597+
pop: true
598+
581599
type-any-identifier:
582600
- include: comments
583601
- include: support-type
@@ -604,6 +622,7 @@ contexts:
604622
pop: true
605623
- include: type-any-identifier
606624
- include: lifetime
625+
- include: impl-trait
607626
- match: '\b([[:upper:]]|_*[[:upper:]][[:alnum:]_]*[[:lower:]][[:alnum:]_]*)\b(::)'
608627
scope: meta.path.rust storage.type.rust
609628
captures:

tests/syntax-rust/syntax_test_generics.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -461,19 +461,20 @@ fn impl_trait_return_use_bound<'a>() -> impl for<'b> Trait1<Item = impl Trait2<'
461461
// ^^ storage.modifier.lifetime
462462
// ^ punctuation.definition.generic.end
463463
// ^ keyword.operator
464-
// ^^^^^^^ meta.generic meta.generic
464+
// ^^^^^^^^ meta.generic
465+
// ^^^ keyword.other
465466
// ^ punctuation.definition.generic.begin
466467
// ^^ storage.modifier.lifetime
467-
// ^ punctuation.definition.generic.end
468-
// ^ punctuation.definition.generic.end
468+
// ^^ punctuation.definition.generic.end
469469

470470
fn impl_trait_use<'a, foo>() -> impl Trait1 + use<'a, Self, foo> {}
471471
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function meta.function.return-type
472-
// ^^^^^^^^^^^^^^^^^^ meta.generic
472+
// ^ keyword.operator
473+
// ^^^ keyword.other
473474
// ^ punctuation.definition.generic.begin
474475
// ^^ storage.modifier.lifetime
475476
// ^ punctuation.separator
476-
// ^^^^ storage.type
477+
// ^^^^ keyword.other
477478
// ^ punctuation.separator
478479
// ^ punctuation.definition.generic.end
479480

0 commit comments

Comments
 (0)