-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(GRAM): allow empty type parameter lists
This is valid Rust: rust-lang/rust#32023
- Loading branch information
Showing
4 changed files
with
277 additions
and
6 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
23 changes: 23 additions & 0 deletions
23
src/test/resources/org/rust/lang/core/parser/fixtures/well-formed/empty_generics.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,23 @@ | ||
// Test that empty type parameter list (<>) is synonymous with | ||
// no type parameters at all | ||
|
||
struct S<>; | ||
trait T<> {} | ||
enum E<> { V } | ||
impl<> T<> for S<> {} | ||
impl T for E {} | ||
fn foo<>() {} | ||
fn bar() {} | ||
|
||
fn main() { | ||
let _ = S; | ||
let _ = S::<>; | ||
let _ = E::V; | ||
let _ = E::<>::V; | ||
foo(); | ||
foo::<>(); | ||
|
||
// Test that we can supply <> to non generic things | ||
bar::<>(); | ||
let _: i32<>; | ||
} |
252 changes: 252 additions & 0 deletions
252
src/test/resources/org/rust/lang/core/parser/fixtures/well-formed/empty_generics.txt
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,252 @@ | ||
FILE | ||
PsiComment(<EOL_COMMENT>)('// Test that empty type parameter list (<>) is synonymous with') | ||
PsiWhiteSpace('\n') | ||
PsiComment(<EOL_COMMENT>)('// no type parameters at all') | ||
PsiWhiteSpace('\n\n') | ||
RustFileModItemImpl(FILE_MOD_ITEM) | ||
RustStructItemImpl(STRUCT_ITEM) | ||
PsiElement(struct)('struct') | ||
PsiWhiteSpace(' ') | ||
PsiElement(<IDENTIFIER>)('S') | ||
RustGenericParamsImpl(GENERIC_PARAMS) | ||
PsiElement(<)('<') | ||
PsiElement(>)('>') | ||
PsiElement(;)(';') | ||
PsiWhiteSpace('\n') | ||
RustTraitItemImpl(TRAIT_ITEM) | ||
PsiElement(trait)('trait') | ||
PsiWhiteSpace(' ') | ||
PsiElement(<IDENTIFIER>)('T') | ||
RustGenericParamsImpl(GENERIC_PARAMS) | ||
PsiElement(<)('<') | ||
PsiElement(>)('>') | ||
PsiWhiteSpace(' ') | ||
PsiElement({)('{') | ||
PsiElement(})('}') | ||
PsiWhiteSpace('\n') | ||
RustEnumItemImpl(ENUM_ITEM) | ||
PsiElement(enum)('enum') | ||
PsiWhiteSpace(' ') | ||
PsiElement(<IDENTIFIER>)('E') | ||
RustGenericParamsImpl(GENERIC_PARAMS) | ||
PsiElement(<)('<') | ||
PsiElement(>)('>') | ||
PsiWhiteSpace(' ') | ||
PsiElement({)('{') | ||
PsiWhiteSpace(' ') | ||
RustEnumDefImpl(ENUM_DEF) | ||
PsiElement(<IDENTIFIER>)('V') | ||
PsiWhiteSpace(' ') | ||
PsiElement(})('}') | ||
PsiWhiteSpace('\n') | ||
RustImplItemImpl(IMPL_ITEM) | ||
PsiElement(impl)('impl') | ||
RustGenericParamsImpl(GENERIC_PARAMS) | ||
PsiElement(<)('<') | ||
PsiElement(>)('>') | ||
PsiWhiteSpace(' ') | ||
RustTraitRefImpl(TRAIT_REF) | ||
RustPathPartImpl(PATH_PART) | ||
PsiElement(<IDENTIFIER>)('T') | ||
RustGenericArgsImpl(GENERIC_ARGS) | ||
PsiElement(<)('<') | ||
PsiElement(>)('>') | ||
PsiWhiteSpace(' ') | ||
PsiElement(for)('for') | ||
PsiWhiteSpace(' ') | ||
RustTypeSumImpl(TYPE_SUM) | ||
RustPathPartImpl(PATH_PART) | ||
PsiElement(<IDENTIFIER>)('S') | ||
RustGenericArgsImpl(GENERIC_ARGS) | ||
PsiElement(<)('<') | ||
PsiElement(>)('>') | ||
PsiWhiteSpace(' ') | ||
PsiElement({)('{') | ||
PsiElement(})('}') | ||
PsiWhiteSpace('\n') | ||
RustImplItemImpl(IMPL_ITEM) | ||
PsiElement(impl)('impl') | ||
PsiWhiteSpace(' ') | ||
RustGenericParamsImpl(GENERIC_PARAMS) | ||
<empty list> | ||
RustTraitRefImpl(TRAIT_REF) | ||
RustPathPartImpl(PATH_PART) | ||
PsiElement(<IDENTIFIER>)('T') | ||
PsiWhiteSpace(' ') | ||
PsiElement(for)('for') | ||
PsiWhiteSpace(' ') | ||
RustTypeSumImpl(TYPE_SUM) | ||
RustPathPartImpl(PATH_PART) | ||
PsiElement(<IDENTIFIER>)('E') | ||
PsiWhiteSpace(' ') | ||
PsiElement({)('{') | ||
PsiElement(})('}') | ||
PsiWhiteSpace('\n') | ||
RustFnItemImpl(FN_ITEM) | ||
PsiElement(fn)('fn') | ||
PsiWhiteSpace(' ') | ||
PsiElement(<IDENTIFIER>)('foo') | ||
RustGenericParamsImpl(GENERIC_PARAMS) | ||
PsiElement(<)('<') | ||
PsiElement(>)('>') | ||
RustFnParamsImpl(FN_PARAMS) | ||
PsiElement(()('(') | ||
PsiElement())(')') | ||
PsiWhiteSpace(' ') | ||
RustBlockImpl(BLOCK) | ||
PsiElement({)('{') | ||
PsiElement(})('}') | ||
PsiWhiteSpace('\n') | ||
RustFnItemImpl(FN_ITEM) | ||
PsiElement(fn)('fn') | ||
PsiWhiteSpace(' ') | ||
PsiElement(<IDENTIFIER>)('bar') | ||
RustGenericParamsImpl(GENERIC_PARAMS) | ||
<empty list> | ||
RustFnParamsImpl(FN_PARAMS) | ||
PsiElement(()('(') | ||
PsiElement())(')') | ||
PsiWhiteSpace(' ') | ||
RustBlockImpl(BLOCK) | ||
PsiElement({)('{') | ||
PsiElement(})('}') | ||
PsiWhiteSpace('\n\n') | ||
RustFnItemImpl(FN_ITEM) | ||
PsiElement(fn)('fn') | ||
PsiWhiteSpace(' ') | ||
PsiElement(<IDENTIFIER>)('main') | ||
RustGenericParamsImpl(GENERIC_PARAMS) | ||
<empty list> | ||
RustFnParamsImpl(FN_PARAMS) | ||
PsiElement(()('(') | ||
PsiElement())(')') | ||
PsiWhiteSpace(' ') | ||
RustBlockImpl(BLOCK) | ||
PsiElement({)('{') | ||
PsiWhiteSpace('\n ') | ||
RustDeclStmtImpl(DECL_STMT) | ||
RustLetDeclImpl(LET_DECL) | ||
PsiElement(let)('let') | ||
PsiWhiteSpace(' ') | ||
RustPatWildImpl(PAT_WILD) | ||
PsiElement(_)('_') | ||
PsiWhiteSpace(' ') | ||
PsiElement(=)('=') | ||
PsiWhiteSpace(' ') | ||
RustPathExprImpl(PATH_EXPR) | ||
RustPathPartImpl(PATH_PART) | ||
PsiElement(<IDENTIFIER>)('S') | ||
PsiElement(;)(';') | ||
PsiWhiteSpace('\n ') | ||
RustDeclStmtImpl(DECL_STMT) | ||
RustLetDeclImpl(LET_DECL) | ||
PsiElement(let)('let') | ||
PsiWhiteSpace(' ') | ||
RustPatWildImpl(PAT_WILD) | ||
PsiElement(_)('_') | ||
PsiWhiteSpace(' ') | ||
PsiElement(=)('=') | ||
PsiWhiteSpace(' ') | ||
RustPathExprImpl(PATH_EXPR) | ||
RustPathPartImpl(PATH_PART) | ||
PsiElement(<IDENTIFIER>)('S') | ||
PsiElement(::)('::') | ||
RustGenericArgsImpl(GENERIC_ARGS) | ||
PsiElement(<)('<') | ||
PsiElement(>)('>') | ||
PsiElement(;)(';') | ||
PsiWhiteSpace('\n ') | ||
RustDeclStmtImpl(DECL_STMT) | ||
RustLetDeclImpl(LET_DECL) | ||
PsiElement(let)('let') | ||
PsiWhiteSpace(' ') | ||
RustPatWildImpl(PAT_WILD) | ||
PsiElement(_)('_') | ||
PsiWhiteSpace(' ') | ||
PsiElement(=)('=') | ||
PsiWhiteSpace(' ') | ||
RustPathExprImpl(PATH_EXPR) | ||
RustPathPartImpl(PATH_PART) | ||
RustPathPartImpl(PATH_PART) | ||
PsiElement(<IDENTIFIER>)('E') | ||
PsiElement(::)('::') | ||
PsiElement(<IDENTIFIER>)('V') | ||
PsiElement(;)(';') | ||
PsiWhiteSpace('\n ') | ||
RustDeclStmtImpl(DECL_STMT) | ||
RustLetDeclImpl(LET_DECL) | ||
PsiElement(let)('let') | ||
PsiWhiteSpace(' ') | ||
RustPatWildImpl(PAT_WILD) | ||
PsiElement(_)('_') | ||
PsiWhiteSpace(' ') | ||
PsiElement(=)('=') | ||
PsiWhiteSpace(' ') | ||
RustPathExprImpl(PATH_EXPR) | ||
RustPathPartImpl(PATH_PART) | ||
RustPathPartImpl(PATH_PART) | ||
PsiElement(<IDENTIFIER>)('E') | ||
PsiElement(::)('::') | ||
RustGenericArgsImpl(GENERIC_ARGS) | ||
PsiElement(<)('<') | ||
PsiElement(>)('>') | ||
PsiElement(::)('::') | ||
PsiElement(<IDENTIFIER>)('V') | ||
PsiElement(;)(';') | ||
PsiWhiteSpace('\n ') | ||
RustExprStmtImpl(EXPR_STMT) | ||
RustCallExprImpl(CALL_EXPR) | ||
RustPathExprImpl(PATH_EXPR) | ||
RustPathPartImpl(PATH_PART) | ||
PsiElement(<IDENTIFIER>)('foo') | ||
RustArgListImpl(ARG_LIST) | ||
PsiElement(()('(') | ||
PsiElement())(')') | ||
PsiElement(;)(';') | ||
PsiWhiteSpace('\n ') | ||
RustExprStmtImpl(EXPR_STMT) | ||
RustCallExprImpl(CALL_EXPR) | ||
RustPathExprImpl(PATH_EXPR) | ||
RustPathPartImpl(PATH_PART) | ||
PsiElement(<IDENTIFIER>)('foo') | ||
PsiElement(::)('::') | ||
RustGenericArgsImpl(GENERIC_ARGS) | ||
PsiElement(<)('<') | ||
PsiElement(>)('>') | ||
RustArgListImpl(ARG_LIST) | ||
PsiElement(()('(') | ||
PsiElement())(')') | ||
PsiElement(;)(';') | ||
PsiWhiteSpace('\n\n ') | ||
PsiComment(<EOL_COMMENT>)('// Test that we can supply <> to non generic things') | ||
PsiWhiteSpace('\n ') | ||
RustExprStmtImpl(EXPR_STMT) | ||
RustCallExprImpl(CALL_EXPR) | ||
RustPathExprImpl(PATH_EXPR) | ||
RustPathPartImpl(PATH_PART) | ||
PsiElement(<IDENTIFIER>)('bar') | ||
PsiElement(::)('::') | ||
RustGenericArgsImpl(GENERIC_ARGS) | ||
PsiElement(<)('<') | ||
PsiElement(>)('>') | ||
RustArgListImpl(ARG_LIST) | ||
PsiElement(()('(') | ||
PsiElement())(')') | ||
PsiElement(;)(';') | ||
PsiWhiteSpace('\n ') | ||
RustDeclStmtImpl(DECL_STMT) | ||
RustLetDeclImpl(LET_DECL) | ||
PsiElement(let)('let') | ||
PsiWhiteSpace(' ') | ||
RustPatWildImpl(PAT_WILD) | ||
PsiElement(_)('_') | ||
PsiElement(:)(':') | ||
PsiWhiteSpace(' ') | ||
RustPathPartImpl(PATH_PART) | ||
PsiElement(<IDENTIFIER>)('i32') | ||
RustGenericArgsImpl(GENERIC_ARGS) | ||
PsiElement(<)('<') | ||
PsiElement(>)('>') | ||
PsiElement(;)(';') | ||
PsiWhiteSpace('\n') | ||
PsiElement(})('}') |