aboutsummaryrefslogtreecommitdiff
path: root/xtask/src/codegen
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-07-31 11:06:38 +0100
committerAleksey Kladov <[email protected]>2020-07-31 11:14:37 +0100
commit08ea2271e8050165d0aaf4c994ed3dd746aff3ba (patch)
tree1d5bb4ce799c6377b49ae73436d50a087db53392 /xtask/src/codegen
parente0f21133cd03c6160fbc97b70bbd50ccde4fe6d9 (diff)
Rename TypeRef -> Type
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.
Diffstat (limited to 'xtask/src/codegen')
-rw-r--r--xtask/src/codegen/gen_syntax.rs8
-rw-r--r--xtask/src/codegen/rust.ungram54
2 files changed, 34 insertions, 28 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 1c1dec80a..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
@@ -120,11 +120,11 @@ AdtDef =
120| Union 120| Union
121 121
122Const = 122Const =
123 Attr* Visibility? 'default'? 'const' (Name | '_') ':' ty:TypeRef 123 Attr* Visibility? 'default'? 'const' (Name | '_') ':' Type
124 '=' body:Expr ';' 124 '=' body:Expr ';'
125 125
126Static = 126Static =
127 Attr* Visibility? 'static'? 'mut'? Name ':' ty:TypeRef 127 Attr* Visibility? 'static'? 'mut'? Name ':' Type
128 '=' body:Expr ';' 128 '=' body:Expr ';'
129 129
130Trait = 130Trait =
@@ -144,8 +144,8 @@ AssocItem =
144Impl = 144Impl =
145 Attr* Visibility? 145 Attr* Visibility?
146 'default'? 'unsafe'? 'impl' 'const'? GenericParamList? ( 146 'default'? 'unsafe'? 'impl' 'const'? GenericParamList? (
147 TypeRef 147 Type
148 | '!'? TypeRef 'for' TypeRef 148 | '!'? Type 'for' Type
149 ) WhereClause? 149 ) WhereClause?
150 AssocItemList 150 AssocItemList
151 151
@@ -168,10 +168,10 @@ GenericParam =
168 168
169TypeParam = 169TypeParam =
170 Attr* Name (':' TypeBoundList?)? 170 Attr* Name (':' TypeBoundList?)?
171 ('=' default_type:TypeRef)? 171 ('=' default_type:Type)?
172 172
173ConstParam = 173ConstParam =
174 Attr* 'const' Name ':' ty:TypeRef 174 Attr* 'const' Name ':' Type
175 ('=' default_val:Expr)? 175 ('=' default_val:Expr)?
176 176
177LifetimeParam = 177LifetimeParam =
@@ -188,7 +188,7 @@ Visibility =
188Attr = 188Attr =
189 '#' '!'? '[' Path ('=' Literal | TokenTree)? ']' 189 '#' '!'? '[' Path ('=' Literal | TokenTree)? ']'
190 190
191TypeRef = 191Type =
192 ParenType 192 ParenType
193| TupleType 193| TupleType
194| NeverType 194| NeverType
@@ -204,10 +204,10 @@ TypeRef =
204| DynTraitType 204| DynTraitType
205 205
206ParenType = 206ParenType =
207 '(' ty:TypeRef ')' 207 '(' Type ')'
208 208
209TupleType = 209TupleType =
210 '(' fields:TypeRef* ')' 210 '(' fields:Type* ')'
211 211
212NeverType = 212NeverType =
213 '!' 213 '!'
@@ -216,16 +216,16 @@ PathType =
216 Path 216 Path
217 217
218PointerType = 218PointerType =
219 '*' ('const' | 'mut') ty:TypeRef 219 '*' ('const' | 'mut') Type
220 220
221ArrayType = 221ArrayType =
222 '[' ty:TypeRef ';' Expr ']' 222 '[' Type ';' Expr ']'
223 223
224SliceType = 224SliceType =
225 '[' ty:TypeRef ']' 225 '[' Type ']'
226 226
227ReferenceType = 227ReferenceType =
228 '&' 'lifetime'? 'mut'? ty:TypeRef 228 '&' 'lifetime'? 'mut'? Type
229 229
230PlaceholderType = 230PlaceholderType =
231 '_' 231 '_'
@@ -234,7 +234,7 @@ FnPointerType =
234 Abi 'unsafe'? 'fn' ParamList RetType? 234 Abi 'unsafe'? 'fn' ParamList RetType?
235 235
236ForType = 236ForType =
237 'for' GenericParamList ty:TypeRef 237 'for' GenericParamList Type
238 238
239ImplTraitType = 239ImplTraitType =
240 'impl' TypeBoundList 240 'impl' TypeBoundList
@@ -322,7 +322,7 @@ TryExpr =
322 Attr* Expr '?' 322 Attr* Expr '?'
323 323
324CastExpr = 324CastExpr =
325 Attr* Expr 'as' ty:TypeRef 325 Attr* Expr 'as' Type
326 326
327RefExpr = 327RefExpr =
328 Attr* '&' ('raw' | 'mut' | 'const') Expr 328 Attr* '&' ('raw' | 'mut' | 'const') Expr
@@ -444,13 +444,13 @@ MacroStmts =
444 Expr? 444 Expr?
445 445
446TypeBound = 446TypeBound =
447 'lifetime' | 'const'? TypeRef 447 'lifetime' | 'const'? Type
448 448
449TypeBoundList = 449TypeBoundList =
450 bounds:TypeBound* 450 bounds:TypeBound*
451 451
452WherePred = 452WherePred =
453 ('for' GenericParamList)? ('lifetime' | TypeRef) ':' TypeBoundList 453 ('for' GenericParamList)? ('lifetime' | Type) ':' TypeBoundList
454 454
455WhereClause = 455WhereClause =
456 'where' predicates:WherePred* 456 'where' predicates:WherePred*
@@ -459,7 +459,7 @@ ExprStmt =
459 Attr* Expr ';' 459 Attr* Expr ';'
460 460
461LetStmt = 461LetStmt =
462 Attr* 'let' Pat (':' ty:TypeRef) 462 Attr* 'let' Pat (':' Type)
463 '=' initializer:Expr ';' 463 '=' initializer:Expr ';'
464 464
465Path = 465Path =
@@ -478,10 +478,10 @@ TypeArgList =
478 '>' 478 '>'
479 479
480TypeArg = 480TypeArg =
481 TypeRef 481 Type
482 482
483AssocTypeArg = 483AssocTypeArg =
484 NameRef (':' TypeBoundList | '=' TypeRef) 484 NameRef (':' TypeBoundList | '=' Type)
485 485
486LifetimeArg = 486LifetimeArg =
487 'lifetime' 487 'lifetime'