Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Rust: Include starting apostrophe in lifetime / loop label token (#739)
- Loading branch information
1 parent
633f8e0
commit 0ea6503
Showing
5 changed files
with
141 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
struct Bar<'b>(&'b str); | ||
|
||
struct Foo<'b, 'a: 'b>(&'a Bar<'b>); | ||
|
||
fn foo<'some_name>(_: Bar<'_>, _: impl Iterator<Item = Bar<'static>> + 'static) { | ||
'im_a_loop_label: loop { | ||
break 'im_a_loop_label; | ||
} | ||
|
||
// None of these should have lifetimes | ||
let _ = 'a'; | ||
let _ = b'a'; | ||
let _ = " | ||
'not_a_lifetime_or_label | ||
"; | ||
} |
117 changes: 117 additions & 0 deletions
117
lexers/testdata/rust/lifetimes_and_loop_labels.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
[ | ||
{"type":"Keyword","value":"struct"}, | ||
{"type":"Text","value":" "}, | ||
{"type":"NameClass","value":"Bar"}, | ||
{"type":"Operator","value":"\u003c"}, | ||
{"type":"NameAttribute","value":"'b"}, | ||
{"type":"Operator","value":"\u003e"}, | ||
{"type":"Punctuation","value":"("}, | ||
{"type":"Operator","value":"\u0026"}, | ||
{"type":"NameAttribute","value":"'b"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"KeywordType","value":"str"}, | ||
{"type":"Punctuation","value":");"}, | ||
{"type":"TextWhitespace","value":"\n\n"}, | ||
{"type":"Keyword","value":"struct"}, | ||
{"type":"Text","value":" "}, | ||
{"type":"NameClass","value":"Foo"}, | ||
{"type":"Operator","value":"\u003c"}, | ||
{"type":"NameAttribute","value":"'b"}, | ||
{"type":"Punctuation","value":","}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"NameAttribute","value":"'a"}, | ||
{"type":"Text","value":": "}, | ||
{"type":"NameAttribute","value":"'b"}, | ||
{"type":"Operator","value":"\u003e"}, | ||
{"type":"Punctuation","value":"("}, | ||
{"type":"Operator","value":"\u0026"}, | ||
{"type":"NameAttribute","value":"'a"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"Name","value":"Bar"}, | ||
{"type":"Operator","value":"\u003c"}, | ||
{"type":"NameAttribute","value":"'b"}, | ||
{"type":"Operator","value":"\u003e"}, | ||
{"type":"Punctuation","value":");"}, | ||
{"type":"TextWhitespace","value":"\n\n"}, | ||
{"type":"Keyword","value":"fn"}, | ||
{"type":"Text","value":" "}, | ||
{"type":"NameFunction","value":"foo"}, | ||
{"type":"Operator","value":"\u003c"}, | ||
{"type":"NameAttribute","value":"'some_name"}, | ||
{"type":"Operator","value":"\u003e"}, | ||
{"type":"Punctuation","value":"("}, | ||
{"type":"Name","value":"_"}, | ||
{"type":"Text","value":": "}, | ||
{"type":"NameClass","value":"Bar"}, | ||
{"type":"Operator","value":"\u003c"}, | ||
{"type":"NameBuiltin","value":"'_"}, | ||
{"type":"Operator","value":"\u003e"}, | ||
{"type":"Punctuation","value":","}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"Name","value":"_"}, | ||
{"type":"Text","value":": "}, | ||
{"type":"NameClass","value":"impl"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"NameBuiltin","value":"Iterator"}, | ||
{"type":"Operator","value":"\u003c"}, | ||
{"type":"Name","value":"Item"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"Operator","value":"="}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"Name","value":"Bar"}, | ||
{"type":"Operator","value":"\u003c"}, | ||
{"type":"NameBuiltin","value":"'static"}, | ||
{"type":"Operator","value":"\u003e\u003e"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"Operator","value":"+"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"NameBuiltin","value":"'static"}, | ||
{"type":"Punctuation","value":")"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"Punctuation","value":"{"}, | ||
{"type":"TextWhitespace","value":"\n "}, | ||
{"type":"NameAttribute","value":"'im_a_loop_label"}, | ||
{"type":"Text","value":": "}, | ||
{"type":"NameClass","value":"loop"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"Punctuation","value":"{"}, | ||
{"type":"TextWhitespace","value":"\n "}, | ||
{"type":"Keyword","value":"break"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"NameLabel","value":"'im_a_loop_label"}, | ||
{"type":"Punctuation","value":";"}, | ||
{"type":"TextWhitespace","value":"\n "}, | ||
{"type":"Punctuation","value":"}"}, | ||
{"type":"TextWhitespace","value":"\n\n "}, | ||
{"type":"CommentSingle","value":"// None of these should have lifetimes\n"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"KeywordDeclaration","value":"let"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"Name","value":"_"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"Operator","value":"="}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"LiteralStringChar","value":"'a'"}, | ||
{"type":"Punctuation","value":";"}, | ||
{"type":"TextWhitespace","value":"\n "}, | ||
{"type":"KeywordDeclaration","value":"let"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"Name","value":"_"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"Operator","value":"="}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"Error","value":"b'a'"}, | ||
{"type":"Punctuation","value":";"}, | ||
{"type":"TextWhitespace","value":"\n "}, | ||
{"type":"KeywordDeclaration","value":"let"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"Name","value":"_"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"Operator","value":"="}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"LiteralString","value":"\"\n 'not_a_lifetime_or_label\n \""}, | ||
{"type":"Punctuation","value":";"}, | ||
{"type":"TextWhitespace","value":"\n"}, | ||
{"type":"Punctuation","value":"}"}, | ||
{"type":"TextWhitespace","value":"\n"} | ||
] |
File renamed without changes.
File renamed without changes.