Skip to content

Commit 39ad16a

Browse files
committed
Syntax: Some where improvements.
- Fix "type-any-identifiers" misnamed in fn-where. - Add `[foo]` slice type.
1 parent f653ba3 commit 39ad16a

File tree

2 files changed

+86
-10
lines changed

2 files changed

+86
-10
lines changed

RustEnhanced.sublime-syntax

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -440,13 +440,7 @@ contexts:
440440
- include: strings
441441
- match: '(?=\S)'
442442
pop: true
443-
- match: '\['
444-
scope: punctuation.definition.group.begin.rust
445-
push:
446-
- match: '\]'
447-
scope: punctuation.definition.group.end.rust
448-
pop: true
449-
- include: type-any-identifier
443+
- include: type-slice
450444
- match: '(?=>)'
451445
pop: true
452446
- match: '<'
@@ -507,9 +501,19 @@ contexts:
507501
pop: true
508502
- include: type-any-identifier
509503
- include: type
504+
- include: type-slice
510505
- match: '\b_\b'
511506
scope: keyword.operator.rust
512507

508+
type-slice:
509+
- match: '\['
510+
scope: punctuation.definition.group.begin.rust
511+
push:
512+
- match: '\]'
513+
scope: punctuation.definition.group.end.rust
514+
pop: true
515+
- include: type-any-identifier
516+
513517
struct-identifier:
514518
- match: '{{identifier}}(?=<)'
515519
scope: entity.name.struct.rust
@@ -839,14 +843,14 @@ contexts:
839843
push:
840844
- match: '(?=<)'
841845
push: generic-angles
842-
- include: type-any-identifiers
846+
- include: type-any-identifier
843847
- match: '&'
844848
scope: keyword.operator.rust
845849
- match: '''{{identifier}}(?!\'')\b'
846850
scope: storage.modifier.lifetime.rust
847851
- match: '(?=\S)'
848852
pop: true
849-
- include: type-any-identifiers
853+
- include: type-any-identifier
850854
- match: ':'
851855
scope: punctuation.separator.rust
852856
- match: ';'

syntax_test_rust.rs

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ extern extern crate simd_rng_derive;*/
3232
// This one is just to visually confirm the testing comments don't intefere
3333
#[macro_use]
3434
extern crate std_web;
35-
/*#[macro_use]
35+
/*#[macro_use]
3636
extern extern crate simd_rng_derive;*/
3737

3838
let c = 'c';
@@ -1352,3 +1352,75 @@ impl<A> Thing for &'a mut A {}
13521352
// ^^ meta.impl storage.modifier.lifetime
13531353
// ^^^ meta.impl storage.modifier
13541354
// ^ meta.impl entity.name.impl
1355+
1356+
// Various tests on `where`.
1357+
fn f<'b: 'a>(self) -> &'b mut [i32] where 'a: 'b { }
1358+
// ^^^^^^^^^^^^^^ meta.function meta.function.return-type
1359+
// ^ meta.function meta.function.return-type punctuation.definition.group.begin
1360+
// ^^^ meta.function meta.function.return-type storage.type
1361+
// ^ meta.function meta.function.return-type punctuation.definition.group.end
1362+
// ^^^^^ meta.function meta.where keyword.other
1363+
// ^^ meta.function meta.where storage.modifier.lifetime
1364+
// ^ meta.function meta.where punctuation.separator
1365+
// ^^ meta.function meta.where storage.modifier.lifetime
1366+
// ^ meta.function meta.block punctuation.definition.block.begin
1367+
// ^ meta.function meta.block punctuation.definition.block.end
1368+
1369+
fn f<F>(func: F) -> usize
1370+
// ^^ meta.function meta.function.return-type punctuation.separator
1371+
// ^^^^^ meta.function meta.function.return-type storage.type
1372+
where F: Fn(usize) -> usize {}
1373+
// ^^^^^ meta.function meta.where keyword.other
1374+
// ^^^^^^^^^^^^^^^^^^^^^ meta.function meta.where
1375+
// ^ punctuation.separator
1376+
// ^^ support.type
1377+
// ^ punctuation.definition.type.begin
1378+
// ^^^^^ storage.type
1379+
// ^ punctuation.definition.type.end
1380+
// ^^ meta.function.return-type punctuation.separator
1381+
// ^^^^^ meta.function.return-type storage.type
1382+
// ^ meta.function meta.block punctuation.definition.block.begin
1383+
// ^ meta.function meta.block punctuation.definition.block.end
1384+
1385+
fn f<L, R>(lhs: L, rhs: R)
1386+
where L: IntoIterator<Item=(&'a i32, &'a i32)>,
1387+
// ^^^^^ meta.function meta.where keyword.other
1388+
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function meta.where
1389+
// ^^^^^^^^^^^^ support.type
1390+
// ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.generic
1391+
// ^ punctuation.definition.generic.begin
1392+
// ^ punctuation.definition.type.begin
1393+
// ^ keyword.operator
1394+
// ^^ storage.modifier.lifetime
1395+
// ^^^ storage.type
1396+
// ^ keyword.operator
1397+
// ^^ storage.modifier.lifetime
1398+
// ^^^ storage.type
1399+
// ^ punctuation.definition.type.end
1400+
// ^ punctuation.definition.generic.end
1401+
R: IntoIterator<Item=(&'a i32, &'a i32)>, {}
1402+
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function meta.where
1403+
// ^ meta.function meta.block punctuation.definition.block.begin
1404+
// ^ meta.function meta.block punctuation.definition.block.end
1405+
fn f<F: Fn(usize) -> usize>(func: f) {}
1406+
// ^^^^^^^^^^^^^^^^^^^^^^^ meta.generic
1407+
// ^ meta.generic punctuation.definition.generic.begin
1408+
// ^ meta.generic punctuation.separator
1409+
// ^^ meta.generic support.type
1410+
// ^ meta.generic punctuation.definition.type.begin
1411+
// ^^^^^ meta.generic storage.type
1412+
// ^ meta.generic punctuation.definition.type.end
1413+
// ^^^^^ meta.generic meta.function.return-type storage.type
1414+
// ^ meta.generic punctuation.definition.generic.end
1415+
// ^ meta.function meta.function.parameters punctuation.definition.parameters.begin
1416+
// ^^^^ meta.function meta.function.parameters variable.parameter
1417+
fn f<L: IntoIterator<Item=(&'a i32, &'a i32)>>(lhs: L) {}
1418+
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.generic
1419+
// ^ punctuation.definition.generic.begin
1420+
// ^ punctuation.definition.generic.begin
1421+
// ^ punctuation.definition.type.begin
1422+
// ^^ storage.modifier.lifetime
1423+
// ^^^ storage.type
1424+
// ^ punctuation.definition.generic.begin
1425+
// ^ punctuation.definition.generic.end
1426+
// ^ meta.function meta.function.parameters punctuation.definition.parameters.begin

0 commit comments

Comments
 (0)