Skip to content

Commit

Permalink
Rust: Improve char pattern so that lifetime annotations are matched b…
Browse files Browse the repository at this point in the history
…etter. Fix #1353
  • Loading branch information
Golmote committed Mar 12, 2018
1 parent 8572474 commit efdccbf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
10 changes: 5 additions & 5 deletions components/prism-rust.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ Prism.languages.rust = {
greedy: true
}
],
'lifetime-annotation': {
pattern: /'[^\s>']+(?!')/,
alias: 'symbol'
},
'char': {
pattern: /'(?:\\.|[^\\\r\n'])*'/,
pattern: /b?'(?:\\(?:x[0-7][\da-fA-F]|u{(?:[\da-fA-F]_*){1,6}|.)|[^\\\r\n\t'])'/,
alias: 'string'
},
'lifetime-annotation': {
pattern: /'[^\s>']+/,
alias: 'symbol'
},
'keyword': /\b(?:abstract|alignof|as|be|box|break|const|continue|crate|do|else|enum|extern|false|final|fn|for|if|impl|in|let|loop|match|mod|move|mut|offsetof|once|override|priv|pub|pure|ref|return|sizeof|static|self|struct|super|true|trait|type|typeof|unsafe|unsized|use|virtual|where|while|yield)\b/,

'attribute': {
Expand Down
2 changes: 1 addition & 1 deletion components/prism-rust.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions tests/languages/rust/issue1353.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
(*e 0 b'a')

----------------------------------------------------

[
["punctuation", "("],
["operator", "*"],
"e ",
["number", "0"],
["char", "b'a'"],
["punctuation", ")"]
]

----------------------------------------------------

Makes sure lifetime annotations do not mess with bytes. See #1353.

0 comments on commit efdccbf

Please sign in to comment.