-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #14746 - lowr:patch/associated-return-types, r=Veykril
Parse associated return type bounds This PR implements parser support for associated return type bounds: `T: Foo<bar(): Send>`. This PR does not implement associated return types (`T::bar(): Send`) because it's not implemented even in rustc, and also removes `(..)`-style return type notation because it has been removed in rust-lang/rust#110203 (effectively reverting #14465). I don't plan to proactively follow this unstable feature unless an RFC is accepted and my main motivation here is to remove no-longer-valid syntax `(..)` from our parser, nevertheless adding minimal parser support so anyone interested (as can be seen in #14465) can experiment it without rust-analyzer's syntax errors.
- Loading branch information
Showing
14 changed files
with
363 additions
and
106 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
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
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
1 change: 1 addition & 0 deletions
1
crates/parser/test_data/parser/inline/ok/0202_typepathfn_with_coloncolon.rs
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
type F = Start::(Middle) -> (Middle)::End; | ||
type GenericArg = S<Start(Middle)::End>; |
33 changes: 0 additions & 33 deletions
33
crates/parser/test_data/parser/inline/ok/0206_return_type_arg.rast
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
crates/parser/test_data/parser/inline/ok/0206_return_type_arg.rs
This file was deleted.
Oops, something went wrong.
102 changes: 102 additions & 0 deletions
102
crates/parser/test_data/parser/inline/ok/0208_associated_return_type_bounds.rast
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,102 @@ | ||
SOURCE_FILE | ||
FN | ||
FN_KW "fn" | ||
WHITESPACE " " | ||
NAME | ||
IDENT "foo" | ||
GENERIC_PARAM_LIST | ||
L_ANGLE "<" | ||
TYPE_PARAM | ||
NAME | ||
IDENT "T" | ||
COLON ":" | ||
WHITESPACE " " | ||
TYPE_BOUND_LIST | ||
TYPE_BOUND | ||
PATH_TYPE | ||
PATH | ||
PATH_SEGMENT | ||
NAME_REF | ||
IDENT "Foo" | ||
GENERIC_ARG_LIST | ||
L_ANGLE "<" | ||
ASSOC_TYPE_ARG | ||
NAME_REF | ||
IDENT "foo" | ||
PARAM_LIST | ||
L_PAREN "(" | ||
R_PAREN ")" | ||
COLON ":" | ||
WHITESPACE " " | ||
TYPE_BOUND_LIST | ||
TYPE_BOUND | ||
PATH_TYPE | ||
PATH | ||
PATH_SEGMENT | ||
NAME_REF | ||
IDENT "Send" | ||
COMMA "," | ||
WHITESPACE " " | ||
ASSOC_TYPE_ARG | ||
NAME_REF | ||
IDENT "bar" | ||
PARAM_LIST | ||
L_PAREN "(" | ||
PARAM | ||
PATH_TYPE | ||
PATH | ||
PATH_SEGMENT | ||
NAME_REF | ||
IDENT "i32" | ||
R_PAREN ")" | ||
COLON ":" | ||
WHITESPACE " " | ||
TYPE_BOUND_LIST | ||
TYPE_BOUND | ||
PATH_TYPE | ||
PATH | ||
PATH_SEGMENT | ||
NAME_REF | ||
IDENT "Send" | ||
COMMA "," | ||
WHITESPACE " " | ||
ASSOC_TYPE_ARG | ||
NAME_REF | ||
IDENT "baz" | ||
PARAM_LIST | ||
L_PAREN "(" | ||
PARAM | ||
PATH_TYPE | ||
PATH | ||
PATH_SEGMENT | ||
NAME_REF | ||
IDENT "i32" | ||
COMMA "," | ||
WHITESPACE " " | ||
PARAM | ||
PATH_TYPE | ||
PATH | ||
PATH_SEGMENT | ||
NAME_REF | ||
IDENT "i32" | ||
R_PAREN ")" | ||
COLON ":" | ||
WHITESPACE " " | ||
TYPE_BOUND_LIST | ||
TYPE_BOUND | ||
PATH_TYPE | ||
PATH | ||
PATH_SEGMENT | ||
NAME_REF | ||
IDENT "Send" | ||
R_ANGLE ">" | ||
R_ANGLE ">" | ||
PARAM_LIST | ||
L_PAREN "(" | ||
R_PAREN ")" | ||
WHITESPACE " " | ||
BLOCK_EXPR | ||
STMT_LIST | ||
L_CURLY "{" | ||
R_CURLY "}" | ||
WHITESPACE "\n" |
1 change: 1 addition & 0 deletions
1
crates/parser/test_data/parser/inline/ok/0208_associated_return_type_bounds.rs
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 @@ | ||
fn foo<T: Foo<foo(): Send, bar(i32): Send, baz(i32, i32): Send>>() {} |
Oops, something went wrong.