Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax: Support HRTB in all type positions. #328

Merged
merged 1 commit into from
Aug 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 14 additions & 22 deletions RustEnhanced.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -451,13 +451,27 @@ contexts:
- include: strings
- match: '(?=\S)'
pop: true
- include: hrtb
- include: type
- include: type-slice
- match: '\b_\b'
scope: keyword.operator.rust
- match: '!'
scope: keyword.operator.rust

hrtb:
- match: \bfor\b
scope: keyword.other.rust
push:
- match: '(?=<)'
push: generic-angles
- include: type-any-identifier
- match: '&'
scope: keyword.operator.rust
- include: lifetime
- match: '(?=\S)'
pop: true

type-slice:
- match: '\['
scope: punctuation.definition.group.begin.rust
Expand Down Expand Up @@ -868,17 +882,6 @@ contexts:
pop: true
- match: \bwhere\b
scope: keyword.other.rust
- match: \bfor\b
scope: keyword.other.rust
push:
- match: '(?=<)'
push: generic-angles
- include: type-any-identifier
- match: '&'
scope: keyword.operator.rust
- include: lifetime
- match: '(?=\S)'
pop: true
- include: type-any-identifier
- match: ':'
scope: punctuation.separator.rust
Expand Down Expand Up @@ -945,17 +948,6 @@ contexts:
set: fn-body
- match: \bwhere\b
scope: keyword.other.rust
- match: \bfor\b
scope: keyword.other.rust
push:
- match: '(?=<)'
push: generic-angles
- include: type-any-identifier
- match: '&'
scope: keyword.operator.rust
- include: lifetime
- match: '(?=\S)'
pop: true
- include: type-any-identifier
- match: ':'
scope: punctuation.separator.rust
Expand Down
17 changes: 17 additions & 0 deletions tests/syntax-rust/syntax_test_generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,3 +300,20 @@ pub fn from_buf_reader<T>(s: io::BufReader<T>) -> Result<isize, &'static str>
where T: io::Read
// ^^^^^ keyword.other
{}

// HRTB in various positions.
fn f<F: for<'c> Fn(&'c mut Self)>() {}
// ^^^ meta.generic keyword.other
// ^ meta.generic meta.generic punctuation.definition.generic.begin
// ^^ meta.generic meta.generic storage.modifier.lifetime
// ^ meta.generic meta.generic punctuation.definition.generic.end
// ^^ meta.generic support.type
fn f(a: for<'a, 'b> fn() -> String) {}
// ^ variable.parameter
// ^^^^^^^^^^^^^^ meta.function meta.function.parameters
// ^^^ keyword.other
// ^ meta.generic punctuation.definition.generic.begin
// ^^ meta.generic storage.modifier.lifetime
// ^ meta.generic punctuation.separator
// ^^ meta.generic storage.modifier.lifetime
// ^ meta.function meta.function.parameters meta.generic punctuation.definition.generic.end