Skip to content
This repository has been archived by the owner on Sep 8, 2023. It is now read-only.

Commit

Permalink
Support tuple index expressions in Rust lexer (rouge-ruby#1580)
Browse files Browse the repository at this point in the history
Currently, the Rust lexer does not support tuple index expressions. This
commit adds that support. To differentiate between tuple index
expressions and field access expressions, the `Name::Attribute` token
is used.

Co-authored-by: Michael Camilleri <[email protected]>
  • Loading branch information
2 people authored and mattt committed May 19, 2021
1 parent c281af7 commit 863fe6b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/rouge/lexers/rust.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def macro_closed?

rule %r/([.]\s*)?#{id}(?=\s*[(])/m, Name::Function
rule %r/[.]\s*#{id}/, Name::Property
rule %r/[.]\s*\d+/, Name::Attribute
rule %r/(#{id})(::)/m do
groups Name::Namespace, Punctuation
end
Expand Down
5 changes: 5 additions & 0 deletions spec/visual/samples/rust
Original file line number Diff line number Diff line change
Expand Up @@ -413,3 +413,8 @@ async fn learn_and_sing() {
let song = learn_song().await;
sing_song(song).await;
}

fn tuple_access() {
let t: (i32, i32) = (42, 13);
let f: t.0;
}

0 comments on commit 863fe6b

Please sign in to comment.