Skip to content

Commit ce732fa

Browse files
committed
Support const functions.
1 parent 8f13f78 commit ce732fa

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

RustEnhanced.sublime-syntax

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ contexts:
106106

107107
- include: raw-pointer
108108

109+
# `const` in a function header has a different scope from `const` values.
110+
- match: '\b(const)\s+(?=unsafe|extern|fn)'
111+
captures:
112+
1: storage.modifier.rust
113+
109114
- match: '\b(const)\s+({{identifier}})'
110115
captures:
111116
1: storage.type.rust

tests/syntax-rust/syntax_test_functions.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,21 @@ fn f(self,
106106
// ^ punctuation.section.brackets.end
107107
// ^ punctuation.separator
108108
{}
109+
110+
const fn f() {}
111+
// <- storage.modifier
112+
// ^^ meta.function storage.type.function
113+
// ^ meta.function entity.name.function
114+
115+
const unsafe fn f() {}
116+
// <- storage.modifier
117+
// ^^^^^^ storage.modifier
118+
// ^^ meta.function storage.type.function
119+
// ^ meta.function entity.name.function
120+
121+
const extern "C" fn f() {}
122+
// <- storage.modifier
123+
// ^^^^^^ keyword.other
124+
// ^^^ string.quoted.double
125+
// ^^ meta.function storage.type.function
126+
// ^ meta.function entity.name.function

0 commit comments

Comments
 (0)