mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-01 12:24:29 +00:00
Allow wrapping builtin#offset_of fields argument in parentheses
This is necessary to correctly handle nested fields (`foo.bar`), see the comments in the code for explanation.
This commit is contained in:
parent
2f2cff19f8
commit
db6db2aacc
4 changed files with 61 additions and 0 deletions
|
|
@ -416,6 +416,10 @@ mod ok {
|
|||
run_and_expect_no_errors("test_data/parser/inline/ok/nocontentexpr_after_item.rs");
|
||||
}
|
||||
#[test]
|
||||
fn offset_of_parens() {
|
||||
run_and_expect_no_errors("test_data/parser/inline/ok/offset_of_parens.rs");
|
||||
}
|
||||
#[test]
|
||||
fn or_pattern() { run_and_expect_no_errors("test_data/parser/inline/ok/or_pattern.rs"); }
|
||||
#[test]
|
||||
fn param_list() { run_and_expect_no_errors("test_data/parser/inline/ok/param_list.rs"); }
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
SOURCE_FILE
|
||||
FN
|
||||
FN_KW "fn"
|
||||
WHITESPACE " "
|
||||
NAME
|
||||
IDENT "foo"
|
||||
PARAM_LIST
|
||||
L_PAREN "("
|
||||
R_PAREN ")"
|
||||
WHITESPACE " "
|
||||
BLOCK_EXPR
|
||||
STMT_LIST
|
||||
L_CURLY "{"
|
||||
WHITESPACE "\n "
|
||||
EXPR_STMT
|
||||
OFFSET_OF_EXPR
|
||||
BUILTIN_KW "builtin"
|
||||
POUND "#"
|
||||
OFFSET_OF_KW "offset_of"
|
||||
L_PAREN "("
|
||||
PATH_TYPE
|
||||
PATH
|
||||
PATH_SEGMENT
|
||||
NAME_REF
|
||||
IDENT "Foo"
|
||||
COMMA ","
|
||||
WHITESPACE " "
|
||||
L_PAREN "("
|
||||
NAME_REF
|
||||
IDENT "bar"
|
||||
DOT "."
|
||||
NAME_REF
|
||||
IDENT "baz"
|
||||
DOT "."
|
||||
NAME_REF
|
||||
INT_NUMBER "0"
|
||||
R_PAREN ")"
|
||||
R_PAREN ")"
|
||||
SEMICOLON ";"
|
||||
WHITESPACE "\n"
|
||||
R_CURLY "}"
|
||||
WHITESPACE "\n"
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fn foo() {
|
||||
builtin#offset_of(Foo, (bar.baz.0));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue