aboutsummaryrefslogtreecommitdiff
path: root/xtask/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-07-31 11:18:53 +0100
committerGitHub <[email protected]>2020-07-31 11:18:53 +0100
commit683d0a4d93c29c988c40c001a4b574d8f0dcb9c6 (patch)
tree1d5bb4ce799c6377b49ae73436d50a087db53392 /xtask/src
parent6b7cb8b5ab539fc4333ce34bc29bf77c976f232a (diff)
parent08ea2271e8050165d0aaf4c994ed3dd746aff3ba (diff)
Merge #5618
5618: Rename TypeRef -> Type r=matklad a=matklad The TypeRef name comes from IntelliJ days, where you often have both type *syntax* as well as *semantical* representation of types in scope. And naming both Type is confusing. In rust-analyzer however, we use ast types as `ast::Type`, and have many more semantic counterparts to ast types, so avoiding name clash here is just confusing. bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'xtask/src')
-rw-r--r--xtask/src/codegen/gen_syntax.rs8
-rw-r--r--xtask/src/codegen/rust.ungram92
2 files changed, 53 insertions, 47 deletions
diff --git a/xtask/src/codegen/gen_syntax.rs b/xtask/src/codegen/gen_syntax.rs
index 45b788bdb..d6a72ccc0 100644
--- a/xtask/src/codegen/gen_syntax.rs
+++ b/xtask/src/codegen/gen_syntax.rs
@@ -476,7 +476,13 @@ impl Field {
476 }; 476 };
477 format_ident!("{}_token", name) 477 format_ident!("{}_token", name)
478 } 478 }
479 Field::Node { name, .. } => format_ident!("{}", name), 479 Field::Node { name, .. } => {
480 if name == "type" {
481 format_ident!("ty")
482 } else {
483 format_ident!("{}", name)
484 }
485 }
480 } 486 }
481 } 487 }
482 fn ty(&self) -> proc_macro2::Ident { 488 fn ty(&self) -> proc_macro2::Ident {
diff --git a/xtask/src/codegen/rust.ungram b/xtask/src/codegen/rust.ungram
index 375df301f..8f0e66278 100644
--- a/xtask/src/codegen/rust.ungram
+++ b/xtask/src/codegen/rust.ungram
@@ -61,22 +61,22 @@ ParamList =
61SelfParam = 61SelfParam =
62 Attr* ( 62 Attr* (
63 ('&' 'lifetime'?)? 'mut'? 'self' 63 ('&' 'lifetime'?)? 'mut'? 'self'
64 | 'mut'? 'self' ':' ty:TypeRef 64 | 'mut'? 'self' ':' Type
65 ) 65 )
66 66
67Param = 67Param =
68 Attr* ( 68 Attr* (
69 Pat (':' ty:TypeRef) 69 Pat (':' Type)
70 | ty:TypeRef 70 | Type
71 | '...' 71 | '...'
72 ) 72 )
73 73
74RetType = 74RetType =
75 '->' ty:TypeRef 75 '->' Type
76 76
77TypeAlias = 77TypeAlias =
78 Attr* Visibility? 'default'? 'type' Name GenericParamList? (':' TypeBoundList?)? WhereClause? 78 Attr* Visibility? 'default'? 'type' Name GenericParamList? (':' TypeBoundList?)? WhereClause?
79 '=' ty:TypeRef ';' 79 '=' Type ';'
80 80
81Struct = 81Struct =
82 Attr* Visibility? 'struct' Name GenericParamList? ( 82 Attr* Visibility? 'struct' Name GenericParamList? (
@@ -88,13 +88,13 @@ RecordFieldList =
88 '{' fields:(RecordField (',' RecordField)* ','?)? '}' 88 '{' fields:(RecordField (',' RecordField)* ','?)? '}'
89 89
90RecordField = 90RecordField =
91 Attr* Visibility? Name ':' ty:TypeRef 91 Attr* Visibility? Name ':' Type
92 92
93TupleFieldList = 93TupleFieldList =
94 '(' fields:(TupleField (',' TupleField)* ','?)? ')' 94 '(' fields:(TupleField (',' TupleField)* ','?)? ')'
95 95
96TupleField = 96TupleField =
97 Attr* Visibility? ty:TypeRef 97 Attr* Visibility? Type
98 98
99FieldList = 99FieldList =
100 RecordFieldList 100 RecordFieldList
@@ -114,12 +114,17 @@ Union =
114 Attr* Visibility? 'union' Name GenericParamList? WhereClause? 114 Attr* Visibility? 'union' Name GenericParamList? WhereClause?
115 RecordFieldList 115 RecordFieldList
116 116
117AdtDef =
118 Struct
119| Enum
120| Union
121
117Const = 122Const =
118 Attr* Visibility? 'default'? 'const' (Name | '_') ':' ty:TypeRef 123 Attr* Visibility? 'default'? 'const' (Name | '_') ':' Type
119 '=' body:Expr ';' 124 '=' body:Expr ';'
120 125
121Static = 126Static =
122 Attr* Visibility? 'static'? 'mut'? Name ':' ty:TypeRef 127 Attr* Visibility? 'static'? 'mut'? Name ':' Type
123 '=' body:Expr ';' 128 '=' body:Expr ';'
124 129
125Trait = 130Trait =
@@ -139,8 +144,8 @@ AssocItem =
139Impl = 144Impl =
140 Attr* Visibility? 145 Attr* Visibility?
141 'default'? 'unsafe'? 'impl' 'const'? GenericParamList? ( 146 'default'? 'unsafe'? 'impl' 'const'? GenericParamList? (
142 TypeRef 147 Type
143 | '!'? TypeRef 'for' TypeRef 148 | '!'? Type 'for' Type
144 ) WhereClause? 149 ) WhereClause?
145 AssocItemList 150 AssocItemList
146 151
@@ -163,10 +168,10 @@ GenericParam =
163 168
164TypeParam = 169TypeParam =
165 Attr* Name (':' TypeBoundList?)? 170 Attr* Name (':' TypeBoundList?)?
166 ('=' default_type:TypeRef)? 171 ('=' default_type:Type)?
167 172
168ConstParam = 173ConstParam =
169 Attr* 'const' Name ':' ty:TypeRef 174 Attr* 'const' Name ':' Type
170 ('=' default_val:Expr)? 175 ('=' default_val:Expr)?
171 176
172LifetimeParam = 177LifetimeParam =
@@ -183,11 +188,26 @@ Visibility =
183Attr = 188Attr =
184 '#' '!'? '[' Path ('=' Literal | TokenTree)? ']' 189 '#' '!'? '[' Path ('=' Literal | TokenTree)? ']'
185 190
191Type =
192 ParenType
193| TupleType
194| NeverType
195| PathType
196| PointerType
197| ArrayType
198| SliceType
199| ReferenceType
200| PlaceholderType
201| FnPointerType
202| ForType
203| ImplTraitType
204| DynTraitType
205
186ParenType = 206ParenType =
187 '(' ty:TypeRef ')' 207 '(' Type ')'
188 208
189TupleType = 209TupleType =
190 '(' fields:TypeRef* ')' 210 '(' fields:Type* ')'
191 211
192NeverType = 212NeverType =
193 '!' 213 '!'
@@ -196,16 +216,16 @@ PathType =
196 Path 216 Path
197 217
198PointerType = 218PointerType =
199 '*' ('const' | 'mut') ty:TypeRef 219 '*' ('const' | 'mut') Type
200 220
201ArrayType = 221ArrayType =
202 '[' ty:TypeRef ';' Expr ']' 222 '[' Type ';' Expr ']'
203 223
204SliceType = 224SliceType =
205 '[' ty:TypeRef ']' 225 '[' Type ']'
206 226
207ReferenceType = 227ReferenceType =
208 '&' 'lifetime'? 'mut'? ty:TypeRef 228 '&' 'lifetime'? 'mut'? Type
209 229
210PlaceholderType = 230PlaceholderType =
211 '_' 231 '_'
@@ -214,7 +234,7 @@ FnPointerType =
214 Abi 'unsafe'? 'fn' ParamList RetType? 234 Abi 'unsafe'? 'fn' ParamList RetType?
215 235
216ForType = 236ForType =
217 'for' GenericParamList ty:TypeRef 237 'for' GenericParamList Type
218 238
219ImplTraitType = 239ImplTraitType =
220 'impl' TypeBoundList 240 'impl' TypeBoundList
@@ -302,7 +322,7 @@ TryExpr =
302 Attr* Expr '?' 322 Attr* Expr '?'
303 323
304CastExpr = 324CastExpr =
305 Attr* Expr 'as' ty:TypeRef 325 Attr* Expr 'as' Type
306 326
307RefExpr = 327RefExpr =
308 Attr* '&' ('raw' | 'mut' | 'const') Expr 328 Attr* '&' ('raw' | 'mut' | 'const') Expr
@@ -424,13 +444,13 @@ MacroStmts =
424 Expr? 444 Expr?
425 445
426TypeBound = 446TypeBound =
427 'lifetime' | 'const'? TypeRef 447 'lifetime' | 'const'? Type
428 448
429TypeBoundList = 449TypeBoundList =
430 bounds:TypeBound* 450 bounds:TypeBound*
431 451
432WherePred = 452WherePred =
433 ('for' GenericParamList)? ('lifetime' | TypeRef) ':' TypeBoundList 453 ('for' GenericParamList)? ('lifetime' | Type) ':' TypeBoundList
434 454
435WhereClause = 455WhereClause =
436 'where' predicates:WherePred* 456 'where' predicates:WherePred*
@@ -439,7 +459,7 @@ ExprStmt =
439 Attr* Expr ';' 459 Attr* Expr ';'
440 460
441LetStmt = 461LetStmt =
442 Attr* 'let' Pat (':' ty:TypeRef) 462 Attr* 'let' Pat (':' Type)
443 '=' initializer:Expr ';' 463 '=' initializer:Expr ';'
444 464
445Path = 465Path =
@@ -458,10 +478,10 @@ TypeArgList =
458 '>' 478 '>'
459 479
460TypeArg = 480TypeArg =
461 TypeRef 481 Type
462 482
463AssocTypeArg = 483AssocTypeArg =
464 NameRef (':' TypeBoundList | '=' TypeRef) 484 NameRef (':' TypeBoundList | '=' Type)
465 485
466LifetimeArg = 486LifetimeArg =
467 'lifetime' 487 'lifetime'
@@ -469,26 +489,6 @@ LifetimeArg =
469ConstArg = 489ConstArg =
470 Literal | BlockExpr BlockExpr 490 Literal | BlockExpr BlockExpr
471 491
472AdtDef =
473 Struct
474| Enum
475| Union
476
477TypeRef =
478 ParenType
479| TupleType
480| NeverType
481| PathType
482| PointerType
483| ArrayType
484| SliceType
485| ReferenceType
486| PlaceholderType
487| FnPointerType
488| ForType
489| ImplTraitType
490| DynTraitType
491
492Stmt = 492Stmt =
493 LetStmt 493 LetStmt
494| ExprStmt 494| ExprStmt