aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/alecthomas/chroma/lexers/r/rust.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/alecthomas/chroma/lexers/r/rust.go')
-rw-r--r--vendor/github.com/alecthomas/chroma/lexers/r/rust.go56
1 files changed, 25 insertions, 31 deletions
diff --git a/vendor/github.com/alecthomas/chroma/lexers/r/rust.go b/vendor/github.com/alecthomas/chroma/lexers/r/rust.go
index 25d42e594a..5399c9d7b2 100644
--- a/vendor/github.com/alecthomas/chroma/lexers/r/rust.go
+++ b/vendor/github.com/alecthomas/chroma/lexers/r/rust.go
@@ -9,9 +9,9 @@ import (
var Rust = internal.Register(MustNewLazyLexer(
&Config{
Name: "Rust",
- Aliases: []string{"rust"},
+ Aliases: []string{"rust", "rs"},
Filenames: []string{"*.rs", "*.rs.in"},
- MimeTypes: []string{"text/rust"},
+ MimeTypes: []string{"text/rust", "text/x-rust"},
EnsureNL: true,
},
rustRules,
@@ -35,20 +35,22 @@ func rustRules() Rules {
{`r#*"(?:\\.|[^\\;])*"#*`, LiteralString, nil},
{`"(?:\\.|[^\\"])*"`, LiteralString, nil},
{`\$([a-zA-Z_]\w*|\(,?|\),?|,?)`, CommentPreproc, nil},
- {Words(``, `\b`, `as`, `async`, `await`, `const`, `crate`, `else`, `extern`, `for`, `if`, `impl`, `in`, `loop`, `match`, `move`, `mut`, `pub`, `ref`, `return`, `static`, `super`, `trait`, `unsafe`, `use`, `where`, `while`), Keyword, nil},
- {Words(``, `\b`, `abstract`, `become`, `box`, `do`, `final`, `macro`, `override`, `priv`, `try`, `typeof`, `unsized`, `virtual`, `yield`), KeywordReserved, nil},
+ {Words(``, `\b`, `as`, `async`, `await`, `box`, `const`, `crate`, `dyn`, `else`, `extern`, `for`, `if`, `impl`, `in`, `loop`, `match`, `move`, `mut`, `pub`, `ref`, `return`, `static`, `super`, `trait`, `unsafe`, `use`, `where`, `while`), Keyword, nil},
+ {Words(``, `\b`, `abstract`, `become`, `do`, `final`, `macro`, `override`, `priv`, `typeof`, `try`, `unsized`, `virtual`, `yield`), KeywordReserved, nil},
{`(true|false)\b`, KeywordConstant, nil},
+ {`self\b`, NameBuiltinPseudo, nil},
{`mod\b`, Keyword, Push("modname")},
{`let\b`, KeywordDeclaration, nil},
{`fn\b`, Keyword, Push("funcname")},
{`(struct|enum|type|union)\b`, Keyword, Push("typename")},
{`(default)(\s+)(type|fn)\b`, ByGroups(Keyword, Text, Keyword), nil},
- {Words(``, `\b`, `u8`, `u16`, `u32`, `u64`, `u128`, `i8`, `i16`, `i32`, `i64`, `i128`, `usize`, `isize`, `f32`, `f64`, `str`, `bool`), KeywordType, nil},
- {`self\b`, NameBuiltinPseudo, nil},
- {Words(``, `\b`, `Copy`, `Send`, `Sized`, `Sync`, `Drop`, `Fn`, `FnMut`, `FnOnce`, `Box`, `ToOwned`, `Clone`, `PartialEq`, `PartialOrd`, `Eq`, `Ord`, `AsRef`, `AsMut`, `Into`, `From`, `Default`, `Iterator`, `Extend`, `IntoIterator`, `DoubleEndedIterator`, `ExactSizeIterator`, `Option`, `Some`, `None`, `Result`, `Ok`, `Err`, `SliceConcatExt`, `String`, `ToString`, `Vec`), NameBuiltin, nil},
+ {Words(``, `\b`, `u8`, `u16`, `u32`, `u64`, `u128`, `i8`, `i16`, `i32`, `i64`, `i128`, `usize`, `isize`, `f32`, `f64`, `char`, `str`, `bool`), KeywordType, nil},
+ {`[sS]elf\b`, NameBuiltinPseudo, nil},
+ {Words(``, `\b`, `Copy`, `Send`, `Sized`, `Sync`, `Unpin`, `Drop`, `Fn`, `FnMut`, `FnOnce`, `drop`, `Box`, `ToOwned`, `Clone`, `PartialEq`, `PartialOrd`, `Eq`, `Ord`, `AsRef`, `AsMut`, `Into`, `From`, `Default`, `Iterator`, `Extend`, `IntoIterator`, `DoubleEndedIterator`, `ExactSizeIterator`, `Option`, `Some`, `None`, `Result`, `Ok`, `Err`, `String`, `ToString`, `Vec`), NameBuiltin, nil},
+ {Words(``, `!`, `asm`, `assert`, `assert_eq`, `assert_ne`, `cfg`, `column`, `compile_error`, `concat`, `concat_idents`, `dbg`, `debug_assert`, `debug_assert_eq`, `debug_assert_ne`, `env`, `eprint`, `eprintln`, `file`, `format`, `format_args`, `format_args_nl`, `global_asm`, `include`, `include_bytes`, `include_str`, `is_aarch64_feature_detected`, `is_arm_feature_detected`, `is_mips64_feature_detected`, `is_mips_feature_detected`, `is_powerpc64_feature_detected`, `is_powerpc_feature_detected`, `is_x86_feature_detected`, `line`, `llvm_asm`, `log_syntax`, `macro_rules`, `matches`, `module_path`, `option_env`, `panic`, `print`, `println`, `stringify`, `thread_local`, `todo`, `trace_macros`, `unimplemented`, `unreachable`, `vec`, `write`, `writeln`), NameFunctionMagic, nil},
{`::\b`, Text, nil},
{`(?::|->)`, Text, Push("typename")},
- {`(break|continue)(\s*)(\'[A-Za-z_]\w*)?`, ByGroups(Keyword, TextWhitespace, NameLabel), nil},
+ {`(break|continue)(\b\s*)(\'[A-Za-z_]\w*)?`, ByGroups(Keyword, TextWhitespace, NameLabel), nil},
{`'(\\['"\\nrt]|\\x[0-7][0-9a-fA-F]|\\0|\\u\{[0-9a-fA-F]{1,6}\}|.)'`, LiteralStringChar, nil},
{`b'(\\['"\\nrt]|\\x[0-9a-fA-F]{2}|\\0|\\u\{[0-9a-fA-F]{1,6}\}|.)'`, LiteralStringChar, nil},
{`0b[01_]+`, LiteralNumberBin, Push("number_lit")},
@@ -57,15 +59,15 @@ func rustRules() Rules {
{`[0-9][0-9_]*(\.[0-9_]+[eE][+\-]?[0-9_]+|\.[0-9_]*(?!\.)|[eE][+\-]?[0-9_]+)`, LiteralNumberFloat, Push("number_lit")},
{`[0-9][0-9_]*`, LiteralNumberInteger, Push("number_lit")},
{`b"`, LiteralString, Push("bytestring")},
- {`b?r(#*)".*?"\1`, LiteralString, nil},
- {`'static`, NameBuiltin, nil},
- {`'[a-zA-Z_]\w*`, NameAttribute, nil},
+ {`(?s)b?r(#*)".*?"\1`, LiteralString, nil},
+ {`'`, Operator, Push("lifetime")},
+ {`\.\.=?`, Operator, nil},
{`[{}()\[\],.;]`, Punctuation, nil},
{`[+\-*/%&|<>^!~@=:?]`, Operator, nil},
{`(r#)?[a-zA-Z_]\w*`, Name, nil},
+ {`r#[a-zA-Z_]\w*`, Name, nil},
{`#!?\[`, CommentPreproc, Push("attribute[")},
- {`([A-Za-z_]\w*)(!)(\s*)([A-Za-z_]\w*)?(\s*)(\{)`, ByGroups(CommentPreproc, Punctuation, TextWhitespace, Name, TextWhitespace, Punctuation), Push("macro{")},
- {`([A-Za-z_]\w*)(!)(\s*)([A-Za-z_]\w*)?(\()`, ByGroups(CommentPreproc, Punctuation, TextWhitespace, Name, Punctuation), Push("macro(")},
+ {`#`, Text, nil},
},
"comment": {
{`[^*/]+`, CommentMultiline, nil},
@@ -92,11 +94,17 @@ func rustRules() Rules {
"typename": {
{`\s+`, Text, nil},
{`&`, KeywordPseudo, nil},
- {Words(``, `\b`, `Copy`, `Send`, `Sized`, `Sync`, `Drop`, `Fn`, `FnMut`, `FnOnce`, `Box`, `ToOwned`, `Clone`, `PartialEq`, `PartialOrd`, `Eq`, `Ord`, `AsRef`, `AsMut`, `Into`, `From`, `Default`, `Iterator`, `Extend`, `IntoIterator`, `DoubleEndedIterator`, `ExactSizeIterator`, `Option`, `Some`, `None`, `Result`, `Ok`, `Err`, `SliceConcatExt`, `String`, `ToString`, `Vec`), NameBuiltin, nil},
- {Words(``, `\b`, `u8`, `u16`, `u32`, `u64`, `i8`, `i16`, `i32`, `i64`, `usize`, `isize`, `f32`, `f64`, `str`, `bool`), KeywordType, nil},
+ {`'`, Operator, Push("lifetime")},
+ {Words(``, `\b`, `Copy`, `Send`, `Sized`, `Sync`, `Unpin`, `Drop`, `Fn`, `FnMut`, `FnOnce`, `drop`, `Box`, `ToOwned`, `Clone`, `PartialEq`, `PartialOrd`, `Eq`, `Ord`, `AsRef`, `AsMut`, `Into`, `From`, `Default`, `Iterator`, `Extend`, `IntoIterator`, `DoubleEndedIterator`, `ExactSizeIterator`, `Option`, `Some`, `None`, `Result`, `Ok`, `Err`, `String`, `ToString`, `Vec`), NameBuiltin, nil},
+ {Words(``, `\b`, `u8`, `u16`, `u32`, `u64`, `u128`, `i8`, `i16`, `i32`, `i64`, `i128`, `usize`, `isize`, `f32`, `f64`, `char`, `str`, `bool`), KeywordType, nil},
{`[a-zA-Z_]\w*`, NameClass, Pop(1)},
Default(Pop(1)),
},
+ "lifetime": {
+ {`(static|_)`, NameBuiltin, nil},
+ {`[a-zA-Z_]+\w*`, NameAttribute, nil},
+ Default(Pop(1)),
+ },
"number_lit": {
{`[ui](8|16|32|64|size)`, Keyword, Pop(1)},
{`f(32|64)`, Keyword, Pop(1)},
@@ -112,28 +120,14 @@ func rustRules() Rules {
{`\\x[89a-fA-F][0-9a-fA-F]`, LiteralStringEscape, nil},
Include("string"),
},
- "macro{": {
- {`\{`, Operator, Push()},
- {`\}`, Operator, Pop(1)},
- },
- "macro(": {
- {`\(`, Operator, Push()},
- {`\)`, Operator, Pop(1)},
- },
"attribute_common": {
{`"`, LiteralString, Push("string")},
{`\[`, CommentPreproc, Push("attribute[")},
- {`\(`, CommentPreproc, Push("attribute(")},
},
"attribute[": {
Include("attribute_common"),
- {`\];?`, CommentPreproc, Pop(1)},
- {`[^"\]]+`, CommentPreproc, nil},
- },
- "attribute(": {
- Include("attribute_common"),
- {`\);?`, CommentPreproc, Pop(1)},
- {`[^")]+`, CommentPreproc, nil},
+ {`\]`, CommentPreproc, Pop(1)},
+ {`[^"\]\[]+`, CommentPreproc, nil},
},
}
}