Skip to content

Commit

Permalink
Rust lexer: bug fix with regex lexer and '!' + r'\b'
Browse files Browse the repository at this point in the history
Rust macros end with a '!'. The word border (regex '\b') for such expressions is located before the '!' (e. g. "print\b!(...)"). The regex here used the suffix option, which added an r'\b' after each regex (e. g. r'print!\b'). Therefore, the supplied regular expressions didn't match the rust macros.

To fix this problem, the suffix is removed. As every macro ends with an '!' (which implicitely includes a word border before), it's not necessary anyway.
  • Loading branch information
K. Lux authored and birkenfeld committed Nov 19, 2020
1 parent 1d8f74c commit 0744d68
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pygments/lexers/rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class RustLexer(RegexLexer):
'module_path!', 'option_env!', 'panic!', 'print!', 'println!',
'stringify!', 'thread_local!', 'todo!', 'trace_macros!',
'unimplemented!', 'unreachable!', 'vec!', 'write!', 'writeln!',
), suffix=r'\b'), Name.Builtin)
)), Name.Builtin)

tokens = {
'root': [
Expand Down

0 comments on commit 0744d68

Please sign in to comment.