diff --git a/Rust/Rust.sublime-syntax b/Rust/Rust.sublime-syntax index fefbd2747b..dcb41ea29d 100644 --- a/Rust/Rust.sublime-syntax +++ b/Rust/Rust.sublime-syntax @@ -176,20 +176,20 @@ contexts: - match: '\b(const)\s+({{identifier}})' captures: - 1: keyword.declaration.rust + 1: keyword.declaration.variable.constant.rust 2: entity.name.constant.rust push: declaration-after-identifier - match: '\b(static)\s+(?:(mut)\s+)?({{identifier}})' captures: - 1: keyword.declaration.rust + 1: keyword.declaration.variable.static.rust 2: storage.modifier.rust 3: entity.name.constant.rust push: declaration-after-identifier - match: \b(let)\s+(?:(mut)\s+)? captures: - 1: keyword.declaration.rust + 1: keyword.declaration.variable.rust 2: storage.modifier.rust push: declaration-identifier @@ -1739,15 +1739,20 @@ contexts: scope: storage.modifier.rust keywords: - # All keywords. Note in `statements` some of these are superseded by more + # All keywords. Note in `statements` most of these are superseded by more # specific rules. - include: bool - - match: \b(let|static)\b - scope: keyword.declaration.rust + - match: \blet\b + scope: keyword.declaration.variable.rust + + - match: \bstatic\b + scope: keyword.declaration.variable.static.rust - match: \bconst\b - scope: storage.type.rust + # The storage keyword seems more likely to not have been matched earlier. + scope: storage.modifier.rust + # scope: keyword.declaration.variable.constant.rust - match: \bfn\b scope: keyword.declaration.function.rust diff --git a/Rust/tests/syntax_test_control_flow.rs b/Rust/tests/syntax_test_control_flow.rs index efda0f27c5..72f66a1323 100644 --- a/Rust/tests/syntax_test_control_flow.rs +++ b/Rust/tests/syntax_test_control_flow.rs @@ -71,7 +71,7 @@ if n < 0 { // <- meta.block punctuation.section.block.end if let BasicStruct(i) = j { -// ^^^ keyword.declaration +// ^^^ keyword.declaration.variable.rust // ^ keyword.operator.assignment // ^ meta.block punctuation.section.block.begin println!("Basic value: {}", i); @@ -80,7 +80,7 @@ if let BasicStruct(i) = j { while let BasicStruct(k) = j { //^^^ keyword.control -// ^^^ keyword.declaration +// ^^^ keyword.declaration.variable.rust // ^ keyword.operator.assignment // ^ meta.block punctuation.section.block.begin println!("Constructed example: {}", j) diff --git a/Rust/tests/syntax_test_expr.rs b/Rust/tests/syntax_test_expr.rs index f491a102d9..a807ca0369 100644 --- a/Rust/tests/syntax_test_expr.rs +++ b/Rust/tests/syntax_test_expr.rs @@ -3,9 +3,9 @@ // specific categories. let big_n = -// <- keyword.declaration - // <- keyword.declaration -//^ keyword.declaration +// <- keyword.declaration.variable.rust + // <- keyword.declaration.variable.rust +//^ keyword.declaration.variable.rust // ^ keyword.operator.assignment if n < 10 && n > -10 { // ^ keyword.operator.comparison diff --git a/Rust/tests/syntax_test_literals.rs b/Rust/tests/syntax_test_literals.rs index 98e8b1b055..1358726791 100644 --- a/Rust/tests/syntax_test_literals.rs +++ b/Rust/tests/syntax_test_literals.rs @@ -1,11 +1,11 @@ // SYNTAX TEST "Packages/Rust/Rust.sublime-syntax" let c = 'c'; -// <- keyword.declaration +// <- keyword.declaration.variable.rust // ^ keyword.operator.assignment // ^^^ string.quoted.single let b = b'c'; -// <- keyword.declaration +// <- keyword.declaration.variable.rust // ^ keyword.operator.assignment // ^ storage.type // ^^^ string.quoted.single @@ -13,7 +13,7 @@ let ch = '∞'; // ^^^ string.quoted.single let s = "This is a string \x01_\u{007F}_\"_\'_\\_\r_\n_\t_\0"; -// <- keyword.declaration +// <- keyword.declaration.variable.rust // ^ keyword.operator.assignment // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double // ^^^^ constant.character.escape @@ -26,7 +26,7 @@ let s = "This is a string \x01_\u{007F}_\"_\'_\\_\r_\n_\t_\0"; // ^^ constant.character.escape // ^^ constant.character.escape let r = r##"This is a raw string, no escapes! \x00 \0 \n"##; -// <- keyword.declaration +// <- keyword.declaration.variable.rust // ^ keyword.operator.assignment // ^ storage.type // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double.raw - constant.character.escape @@ -46,7 +46,7 @@ println!("Continuation in format \ "); let bytes = b"This won't escape unicode \u{0123}, but will do \x01_\"_\'_\\_\r_\n_\t_\0"; -// <- keyword.declaration +// <- keyword.declaration.variable.rust // ^ keyword.operator.assignment // ^ storage.type // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double @@ -60,7 +60,7 @@ let bytes = b"This won't escape unicode \u{0123}, but will do \x01_\"_\'_\\_\r_\ // ^^ constant.character.escape let raw_bytes = br#"This won't escape anything either \x01 \""#; -// <- keyword.declaration +// <- keyword.declaration.variable.rust // ^ keyword.operator.assignment // ^^ storage.type // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double - constant.character.escape diff --git a/Rust/tests/syntax_test_types.rs b/Rust/tests/syntax_test_types.rs index edb6e4a7a9..3585651036 100644 --- a/Rust/tests/syntax_test_types.rs +++ b/Rust/tests/syntax_test_types.rs @@ -34,14 +34,14 @@ type GenFnPointer2 = Bar; // ^ - meta.generic const ZERO: u64 = 0; -// <- keyword.declaration +// <- keyword.declaration.variable.constant.rust // ^^^^ entity.name.constant // ^ punctuation.separator // ^^^ storage.type // ^ keyword.operator.assignment // ^ constant.numeric.integer.decimal static NAME: &'static str = "John"; -// <- keyword.declaration +// <- keyword.declaration.variable.static.rust // ^^^^ entity.name.constant // ^ keyword.operator // ^^^^^^^ storage.modifier.lifetime @@ -49,7 +49,7 @@ static NAME: &'static str = "John"; // ^ keyword.operator.assignment // ^^^^^^ string.quoted.double static mut BRAVO: u32 = 0; -// <- keyword.declaration +// <- keyword.declaration.variable.static.rust // ^^^ storage.modifier // ^^^^^ entity.name.constant @@ -65,7 +65,7 @@ fn factory() -> Box i32> { } let x: __m128i = __m128i::from_bits(f32x4::from_bits(m32x4::new(true, true, true, true))); -// <- keyword.declaration +// <- keyword.declaration.variable.rust // ^^^^^^^ storage.type // ^^^^^^^ storage.type // ^^^^^ meta.group storage.type @@ -94,7 +94,7 @@ type Pair<'a> = (i32, &'a str); // ^ punctuation.terminator let p: Pair<'static> = (10, "ten"); -// <- keyword.declaration +// <- keyword.declaration.variable.rust // ^ punctuation.separator // ^^^^^^^^^ meta.generic // ^ punctuation.definition.generic.begin diff --git a/Rust/tests/syntax_test_visibility.rs b/Rust/tests/syntax_test_visibility.rs index de481e4b14..d19fae86b1 100644 --- a/Rust/tests/syntax_test_visibility.rs +++ b/Rust/tests/syntax_test_visibility.rs @@ -36,13 +36,13 @@ pub ( in self ) enum E {A,B} pub ( in super ) const CONST: i32 = 1; // ^^ keyword.other // ^^^^^ keyword.other -// ^^^^^ keyword.declaration +// ^^^^^ keyword.declaration.variable.constant.rust pub ( in super::super ) static STATIC: i32 = 1; // ^^ keyword.other // ^^^^^ keyword.other // ^^ meta.path // ^^^^^ keyword.other -// ^^^^^^ keyword.declaration +// ^^^^^^ keyword.declaration.variable.static.rust struct S { pub f1: i32,