Skip to content

Commit d65dfb9

Browse files
committed
Add use bounds
1 parent 35723d0 commit d65dfb9

File tree

2 files changed

+31
-13
lines changed

2 files changed

+31
-13
lines changed

Rust/Rust.sublime-syntax

+26-10
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,6 @@ contexts:
564564
types:
565565
# matches stray identifiers as a types because a type is expected
566566
- include: comments
567-
- include: impl-types
568567
- include: return-type
569568
- match: '&'
570569
scope: keyword.operator.rust
@@ -590,6 +589,7 @@ contexts:
590589
- include: pattern-param
591590
- include: dyn-types
592591
- include: lifetime
592+
- include: impl-trait
593593
- match: (?={{identifier}}::)
594594
push: type-path
595595
- match: (?=::)
@@ -710,15 +710,6 @@ contexts:
710710
- match: '\b(?:r#)?_*{{type_identifier}}'
711711
scope: storage.type.rust
712712

713-
impl-types:
714-
- match: '\bimpl\b'
715-
scope: storage.type.impl.rust
716-
push:
717-
- include: comments
718-
- include: impl-generic
719-
- match: '(?=\S)'
720-
pop: true
721-
722713
dyn-types:
723714
- match: '\bdyn\b(?=\s*(?:\(|{{lifetime}}|{{identifier}}))'
724715
scope: storage.type.trait.rust
@@ -803,6 +794,31 @@ contexts:
803794
- match: '[-+%/*]'
804795
scope: keyword.operator.arithmetic.rust
805796

797+
impl-trait:
798+
- match: '\bimpl\b'
799+
scope: storage.type.impl.rust
800+
push:
801+
- match: '\buse\b'
802+
scope: keyword.other.rust
803+
push:
804+
- match: '<'
805+
scope: punctuation.definition.generic.begin.rust
806+
set:
807+
- match: '>'
808+
scope: punctuation.definition.generic.end.rust
809+
pop: true
810+
- include: lifetime
811+
- match: ','
812+
scope: punctuation.separator.rust
813+
- match: \b(Self)\b
814+
scope: keyword.other.rust
815+
- match: '{{identifier}}'
816+
- match: '(?=\S)'
817+
pop: true
818+
- include: types
819+
- match: '(?=\S)'
820+
pop: true
821+
806822
##[ STRUCTS ]###############################################################
807823

808824
struct-identifier:

Rust/tests/syntax_test_generics.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -464,19 +464,21 @@ fn impl_trait_return_use_bound<'a>() -> impl for<'b> Trait1<Item = impl Trait2<'
464464
// ^^ storage.modifier.lifetime
465465
// ^ punctuation.definition.generic.end
466466
// ^ keyword.operator
467-
// ^^^^ meta.generic meta.generic
467+
// ^^^ keyword.other
468+
// ^^^^ meta.generic
468469
// ^ punctuation.definition.generic.begin
469470
// ^^ storage.modifier.lifetime
470471
// ^ punctuation.definition.generic.end
471472
// ^ punctuation.definition.generic.end
472473

473474
fn impl_trait_use<'a, foo>() -> impl Trait1 + use<'a, Self, foo> {}
474475
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function meta.function.return-type
475-
// ^^^^^^^^^^^^^^^ meta.generic
476+
// ^ keyword.operator
477+
// ^^^ keyword.other
476478
// ^ punctuation.definition.generic.begin
477479
// ^^ storage.modifier.lifetime
478480
// ^ punctuation.separator
479-
// ^^^^ storage.type
481+
// ^^^^ keyword.other
480482
// ^ punctuation.separator
481483
// ^ punctuation.definition.generic.end
482484

0 commit comments

Comments
 (0)