diff options
author | Aleksey Kladov <[email protected]> | 2020-07-31 11:06:38 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-07-31 11:14:37 +0100 |
commit | 08ea2271e8050165d0aaf4c994ed3dd746aff3ba (patch) | |
tree | 1d5bb4ce799c6377b49ae73436d50a087db53392 /xtask/src | |
parent | e0f21133cd03c6160fbc97b70bbd50ccde4fe6d9 (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')
-rw-r--r-- | xtask/src/codegen/gen_syntax.rs | 8 | ||||
-rw-r--r-- | xtask/src/codegen/rust.ungram | 54 |
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 = | |||
61 | SelfParam = | 61 | SelfParam = |
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 | ||
67 | Param = | 67 | Param = |
68 | Attr* ( | 68 | Attr* ( |
69 | Pat (':' ty:TypeRef) | 69 | Pat (':' Type) |
70 | | ty:TypeRef | 70 | | Type |
71 | | '...' | 71 | | '...' |
72 | ) | 72 | ) |
73 | 73 | ||
74 | RetType = | 74 | RetType = |
75 | '->' ty:TypeRef | 75 | '->' Type |
76 | 76 | ||
77 | TypeAlias = | 77 | TypeAlias = |
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 | ||
81 | Struct = | 81 | Struct = |
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 | ||
90 | RecordField = | 90 | RecordField = |
91 | Attr* Visibility? Name ':' ty:TypeRef | 91 | Attr* Visibility? Name ':' Type |
92 | 92 | ||
93 | TupleFieldList = | 93 | TupleFieldList = |
94 | '(' fields:(TupleField (',' TupleField)* ','?)? ')' | 94 | '(' fields:(TupleField (',' TupleField)* ','?)? ')' |
95 | 95 | ||
96 | TupleField = | 96 | TupleField = |
97 | Attr* Visibility? ty:TypeRef | 97 | Attr* Visibility? Type |
98 | 98 | ||
99 | FieldList = | 99 | FieldList = |
100 | RecordFieldList | 100 | RecordFieldList |
@@ -120,11 +120,11 @@ AdtDef = | |||
120 | | Union | 120 | | Union |
121 | 121 | ||
122 | Const = | 122 | Const = |
123 | Attr* Visibility? 'default'? 'const' (Name | '_') ':' ty:TypeRef | 123 | Attr* Visibility? 'default'? 'const' (Name | '_') ':' Type |
124 | '=' body:Expr ';' | 124 | '=' body:Expr ';' |
125 | 125 | ||
126 | Static = | 126 | Static = |
127 | Attr* Visibility? 'static'? 'mut'? Name ':' ty:TypeRef | 127 | Attr* Visibility? 'static'? 'mut'? Name ':' Type |
128 | '=' body:Expr ';' | 128 | '=' body:Expr ';' |
129 | 129 | ||
130 | Trait = | 130 | Trait = |
@@ -144,8 +144,8 @@ AssocItem = | |||
144 | Impl = | 144 | Impl = |
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 | ||
169 | TypeParam = | 169 | TypeParam = |
170 | Attr* Name (':' TypeBoundList?)? | 170 | Attr* Name (':' TypeBoundList?)? |
171 | ('=' default_type:TypeRef)? | 171 | ('=' default_type:Type)? |
172 | 172 | ||
173 | ConstParam = | 173 | ConstParam = |
174 | Attr* 'const' Name ':' ty:TypeRef | 174 | Attr* 'const' Name ':' Type |
175 | ('=' default_val:Expr)? | 175 | ('=' default_val:Expr)? |
176 | 176 | ||
177 | LifetimeParam = | 177 | LifetimeParam = |
@@ -188,7 +188,7 @@ Visibility = | |||
188 | Attr = | 188 | Attr = |
189 | '#' '!'? '[' Path ('=' Literal | TokenTree)? ']' | 189 | '#' '!'? '[' Path ('=' Literal | TokenTree)? ']' |
190 | 190 | ||
191 | TypeRef = | 191 | Type = |
192 | ParenType | 192 | ParenType |
193 | | TupleType | 193 | | TupleType |
194 | | NeverType | 194 | | NeverType |
@@ -204,10 +204,10 @@ TypeRef = | |||
204 | | DynTraitType | 204 | | DynTraitType |
205 | 205 | ||
206 | ParenType = | 206 | ParenType = |
207 | '(' ty:TypeRef ')' | 207 | '(' Type ')' |
208 | 208 | ||
209 | TupleType = | 209 | TupleType = |
210 | '(' fields:TypeRef* ')' | 210 | '(' fields:Type* ')' |
211 | 211 | ||
212 | NeverType = | 212 | NeverType = |
213 | '!' | 213 | '!' |
@@ -216,16 +216,16 @@ PathType = | |||
216 | Path | 216 | Path |
217 | 217 | ||
218 | PointerType = | 218 | PointerType = |
219 | '*' ('const' | 'mut') ty:TypeRef | 219 | '*' ('const' | 'mut') Type |
220 | 220 | ||
221 | ArrayType = | 221 | ArrayType = |
222 | '[' ty:TypeRef ';' Expr ']' | 222 | '[' Type ';' Expr ']' |
223 | 223 | ||
224 | SliceType = | 224 | SliceType = |
225 | '[' ty:TypeRef ']' | 225 | '[' Type ']' |
226 | 226 | ||
227 | ReferenceType = | 227 | ReferenceType = |
228 | '&' 'lifetime'? 'mut'? ty:TypeRef | 228 | '&' 'lifetime'? 'mut'? Type |
229 | 229 | ||
230 | PlaceholderType = | 230 | PlaceholderType = |
231 | '_' | 231 | '_' |
@@ -234,7 +234,7 @@ FnPointerType = | |||
234 | Abi 'unsafe'? 'fn' ParamList RetType? | 234 | Abi 'unsafe'? 'fn' ParamList RetType? |
235 | 235 | ||
236 | ForType = | 236 | ForType = |
237 | 'for' GenericParamList ty:TypeRef | 237 | 'for' GenericParamList Type |
238 | 238 | ||
239 | ImplTraitType = | 239 | ImplTraitType = |
240 | 'impl' TypeBoundList | 240 | 'impl' TypeBoundList |
@@ -322,7 +322,7 @@ TryExpr = | |||
322 | Attr* Expr '?' | 322 | Attr* Expr '?' |
323 | 323 | ||
324 | CastExpr = | 324 | CastExpr = |
325 | Attr* Expr 'as' ty:TypeRef | 325 | Attr* Expr 'as' Type |
326 | 326 | ||
327 | RefExpr = | 327 | RefExpr = |
328 | Attr* '&' ('raw' | 'mut' | 'const') Expr | 328 | Attr* '&' ('raw' | 'mut' | 'const') Expr |
@@ -444,13 +444,13 @@ MacroStmts = | |||
444 | Expr? | 444 | Expr? |
445 | 445 | ||
446 | TypeBound = | 446 | TypeBound = |
447 | 'lifetime' | 'const'? TypeRef | 447 | 'lifetime' | 'const'? Type |
448 | 448 | ||
449 | TypeBoundList = | 449 | TypeBoundList = |
450 | bounds:TypeBound* | 450 | bounds:TypeBound* |
451 | 451 | ||
452 | WherePred = | 452 | WherePred = |
453 | ('for' GenericParamList)? ('lifetime' | TypeRef) ':' TypeBoundList | 453 | ('for' GenericParamList)? ('lifetime' | Type) ':' TypeBoundList |
454 | 454 | ||
455 | WhereClause = | 455 | WhereClause = |
456 | 'where' predicates:WherePred* | 456 | 'where' predicates:WherePred* |
@@ -459,7 +459,7 @@ ExprStmt = | |||
459 | Attr* Expr ';' | 459 | Attr* Expr ';' |
460 | 460 | ||
461 | LetStmt = | 461 | LetStmt = |
462 | Attr* 'let' Pat (':' ty:TypeRef) | 462 | Attr* 'let' Pat (':' Type) |
463 | '=' initializer:Expr ';' | 463 | '=' initializer:Expr ';' |
464 | 464 | ||
465 | Path = | 465 | Path = |
@@ -478,10 +478,10 @@ TypeArgList = | |||
478 | '>' | 478 | '>' |
479 | 479 | ||
480 | TypeArg = | 480 | TypeArg = |
481 | TypeRef | 481 | Type |
482 | 482 | ||
483 | AssocTypeArg = | 483 | AssocTypeArg = |
484 | NameRef (':' TypeBoundList | '=' TypeRef) | 484 | NameRef (':' TypeBoundList | '=' Type) |
485 | 485 | ||
486 | LifetimeArg = | 486 | LifetimeArg = |
487 | 'lifetime' | 487 | 'lifetime' |