diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-31 11:18:53 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-31 11:18:53 +0100 |
commit | 683d0a4d93c29c988c40c001a4b574d8f0dcb9c6 (patch) | |
tree | 1d5bb4ce799c6377b49ae73436d50a087db53392 /xtask/src | |
parent | 6b7cb8b5ab539fc4333ce34bc29bf77c976f232a (diff) | |
parent | 08ea2271e8050165d0aaf4c994ed3dd746aff3ba (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.rs | 8 | ||||
-rw-r--r-- | xtask/src/codegen/rust.ungram | 92 |
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 = | |||
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 |
@@ -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 | ||
117 | AdtDef = | ||
118 | Struct | ||
119 | | Enum | ||
120 | | Union | ||
121 | |||
117 | Const = | 122 | Const = |
118 | Attr* Visibility? 'default'? 'const' (Name | '_') ':' ty:TypeRef | 123 | Attr* Visibility? 'default'? 'const' (Name | '_') ':' Type |
119 | '=' body:Expr ';' | 124 | '=' body:Expr ';' |
120 | 125 | ||
121 | Static = | 126 | Static = |
122 | Attr* Visibility? 'static'? 'mut'? Name ':' ty:TypeRef | 127 | Attr* Visibility? 'static'? 'mut'? Name ':' Type |
123 | '=' body:Expr ';' | 128 | '=' body:Expr ';' |
124 | 129 | ||
125 | Trait = | 130 | Trait = |
@@ -139,8 +144,8 @@ AssocItem = | |||
139 | Impl = | 144 | Impl = |
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 | ||
164 | TypeParam = | 169 | TypeParam = |
165 | Attr* Name (':' TypeBoundList?)? | 170 | Attr* Name (':' TypeBoundList?)? |
166 | ('=' default_type:TypeRef)? | 171 | ('=' default_type:Type)? |
167 | 172 | ||
168 | ConstParam = | 173 | ConstParam = |
169 | Attr* 'const' Name ':' ty:TypeRef | 174 | Attr* 'const' Name ':' Type |
170 | ('=' default_val:Expr)? | 175 | ('=' default_val:Expr)? |
171 | 176 | ||
172 | LifetimeParam = | 177 | LifetimeParam = |
@@ -183,11 +188,26 @@ Visibility = | |||
183 | Attr = | 188 | Attr = |
184 | '#' '!'? '[' Path ('=' Literal | TokenTree)? ']' | 189 | '#' '!'? '[' Path ('=' Literal | TokenTree)? ']' |
185 | 190 | ||
191 | Type = | ||
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 | |||
186 | ParenType = | 206 | ParenType = |
187 | '(' ty:TypeRef ')' | 207 | '(' Type ')' |
188 | 208 | ||
189 | TupleType = | 209 | TupleType = |
190 | '(' fields:TypeRef* ')' | 210 | '(' fields:Type* ')' |
191 | 211 | ||
192 | NeverType = | 212 | NeverType = |
193 | '!' | 213 | '!' |
@@ -196,16 +216,16 @@ PathType = | |||
196 | Path | 216 | Path |
197 | 217 | ||
198 | PointerType = | 218 | PointerType = |
199 | '*' ('const' | 'mut') ty:TypeRef | 219 | '*' ('const' | 'mut') Type |
200 | 220 | ||
201 | ArrayType = | 221 | ArrayType = |
202 | '[' ty:TypeRef ';' Expr ']' | 222 | '[' Type ';' Expr ']' |
203 | 223 | ||
204 | SliceType = | 224 | SliceType = |
205 | '[' ty:TypeRef ']' | 225 | '[' Type ']' |
206 | 226 | ||
207 | ReferenceType = | 227 | ReferenceType = |
208 | '&' 'lifetime'? 'mut'? ty:TypeRef | 228 | '&' 'lifetime'? 'mut'? Type |
209 | 229 | ||
210 | PlaceholderType = | 230 | PlaceholderType = |
211 | '_' | 231 | '_' |
@@ -214,7 +234,7 @@ FnPointerType = | |||
214 | Abi 'unsafe'? 'fn' ParamList RetType? | 234 | Abi 'unsafe'? 'fn' ParamList RetType? |
215 | 235 | ||
216 | ForType = | 236 | ForType = |
217 | 'for' GenericParamList ty:TypeRef | 237 | 'for' GenericParamList Type |
218 | 238 | ||
219 | ImplTraitType = | 239 | ImplTraitType = |
220 | 'impl' TypeBoundList | 240 | 'impl' TypeBoundList |
@@ -302,7 +322,7 @@ TryExpr = | |||
302 | Attr* Expr '?' | 322 | Attr* Expr '?' |
303 | 323 | ||
304 | CastExpr = | 324 | CastExpr = |
305 | Attr* Expr 'as' ty:TypeRef | 325 | Attr* Expr 'as' Type |
306 | 326 | ||
307 | RefExpr = | 327 | RefExpr = |
308 | Attr* '&' ('raw' | 'mut' | 'const') Expr | 328 | Attr* '&' ('raw' | 'mut' | 'const') Expr |
@@ -424,13 +444,13 @@ MacroStmts = | |||
424 | Expr? | 444 | Expr? |
425 | 445 | ||
426 | TypeBound = | 446 | TypeBound = |
427 | 'lifetime' | 'const'? TypeRef | 447 | 'lifetime' | 'const'? Type |
428 | 448 | ||
429 | TypeBoundList = | 449 | TypeBoundList = |
430 | bounds:TypeBound* | 450 | bounds:TypeBound* |
431 | 451 | ||
432 | WherePred = | 452 | WherePred = |
433 | ('for' GenericParamList)? ('lifetime' | TypeRef) ':' TypeBoundList | 453 | ('for' GenericParamList)? ('lifetime' | Type) ':' TypeBoundList |
434 | 454 | ||
435 | WhereClause = | 455 | WhereClause = |
436 | 'where' predicates:WherePred* | 456 | 'where' predicates:WherePred* |
@@ -439,7 +459,7 @@ ExprStmt = | |||
439 | Attr* Expr ';' | 459 | Attr* Expr ';' |
440 | 460 | ||
441 | LetStmt = | 461 | LetStmt = |
442 | Attr* 'let' Pat (':' ty:TypeRef) | 462 | Attr* 'let' Pat (':' Type) |
443 | '=' initializer:Expr ';' | 463 | '=' initializer:Expr ';' |
444 | 464 | ||
445 | Path = | 465 | Path = |
@@ -458,10 +478,10 @@ TypeArgList = | |||
458 | '>' | 478 | '>' |
459 | 479 | ||
460 | TypeArg = | 480 | TypeArg = |
461 | TypeRef | 481 | Type |
462 | 482 | ||
463 | AssocTypeArg = | 483 | AssocTypeArg = |
464 | NameRef (':' TypeBoundList | '=' TypeRef) | 484 | NameRef (':' TypeBoundList | '=' Type) |
465 | 485 | ||
466 | LifetimeArg = | 486 | LifetimeArg = |
467 | 'lifetime' | 487 | 'lifetime' |
@@ -469,26 +489,6 @@ LifetimeArg = | |||
469 | ConstArg = | 489 | ConstArg = |
470 | Literal | BlockExpr BlockExpr | 490 | Literal | BlockExpr BlockExpr |
471 | 491 | ||
472 | AdtDef = | ||
473 | Struct | ||
474 | | Enum | ||
475 | | Union | ||
476 | |||
477 | TypeRef = | ||
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 | |||
492 | Stmt = | 492 | Stmt = |
493 | LetStmt | 493 | LetStmt |
494 | | ExprStmt | 494 | | ExprStmt |