Skip to content

Commit e733b76

Browse files
dtenJayflux
authored andcommitted
impl trait / yield syntax (#204)
* equals is valid in generic definitions * test path should match package name folder needs to be Rust Enahanced or other things don't work (like default settings) * yield and impl trait
1 parent a903f86 commit e733b76

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

RustEnhanced.sublime-syntax

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ contexts:
124124
- match: \b(crate|extern|use|where)\b
125125
scope: keyword.other.rust
126126

127-
- match: \b(break|else|for|if|loop|match|while|continue)\b
127+
- match: \b(break|else|for|if|loop|match|while|continue|yield)\b
128128
scope: keyword.control.rust
129129

130130
- match: \breturn\b
@@ -298,6 +298,13 @@ contexts:
298298
scope: support.type.rust
299299

300300
return-type:
301+
- match: '\bimpl\b'
302+
scope: storage.type.impl.rust
303+
push:
304+
- include: comments
305+
- include: impl-generic
306+
- match: '(?=\S)'
307+
pop: true
301308
- match: '->'
302309
scope: punctuation.separator.rust
303310
push:
@@ -417,7 +424,7 @@ contexts:
417424
- match: '{{identifier}}'
418425
- match: ':|,'
419426
scope: punctuation.separator.rust
420-
- match: '\+|\bas\b'
427+
- match: '\+|\bas\b|='
421428
scope: keyword.operator.rust
422429
- match: '\S'
423430
scope: invalid.illegal.rust

syntax_test_rust.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SYNTAX TEST "Packages/sublime-rust/RustEnhanced.sublime-syntax"
1+
// SYNTAX TEST "Packages/Rust Enhanced/RustEnhanced.sublime-syntax"
22

33
// Line comments
44
// <- comment.line.double-slash
@@ -1051,3 +1051,18 @@ impl<T> From<AsRef<T>> for CliError<T> { }
10511051
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.impl
10521052
// ^^^^^^^^ entity.name.impl
10531053
// ^^^ meta.generic
1054+
1055+
fn legal_dates_iter() -> Box<Iterator<Item = Date<UTC>>> {
1056+
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.return-type meta.generic
1057+
// ^ keyword.operator
1058+
unimplemented!()
1059+
}
1060+
1061+
fn numbers() -> impl Iterator<Item = u64> {
1062+
// ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.return-type
1063+
// ^^^^ meta.function.return-type storage.type.impl
1064+
// ^^^^^^^^ meta.function.return-type support.type
1065+
// ^^^^^^^^^^^^ meta.function.return-type meta.generic
1066+
Generator(move || for a in (0..10) { yield a; } })
1067+
// ^^^^^ keyword.control
1068+
}

0 commit comments

Comments
 (0)