( information_for_contributors: [ "This file has been converted from https://github.com/dustypomerleau/rust-syntax/blob/master/syntaxes/rust.tmLanguage.json", "If you want to provide a fix or improvement, please create a pull request against the original repository.", "Once accepted there, we are happy to receive an update request.", ], version: "https://github.com/dustypomerleau/rust-syntax/commit/328a68299533bc2b8c71028be741cce78a9e0d53", name: "Rust", scopeName: "source.rust", patterns: [ ( comment: "boxed slice literal", name: "", begin: "(<)(\\[)", beginCaptures: { 1: ( name: "punctuation.brackets.angle.rust", ), 2: ( name: "punctuation.brackets.square.rust", ), }, begin: "(<)(\\[)", beginCaptures: { 0: ( name: "punctuation.brackets.angle.rust", ), }, patterns: [ ( include: "#block-comments", ), ( include: "#comments", ), ( include: "#gtypes", ), ( include: "#lvariables", ), ( include: "#lifetimes", ), ( include: "#punctuation", ), ( include: "#types", ), ], ), ( comment: "macro type metavariables", name: "meta.macro.metavariable.type.rust", match: "(\\$)((crate)|([A-Z][A-Za-z0-9_]*))((:)(block|expr|ident|item|lifetime|literal|meta|path?|stmt|tt|ty|vis))?", captures: { 1: ( name: "keyword.operator.macro.dollar.rust", ), 3: ( name: "keyword.other.crate.rust", ), 4: ( name: "entity.name.type.metavariable.rust", ), 6: ( name: "keyword.operator.key-value.rust", ), 7: ( name: "variable.other.metavariable.specifier.rust", ), }, patterns: [ ( include: "#keywords", ), ], ), ( comment: "macro metavariables", name: "meta.macro.metavariable.rust", match: "(\\$)([a-z][A-Za-z0-9_]*)((:)(block|expr|ident|item|lifetime|literal|meta|path?|stmt|tt|ty|vis))?", captures: { 1: ( name: "keyword.operator.macro.dollar.rust", ), 2: ( name: "variable.other.metavariable.name.rust", ), 4: ( name: "keyword.operator.key-value.rust", ), 5: ( name: "variable.other.metavariable.specifier.rust", ), }, patterns: [ ( include: "#keywords", ), ], ), ( comment: "macro rules", name: "meta.macro.rules.rust", match: "\\b(macro_rules!)\\s+(([a-z0-9_]+)|([A-Z][a-z0-9_]*))\\s+(\\{)", captures: { 1: ( name: "entity.name.function.macro.rules.rust", ), 3: ( name: "entity.name.function.macro.rust", ), 4: ( name: "entity.name.type.macro.rust", ), 5: ( name: "punctuation.brackets.curly.rust", ), }, ), ( comment: "attributes", name: "meta.attribute.rust", begin: "(#)(\\!?)(\\[)", beginCaptures: { 1: ( name: "punctuation.definition.attribute.rust", ), 2: ( name: "keyword.operator.attribute.inner.rust", ), 3: ( name: "punctuation.brackets.attribute.rust", ), }, begin: "(#)(\\!?)(\\[)", beginCaptures: { 0: ( name: "punctuation.brackets.attribute.rust", ), }, patterns: [ ( include: "#block-comments", ), ( include: "#comments", ), ( include: "#keywords", ), ( include: "#lifetimes", ), ( include: "#punctuation", ), ( include: "#strings", ), ( include: "#gtypes", ), ( include: "#types", ), ], ), ( comment: "modules", name: "", match: "(mod)\\s+((?:r#(?!crate|[Ss]elf|super))?[a-z][A-Za-z0-9_]*)", captures: { 1: ( name: "storage.type.rust", ), 2: ( name: "entity.name.module.rust", ), }, ), ( comment: "external crate imports", name: "meta.import.rust", begin: "\\b(extern)\\s+(crate)", beginCaptures: { 1: ( name: "storage.type.rust", ), 2: ( name: "keyword.other.crate.rust", ), }, begin: "\\b(extern)\\s+(crate)", beginCaptures: { 0: ( name: "punctuation.semi.rust", ), }, patterns: [ ( include: "#block-comments", ), ( include: "#comments", ), ( include: "#keywords", ), ( include: "#punctuation", ), ], ), ( comment: "use statements", name: "meta.use.rust", begin: "\\b(use)\\s", beginCaptures: { 1: ( name: "keyword.other.rust", ), }, begin: "\\b(use)\\s", beginCaptures: { 0: ( name: "punctuation.semi.rust", ), }, patterns: [ ( include: "#block-comments", ), ( include: "#comments", ), ( include: "#keywords", ), ( include: "#namespaces", ), ( include: "#punctuation", ), ( include: "#types", ), ( include: "#lvariables", ), ], ), ( include: "#block-comments", ), ( include: "#comments", ), ( include: "#lvariables", ), ( include: "#constants", ), ( include: "#gtypes", ), ( include: "#functions", ), ( include: "#types", ), ( include: "#keywords", ), ( include: "#lifetimes", ), ( include: "#macros", ), ( include: "#namespaces", ), ( include: "#punctuation", ), ( include: "#strings", ), ( include: "#variables", ), ], repository: { "block-comments": ( name: "", patterns: [ ( comment: "empty block comments", name: "comment.block.rust", match: "/\\*\\*/", captures: {}, ), ( comment: "block documentation comments", name: "comment.block.documentation.rust", begin: "/\\*\\*", beginCaptures: {}, begin: "/\\*\\*", beginCaptures: {}, patterns: [ ( include: "#block-comments", ), ], ), ( comment: "block comments", name: "comment.block.rust", begin: "/\\*(?!\\*)", beginCaptures: {}, begin: "/\\*(?!\\*)", beginCaptures: {}, patterns: [ ( include: "#block-comments", ), ], ), ], ), "comments": ( name: "", patterns: [ ( comment: "documentation comments", name: "comment.line.documentation.rust", match: "^\\s*///.*", captures: {}, ), ( comment: "line comments", name: "comment.line.double-slash.rust", match: "\\s*//.*", captures: {}, ), ], ), "constants": ( name: "", patterns: [ ( comment: "ALL CAPS constants", name: "constant.other.caps.rust", match: "\\b[A-Z]{2}[A-Z0-9_]*\\b", captures: {}, ), ( comment: "constant declarations", name: "", match: "\\b(const)\\s+([A-Z][A-Za-z0-9_]*)\\b", captures: { 1: ( name: "storage.type.rust", ), 2: ( name: "constant.other.caps.rust", ), }, ), ( comment: "decimal integers and floats", name: "constant.numeric.decimal.rust", match: "\\b\\d[\\d_]*(\\.?)[\\d_]*(?:(E|e)([+-]?)([\\d_]+))?(f32|f64|i128|i16|i32|i64|i8|isize|u128|u16|u32|u64|u8|usize)?\\b", captures: { 1: ( name: "punctuation.separator.dot.decimal.rust", ), 2: ( name: "keyword.operator.exponent.rust", ), 3: ( name: "keyword.operator.exponent.sign.rust", ), 4: ( name: "constant.numeric.decimal.exponent.mantissa.rust", ), 5: ( name: "entity.name.type.numeric.rust", ), }, ), ( comment: "hexadecimal integers", name: "constant.numeric.hex.rust", match: "\\b0x[\\da-fA-F_]+(i128|i16|i32|i64|i8|isize|u128|u16|u32|u64|u8|usize)?\\b", captures: { 1: ( name: "entity.name.type.numeric.rust", ), }, ), ( comment: "octal integers", name: "constant.numeric.oct.rust", match: "\\b0o[0-7_]+(i128|i16|i32|i64|i8|isize|u128|u16|u32|u64|u8|usize)?\\b", captures: { 1: ( name: "entity.name.type.numeric.rust", ), }, ), ( comment: "binary integers", name: "constant.numeric.bin.rust", match: "\\b0b[01_]+(i128|i16|i32|i64|i8|isize|u128|u16|u32|u64|u8|usize)?\\b", captures: { 1: ( name: "entity.name.type.numeric.rust", ), }, ), ( comment: "booleans", name: "constant.language.bool.rust", match: "\\b(true|false)\\b", captures: {}, ), ], ), "escapes": ( comment: "escapes: ASCII, byte, Unicode, quote, regex", name: "constant.character.escape.rust", match: "(\\\\)(?:(?:(x[0-7][0-7a-fA-F])|(u(\\{)[\\da-fA-F]{4,6}(\\}))|.))", captures: { 1: ( name: "constant.character.escape.backslash.rust", ), 2: ( name: "constant.character.escape.bit.rust", ), 3: ( name: "constant.character.escape.unicode.rust", ), 4: ( name: "constant.character.escape.unicode.punctuation.rust", ), 5: ( name: "constant.character.escape.unicode.punctuation.rust", ), }, ), "functions": ( name: "", patterns: [ ( comment: "pub as a function", name: "", match: "\\b(pub)(\\()", captures: { 1: ( name: "keyword.other.rust", ), 2: ( name: "punctuation.brackets.round.rust", ), }, ), ( comment: "function definition", name: "meta.function.definition.rust", begin: "\\b(fn)\\s+((?:r#(?!crate|[Ss]elf|super))?[A-Za-z0-9_]+)((\\()|(<))", beginCaptures: { 1: ( name: "keyword.other.fn.rust", ), 2: ( name: "entity.name.function.rust", ), 4: ( name: "punctuation.brackets.round.rust", ), 5: ( name: "punctuation.brackets.angle.rust", ), }, begin: "\\b(fn)\\s+((?:r#(?!crate|[Ss]elf|super))?[A-Za-z0-9_]+)((\\()|(<))", beginCaptures: { 0: ( name: "punctuation.brackets.curly.rust", ), }, patterns: [ ( include: "#block-comments", ), ( include: "#comments", ), ( include: "#keywords", ), ( include: "#lvariables", ), ( include: "#constants", ), ( include: "#gtypes", ), ( include: "#functions", ), ( include: "#lifetimes", ), ( include: "#macros", ), ( include: "#namespaces", ), ( include: "#punctuation", ), ( include: "#strings", ), ( include: "#types", ), ( include: "#variables", ), ], ), ( comment: "function/method calls, chaining", name: "meta.function.call.rust", begin: "((?:r#(?!crate|[Ss]elf|super))?[A-Za-z0-9_]+)(\\()", beginCaptures: { 1: ( name: "entity.name.function.rust", ), 2: ( name: "punctuation.brackets.round.rust", ), }, begin: "((?:r#(?!crate|[Ss]elf|super))?[A-Za-z0-9_]+)(\\()", beginCaptures: { 0: ( name: "punctuation.brackets.round.rust", ), }, patterns: [ ( include: "#block-comments", ), ( include: "#comments", ), ( include: "#keywords", ), ( include: "#lvariables", ), ( include: "#constants", ), ( include: "#gtypes", ), ( include: "#functions", ), ( include: "#lifetimes", ), ( include: "#macros", ), ( include: "#namespaces", ), ( include: "#punctuation", ), ( include: "#strings", ), ( include: "#types", ), ( include: "#variables", ), ], ), ( comment: "function/method calls with turbofish", name: "meta.function.call.rust", begin: "((?:r#(?!crate|[Ss]elf|super))?[A-Za-z0-9_]+)(?=::<.*>\\()", beginCaptures: { 1: ( name: "entity.name.function.rust", ), }, begin: "((?:r#(?!crate|[Ss]elf|super))?[A-Za-z0-9_]+)(?=::<.*>\\()", beginCaptures: { 0: ( name: "punctuation.brackets.round.rust", ), }, patterns: [ ( include: "#block-comments", ), ( include: "#comments", ), ( include: "#keywords", ), ( include: "#lvariables", ), ( include: "#constants", ), ( include: "#gtypes", ), ( include: "#functions", ), ( include: "#lifetimes", ), ( include: "#macros", ), ( include: "#namespaces", ), ( include: "#punctuation", ), ( include: "#strings", ), ( include: "#types", ), ( include: "#variables", ), ], ), ], ), "gtypes": ( name: "", patterns: [ ( comment: "option types", name: "entity.name.type.option.rust", match: "\\b(Some|None)\\b", captures: {}, ), ( comment: "result types", name: "entity.name.type.result.rust", match: "\\b(Ok|Err)\\b", captures: {}, ), ], ), "interpolations": ( comment: "curly brace interpolations", name: "meta.interpolation.rust", match: "({)[^\"{}]*(})", captures: { 1: ( name: "punctuation.definition.interpolation.rust", ), 2: ( name: "punctuation.definition.interpolation.rust", ), }, ), "keywords": ( name: "", patterns: [ ( comment: "control flow keywords", name: "keyword.control.rust", match: "\\b(await|break|continue|do|else|for|if|loop|match|return|try|while|yield)\\b", captures: {}, ), ( comment: "storage keywords", name: "keyword.other.rust storage.type.rust", match: "\\b(extern|let|macro|mod)\\b", captures: {}, ), ( comment: "const keyword", name: "storage.modifier.rust", match: "\\b(const)\\b", captures: {}, ), ( comment: "type keyword", name: "keyword.declaration.type.rust storage.type.rust", match: "\\b(type)\\b", captures: {}, ), ( comment: "enum keyword", name: "keyword.declaration.enum.rust storage.type.rust", match: "\\b(enum)\\b", captures: {}, ), ( comment: "trait keyword", name: "keyword.declaration.trait.rust storage.type.rust", match: "\\b(trait)\\b", captures: {}, ), ( comment: "struct keyword", name: "keyword.declaration.struct.rust storage.type.rust", match: "\\b(struct)\\b", captures: {}, ), ( comment: "storage modifiers", name: "storage.modifier.rust", match: "\\b(abstract|static)\\b", captures: {}, ), ( comment: "other keywords", name: "keyword.other.rust", match: "\\b(as|async|become|box|dyn|move|final|impl|in|override|priv|pub|ref|typeof|union|unsafe|unsized|use|virtual|where)\\b", captures: {}, ), ( comment: "fn", name: "keyword.other.fn.rust", match: "\\bfn\\b", captures: {}, ), ( comment: "crate", name: "keyword.other.crate.rust", match: "\\bcrate\\b", captures: {}, ), ( comment: "mut", name: "storage.modifier.mut.rust", match: "\\bmut\\b", captures: {}, ), ( comment: "logical operators", name: "keyword.operator.logical.rust", match: "(\\^|\\||\\|\\||&&|<<|>>|!)(?!=)", captures: {}, ), ( comment: "logical AND, borrow references", name: "keyword.operator.borrow.and.rust", match: "&(?![&=])", captures: {}, ), ( comment: "assignment operators", name: "keyword.operator.assignment.rust", match: "(\\+=|-=|\\*=|/=|%=|\\^=|&=|\\|=|<<=|>>=)", captures: {}, ), ( comment: "single equal", name: "keyword.operator.assignment.equal.rust", match: "(?])=(?!=|>)", captures: {}, ), ( comment: "comparison operators", name: "keyword.operator.comparison.rust", match: "(=(=)?(?!>)|!=|<=|(?=)", captures: {}, ), ( comment: "math operators", name: "keyword.operator.math.rust", match: "(([+%]|(\\*(?!\\w)))(?!=))|(-(?!>))|(/(?!/))", captures: {}, ), ( comment: "less than, greater than (special case)", name: "", match: "(?:\\b|(?:(\\))|(\\])|(\\})))[ \\t]+([<>])[ \\t]+(?:\\b|(?:(\\()|(\\[)|(\\{)))", captures: { 1: ( name: "punctuation.brackets.round.rust", ), 2: ( name: "punctuation.brackets.square.rust", ), 3: ( name: "punctuation.brackets.curly.rust", ), 4: ( name: "keyword.operator.comparison.rust", ), 5: ( name: "punctuation.brackets.round.rust", ), 6: ( name: "punctuation.brackets.square.rust", ), 7: ( name: "punctuation.brackets.curly.rust", ), }, ), ( comment: "namespace operator", name: "keyword.operator.namespace.rust", match: "::", captures: {}, ), ( comment: "dereference asterisk", name: "", match: "(\\*)(?=\\w+)", captures: { 1: ( name: "keyword.operator.dereference.rust", ), }, ), ( comment: "subpattern binding", name: "keyword.operator.subpattern.rust", match: "@", captures: {}, ), ( comment: "dot access", name: "keyword.operator.access.dot.rust", match: "\\.(?!\\.)", captures: {}, ), ( comment: "ranges, range patterns", name: "keyword.operator.range.rust", match: "\\.{2}(=|\\.)?", captures: {}, ), ( comment: "colon", name: "keyword.operator.key-value.rust", match: ":(?!:)", captures: {}, ), ( comment: "dashrocket, skinny arrow", name: "keyword.operator.arrow.skinny.rust", match: "->", captures: {}, ), ( comment: "hashrocket, fat arrow", name: "keyword.operator.arrow.fat.rust", match: "=>", captures: {}, ), ( comment: "dollar macros", name: "keyword.operator.macro.dollar.rust", match: "\\$", captures: {}, ), ( comment: "question mark operator, questionably sized, macro kleene matcher", name: "keyword.operator.question.rust", match: "\\?", captures: {}, ), ], ), "lifetimes": ( name: "", patterns: [ ( comment: "named lifetime parameters", name: "", match: "([\'])([a-zA-Z_][0-9a-zA-Z_]*)(?![\'])\\b", captures: { 1: ( name: "punctuation.definition.lifetime.rust", ), 2: ( name: "entity.name.type.lifetime.rust", ), }, ), ( comment: "borrowing references to named lifetimes", name: "", match: "(\\&)([\'])([a-zA-Z_][0-9a-zA-Z_]*)(?![\'])\\b", captures: { 1: ( name: "keyword.operator.borrow.rust", ), 2: ( name: "punctuation.definition.lifetime.rust", ), 3: ( name: "entity.name.type.lifetime.rust", ), }, ), ], ), "lvariables": ( name: "", patterns: [ ( comment: "self", name: "variable.language.self.rust", match: "\\b[Ss]elf\\b", captures: {}, ), ( comment: "super", name: "variable.language.super.rust", match: "\\bsuper\\b", captures: {}, ), ], ), "macros": ( name: "", patterns: [ ( comment: "macros", name: "meta.macro.rust", match: "(([a-z_][A-Za-z0-9_]*!)|([A-Z_][A-Za-z0-9_]*!))", captures: { 2: ( name: "entity.name.function.macro.rust", ), 3: ( name: "entity.name.type.macro.rust", ), }, ), ], ), "namespaces": ( name: "", patterns: [ ( comment: "namespace (non-type, non-function path segment)", name: "", match: "(?]", captures: {}, ), ], ), "strings": ( name: "", patterns: [ ( comment: "double-quoted strings and byte strings", name: "string.quoted.double.rust", begin: "(b?)(\")", beginCaptures: { 1: ( name: "string.quoted.byte.raw.rust", ), 2: ( name: "punctuation.definition.string.rust", ), }, begin: "(b?)(\")", beginCaptures: { 0: ( name: "punctuation.definition.string.rust", ), }, patterns: [ ( include: "#escapes", ), ( include: "#interpolations", ), ], ), ( comment: "double-quoted raw strings and raw byte strings", name: "string.quoted.double.rust", begin: "(b?r)(#*)(\")", beginCaptures: { 1: ( name: "string.quoted.byte.raw.rust", ), 2: ( name: "punctuation.definition.string.raw.rust", ), 3: ( name: "punctuation.definition.string.rust", ), }, begin: "(b?r)(#*)(\")", beginCaptures: { 1: ( name: "punctuation.definition.string.rust", ), 2: ( name: "punctuation.definition.string.raw.rust", ), }, ), ( comment: "characters and bytes", name: "string.quoted.single.char.rust", begin: "(b)?(\')", beginCaptures: { 1: ( name: "string.quoted.byte.raw.rust", ), 2: ( name: "punctuation.definition.char.rust", ), }, begin: "(b)?(\')", beginCaptures: { 0: ( name: "punctuation.definition.char.rust", ), }, patterns: [ ( include: "#escapes", ), ], ), ], ), "types": ( name: "", patterns: [ ( comment: "numeric types", name: "", match: "(?