diff --git a/pygments/lexers/rust.py b/pygments/lexers/rust.py index c57f2b9e6b..d01f73e4a4 100644 --- a/pygments/lexers/rust.py +++ b/pygments/lexers/rust.py @@ -213,16 +213,10 @@ class RustLexer(RegexLexer): 'attribute_common': [ (r'"', String, 'string'), (r'\[', Comment.Preproc, 'attribute['), - (r'\(', Comment.Preproc, 'attribute('), ], 'attribute[': [ include('attribute_common'), - (r'\];?', Comment.Preproc, '#pop'), - (r'[^"\]]+', Comment.Preproc), - ], - 'attribute(': [ - include('attribute_common'), - (r'\);?', Comment.Preproc, '#pop'), - (r'[^")]+', Comment.Preproc), + (r'\]', Comment.Preproc, '#pop'), + (r'[^"\]\[]+', Comment.Preproc), ], } diff --git a/tests/snippets/rust/test_attribute.txt b/tests/snippets/rust/test_attribute.txt new file mode 100644 index 0000000000..2c4a889fb7 --- /dev/null +++ b/tests/snippets/rust/test_attribute.txt @@ -0,0 +1,12 @@ +---input--- +#[foo(bar = [baz, qux])] + +---tokens--- +'#[' Comment.Preproc +'foo(bar = ' Comment.Preproc +'[' Comment.Preproc +'baz, qux' Comment.Preproc +']' Comment.Preproc +')' Comment.Preproc +']' Comment.Preproc +'\n' Text.Whitespace