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.
This commit is contained in:
Aleksey Kladov 2020-07-31 12:06:38 +02:00
parent e0f21133cd
commit 08ea2271e8
19 changed files with 209 additions and 203 deletions

View file

@ -476,7 +476,13 @@ impl Field {
};
format_ident!("{}_token", name)
}
Field::Node { name, .. } => format_ident!("{}", name),
Field::Node { name, .. } => {
if name == "type" {
format_ident!("ty")
} else {
format_ident!("{}", name)
}
}
}
}
fn ty(&self) -> proc_macro2::Ident {

View file

@ -61,22 +61,22 @@ ParamList =
SelfParam =
Attr* (
('&' 'lifetime'?)? 'mut'? 'self'
| 'mut'? 'self' ':' ty:TypeRef
| 'mut'? 'self' ':' Type
)
Param =
Attr* (
Pat (':' ty:TypeRef)
| ty:TypeRef
Pat (':' Type)
| Type
| '...'
)
RetType =
'->' ty:TypeRef
'->' Type
TypeAlias =
Attr* Visibility? 'default'? 'type' Name GenericParamList? (':' TypeBoundList?)? WhereClause?
'=' ty:TypeRef ';'
'=' Type ';'
Struct =
Attr* Visibility? 'struct' Name GenericParamList? (
@ -88,13 +88,13 @@ RecordFieldList =
'{' fields:(RecordField (',' RecordField)* ','?)? '}'
RecordField =
Attr* Visibility? Name ':' ty:TypeRef
Attr* Visibility? Name ':' Type
TupleFieldList =
'(' fields:(TupleField (',' TupleField)* ','?)? ')'
TupleField =
Attr* Visibility? ty:TypeRef
Attr* Visibility? Type
FieldList =
RecordFieldList
@ -120,11 +120,11 @@ AdtDef =
| Union
Const =
Attr* Visibility? 'default'? 'const' (Name | '_') ':' ty:TypeRef
Attr* Visibility? 'default'? 'const' (Name | '_') ':' Type
'=' body:Expr ';'
Static =
Attr* Visibility? 'static'? 'mut'? Name ':' ty:TypeRef
Attr* Visibility? 'static'? 'mut'? Name ':' Type
'=' body:Expr ';'
Trait =
@ -144,8 +144,8 @@ AssocItem =
Impl =
Attr* Visibility?
'default'? 'unsafe'? 'impl' 'const'? GenericParamList? (
TypeRef
| '!'? TypeRef 'for' TypeRef
Type
| '!'? Type 'for' Type
) WhereClause?
AssocItemList
@ -168,10 +168,10 @@ GenericParam =
TypeParam =
Attr* Name (':' TypeBoundList?)?
('=' default_type:TypeRef)?
('=' default_type:Type)?
ConstParam =
Attr* 'const' Name ':' ty:TypeRef
Attr* 'const' Name ':' Type
('=' default_val:Expr)?
LifetimeParam =
@ -188,7 +188,7 @@ Visibility =
Attr =
'#' '!'? '[' Path ('=' Literal | TokenTree)? ']'
TypeRef =
Type =
ParenType
| TupleType
| NeverType
@ -204,10 +204,10 @@ TypeRef =
| DynTraitType
ParenType =
'(' ty:TypeRef ')'
'(' Type ')'
TupleType =
'(' fields:TypeRef* ')'
'(' fields:Type* ')'
NeverType =
'!'
@ -216,16 +216,16 @@ PathType =
Path
PointerType =
'*' ('const' | 'mut') ty:TypeRef
'*' ('const' | 'mut') Type
ArrayType =
'[' ty:TypeRef ';' Expr ']'
'[' Type ';' Expr ']'
SliceType =
'[' ty:TypeRef ']'
'[' Type ']'
ReferenceType =
'&' 'lifetime'? 'mut'? ty:TypeRef
'&' 'lifetime'? 'mut'? Type
PlaceholderType =
'_'
@ -234,7 +234,7 @@ FnPointerType =
Abi 'unsafe'? 'fn' ParamList RetType?
ForType =
'for' GenericParamList ty:TypeRef
'for' GenericParamList Type
ImplTraitType =
'impl' TypeBoundList
@ -322,7 +322,7 @@ TryExpr =
Attr* Expr '?'
CastExpr =
Attr* Expr 'as' ty:TypeRef
Attr* Expr 'as' Type
RefExpr =
Attr* '&' ('raw' | 'mut' | 'const') Expr
@ -444,13 +444,13 @@ MacroStmts =
Expr?
TypeBound =
'lifetime' | 'const'? TypeRef
'lifetime' | 'const'? Type
TypeBoundList =
bounds:TypeBound*
WherePred =
('for' GenericParamList)? ('lifetime' | TypeRef) ':' TypeBoundList
('for' GenericParamList)? ('lifetime' | Type) ':' TypeBoundList
WhereClause =
'where' predicates:WherePred*
@ -459,7 +459,7 @@ ExprStmt =
Attr* Expr ';'
LetStmt =
Attr* 'let' Pat (':' ty:TypeRef)
Attr* 'let' Pat (':' Type)
'=' initializer:Expr ';'
Path =
@ -478,10 +478,10 @@ TypeArgList =
'>'
TypeArg =
TypeRef
Type
AssocTypeArg =
NameRef (':' TypeBoundList | '=' TypeRef)
NameRef (':' TypeBoundList | '=' Type)
LifetimeArg =
'lifetime'