Skip to content

Add fmt-style formatting for additional macros in the standard library. #181

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

Merged
merged 1 commit into from
May 4, 2017
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
4 changes: 2 additions & 2 deletions RustEnhanced.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ contexts:
- match: '\b[[:lower:]_][[:lower:][:digit:]_]*(?=\()'
scope: support.function.rust

- match: '\b((?:format|print|println)!)\s*(\()'
- match: '\b((?:format|print|println|panic|format_args|unreachable)!)\s*(\()'
captures:
1: support.macro.rust
2: meta.group.rust punctuation.definition.group.begin.rust
Expand Down Expand Up @@ -233,7 +233,7 @@ contexts:
- match: '#!?\['
push:
# https://github.com/sublimehq/Packages/issues/709#issuecomment-266835130
- meta_scope: meta.annotation.rust
- meta_scope: meta.annotation.rust
- include: statements
- match: '\]'
pop: true
Expand Down
38 changes: 34 additions & 4 deletions syntax_test_rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,10 @@ struct PrintableStruct(Box<i32>);
// fixes https://github.com/rust-lang/sublime-rust/issues/144
fn factory() -> Box<Fn(i32) -> i32> {
// <- storage.type.function
// ^^^^^^^ entity.name.function
// ^^^^^^^ entity.name.function
// ^^^^^^^^^^^^^^ meta.generic
// ^^ storage.type
// ^^ storage.type
// ^^ storage.type
// ^^ storage.type
// ^^ punctuation.separator.generic

Box::new(|x| x + 1)
Expand Down Expand Up @@ -902,7 +902,7 @@ pub fn next_lex2</* block */T/* comments */:/* everywhere */
/* help */ PartialOrd // Possibly too many comments
// ^^^^^^^^^^ comment.block.rust
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.double-slash.rust
> (
> (
/* block2 */ data2: &mut [T] // line
// ^^^^^^^^^^^^ source.rust meta.function.rust meta.function.parameters.rust comment.block.rust
// ^^^^^^^ source.rust meta.function.rust meta.function.parameters.rust comment.line.double-slash.rust
Expand Down Expand Up @@ -967,3 +967,33 @@ impl<T> Iterator for Fibonacci<T>
pub const FOO: Option<[i32; 1]> = Some([1]);
// ^ punctuation.definition.group.begin.rust
// ^ punctuation.definition.group.end.rust

pub fn macro_tests() {
println!();
// ^^^^^^^^ support.macro.rust
println!("Example");
// ^^^^^^^^ support.macro.rust
// ^ punctuation.definition.group.begin
// ^^^^^^^^^ string.quoted.double.rust
// ^ punctuation.definition.group.end
println!("Example {} {message}", "test", message="hi");
// ^^ constant.other.placeholder.rust
// ^^^^^^^^^ constant.other.placeholder.rust
panic!();
// ^^^^^^ support.macro.rust
panic!("Example");
// ^^^^^^ support.macro.rust
// ^ punctuation.definition.group.begin
// ^^^^^^^^^ string.quoted.double.rust
// ^ punctuation.definition.group.end
panic!("Example {} {message}", "test", message="hi");
// ^^ constant.other.placeholder.rust
// ^^^^^^^^^ constant.other.placeholder.rust
format_args!("invalid type: {}, expected {}", unexp, exp);
// ^^^^^^^^^^^^ support.macro.rust
// ^^ constant.other.placeholder.rust
// ^^ constant.other.placeholder.rust
unreachable!("{:?}", e);
// ^^^^^^^^^^^^ support.macro.rust
// ^^^^ constant.other.placeholder.rust
}