Skip to content

Commit ea4ab33

Browse files
bors[bot]PSeitzehuss
committed
Merge #360 #361
360: add dbg, debug, trace, info snippet r=ehuss a=PSeitz 361: Syntax: Support `const` functions. r=ehuss a=ehuss Co-authored-by: Pascal Seitz <[email protected]> Co-authored-by: Eric Huss <[email protected]>
3 parents 30dc8af + bfc4dd3 + ce732fa commit ea4ab33

8 files changed

+59
-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

snippets/dbg.sublime-snippet

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<snippet>
2+
<content><![CDATA[dbg!($1);$0]]></content>
3+
<scope>source.rust</scope>
4+
<tabTrigger>dbg</tabTrigger>
5+
<description>dbg!(…)</description>
6+
</snippet>

snippets/debug.sublime-snippet

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<snippet>
2+
<content><![CDATA[debug!("${1:\{${2::?}\}}"${1/([^\{])*(\{.*\})?.*/(?2:, :\);)/}$3${1/([^\{])*(\{.*\})?.*/(?2:\);)/}]]></content>
3+
<scope>source.rust</scope>
4+
<tabTrigger>debug</tabTrigger>
5+
<description>debug!(…)</description>
6+
</snippet>

snippets/error.sublime-snippet

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<snippet>
2+
<content><![CDATA[error!("${1:\{${2::?}\}}"${1/([^\{])*(\{.*\})?.*/(?2:, :\);)/}$3${1/([^\{])*(\{.*\})?.*/(?2:\);)/}]]></content>
3+
<scope>source.rust</scope>
4+
<tabTrigger>error</tabTrigger>
5+
<description>error!(…)</description>
6+
</snippet>

snippets/info.sublime-snippet

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<snippet>
2+
<content><![CDATA[info!("${1:\{${2::?}\}}"${1/([^\{])*(\{.*\})?.*/(?2:, :\);)/}$3${1/([^\{])*(\{.*\})?.*/(?2:\);)/}]]></content>
3+
<scope>source.rust</scope>
4+
<tabTrigger>info</tabTrigger>
5+
<description>info!(…)</description>
6+
</snippet>

snippets/trace.sublime-snippet

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<snippet>
2+
<content><![CDATA[trace!("${1:\{${2::?}\}}"${1/([^\{])*(\{.*\})?.*/(?2:, :\);)/}$3${1/([^\{])*(\{.*\})?.*/(?2:\);)/}]]></content>
3+
<scope>source.rust</scope>
4+
<tabTrigger>trace</tabTrigger>
5+
<description>trace!(…)</description>
6+
</snippet>

snippets/warn.sublime-snippet

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<snippet>
2+
<content><![CDATA[warn!("${1:\{${2::?}\}}"${1/([^\{])*(\{.*\})?.*/(?2:, :\);)/}$3${1/([^\{])*(\{.*\})?.*/(?2:\);)/}]]></content>
3+
<scope>source.rust</scope>
4+
<tabTrigger>warn</tabTrigger>
5+
<description>warn!(…)</description>
6+
</snippet>

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)