mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Reame PlaceholderType -> InferType
This commit is contained in:
parent
08ea2271e8
commit
a6e45c6c69
10 changed files with 28 additions and 28 deletions
|
@ -46,7 +46,7 @@ pub(crate) fn add_explicit_type(acc: &mut Assists, ctx: &AssistContext) -> Optio
|
||||||
// and it has no placeholders
|
// and it has no placeholders
|
||||||
let ascribed_ty = let_stmt.ty();
|
let ascribed_ty = let_stmt.ty();
|
||||||
if let Some(ty) = &ascribed_ty {
|
if let Some(ty) = &ascribed_ty {
|
||||||
if ty.syntax().descendants().find_map(ast::PlaceholderType::cast).is_none() {
|
if ty.syntax().descendants().find_map(ast::InferType::cast).is_none() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ impl TypeRef {
|
||||||
let mutability = Mutability::from_mutable(inner.mut_token().is_some());
|
let mutability = Mutability::from_mutable(inner.mut_token().is_some());
|
||||||
TypeRef::Reference(Box::new(inner_ty), mutability)
|
TypeRef::Reference(Box::new(inner_ty), mutability)
|
||||||
}
|
}
|
||||||
ast::Type::PlaceholderType(_inner) => TypeRef::Placeholder,
|
ast::Type::InferType(_inner) => TypeRef::Placeholder,
|
||||||
ast::Type::FnPointerType(inner) => {
|
ast::Type::FnPointerType(inner) => {
|
||||||
let ret_ty = inner
|
let ret_ty = inner
|
||||||
.ret_type()
|
.ret_type()
|
||||||
|
|
|
@ -172,7 +172,7 @@ fn placeholder_type(p: &mut Parser) {
|
||||||
assert!(p.at(T![_]));
|
assert!(p.at(T![_]));
|
||||||
let m = p.start();
|
let m = p.start();
|
||||||
p.bump(T![_]);
|
p.bump(T![_]);
|
||||||
m.complete(p, PLACEHOLDER_TYPE);
|
m.complete(p, INFER_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// test fn_pointer_type
|
// test fn_pointer_type
|
||||||
|
|
|
@ -147,7 +147,7 @@ pub enum SyntaxKind {
|
||||||
ARRAY_TYPE,
|
ARRAY_TYPE,
|
||||||
SLICE_TYPE,
|
SLICE_TYPE,
|
||||||
REFERENCE_TYPE,
|
REFERENCE_TYPE,
|
||||||
PLACEHOLDER_TYPE,
|
INFER_TYPE,
|
||||||
FN_POINTER_TYPE,
|
FN_POINTER_TYPE,
|
||||||
FOR_TYPE,
|
FOR_TYPE,
|
||||||
IMPL_TRAIT_TYPE,
|
IMPL_TRAIT_TYPE,
|
||||||
|
|
|
@ -594,10 +594,10 @@ impl ReferenceType {
|
||||||
pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
|
pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct PlaceholderType {
|
pub struct InferType {
|
||||||
pub(crate) syntax: SyntaxNode,
|
pub(crate) syntax: SyntaxNode,
|
||||||
}
|
}
|
||||||
impl PlaceholderType {
|
impl InferType {
|
||||||
pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) }
|
pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
@ -1291,7 +1291,7 @@ pub enum Type {
|
||||||
ArrayType(ArrayType),
|
ArrayType(ArrayType),
|
||||||
SliceType(SliceType),
|
SliceType(SliceType),
|
||||||
ReferenceType(ReferenceType),
|
ReferenceType(ReferenceType),
|
||||||
PlaceholderType(PlaceholderType),
|
InferType(InferType),
|
||||||
FnPointerType(FnPointerType),
|
FnPointerType(FnPointerType),
|
||||||
ForType(ForType),
|
ForType(ForType),
|
||||||
ImplTraitType(ImplTraitType),
|
ImplTraitType(ImplTraitType),
|
||||||
|
@ -1988,8 +1988,8 @@ impl AstNode for ReferenceType {
|
||||||
}
|
}
|
||||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||||
}
|
}
|
||||||
impl AstNode for PlaceholderType {
|
impl AstNode for InferType {
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == PLACEHOLDER_TYPE }
|
fn can_cast(kind: SyntaxKind) -> bool { kind == INFER_TYPE }
|
||||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||||
if Self::can_cast(syntax.kind()) {
|
if Self::can_cast(syntax.kind()) {
|
||||||
Some(Self { syntax })
|
Some(Self { syntax })
|
||||||
|
@ -2871,8 +2871,8 @@ impl From<SliceType> for Type {
|
||||||
impl From<ReferenceType> for Type {
|
impl From<ReferenceType> for Type {
|
||||||
fn from(node: ReferenceType) -> Type { Type::ReferenceType(node) }
|
fn from(node: ReferenceType) -> Type { Type::ReferenceType(node) }
|
||||||
}
|
}
|
||||||
impl From<PlaceholderType> for Type {
|
impl From<InferType> for Type {
|
||||||
fn from(node: PlaceholderType) -> Type { Type::PlaceholderType(node) }
|
fn from(node: InferType) -> Type { Type::InferType(node) }
|
||||||
}
|
}
|
||||||
impl From<FnPointerType> for Type {
|
impl From<FnPointerType> for Type {
|
||||||
fn from(node: FnPointerType) -> Type { Type::FnPointerType(node) }
|
fn from(node: FnPointerType) -> Type { Type::FnPointerType(node) }
|
||||||
|
@ -2890,7 +2890,7 @@ impl AstNode for Type {
|
||||||
fn can_cast(kind: SyntaxKind) -> bool {
|
fn can_cast(kind: SyntaxKind) -> bool {
|
||||||
match kind {
|
match kind {
|
||||||
PAREN_TYPE | TUPLE_TYPE | NEVER_TYPE | PATH_TYPE | POINTER_TYPE | ARRAY_TYPE
|
PAREN_TYPE | TUPLE_TYPE | NEVER_TYPE | PATH_TYPE | POINTER_TYPE | ARRAY_TYPE
|
||||||
| SLICE_TYPE | REFERENCE_TYPE | PLACEHOLDER_TYPE | FN_POINTER_TYPE | FOR_TYPE
|
| SLICE_TYPE | REFERENCE_TYPE | INFER_TYPE | FN_POINTER_TYPE | FOR_TYPE
|
||||||
| IMPL_TRAIT_TYPE | DYN_TRAIT_TYPE => true,
|
| IMPL_TRAIT_TYPE | DYN_TRAIT_TYPE => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
|
@ -2905,7 +2905,7 @@ impl AstNode for Type {
|
||||||
ARRAY_TYPE => Type::ArrayType(ArrayType { syntax }),
|
ARRAY_TYPE => Type::ArrayType(ArrayType { syntax }),
|
||||||
SLICE_TYPE => Type::SliceType(SliceType { syntax }),
|
SLICE_TYPE => Type::SliceType(SliceType { syntax }),
|
||||||
REFERENCE_TYPE => Type::ReferenceType(ReferenceType { syntax }),
|
REFERENCE_TYPE => Type::ReferenceType(ReferenceType { syntax }),
|
||||||
PLACEHOLDER_TYPE => Type::PlaceholderType(PlaceholderType { syntax }),
|
INFER_TYPE => Type::InferType(InferType { syntax }),
|
||||||
FN_POINTER_TYPE => Type::FnPointerType(FnPointerType { syntax }),
|
FN_POINTER_TYPE => Type::FnPointerType(FnPointerType { syntax }),
|
||||||
FOR_TYPE => Type::ForType(ForType { syntax }),
|
FOR_TYPE => Type::ForType(ForType { syntax }),
|
||||||
IMPL_TRAIT_TYPE => Type::ImplTraitType(ImplTraitType { syntax }),
|
IMPL_TRAIT_TYPE => Type::ImplTraitType(ImplTraitType { syntax }),
|
||||||
|
@ -2924,7 +2924,7 @@ impl AstNode for Type {
|
||||||
Type::ArrayType(it) => &it.syntax,
|
Type::ArrayType(it) => &it.syntax,
|
||||||
Type::SliceType(it) => &it.syntax,
|
Type::SliceType(it) => &it.syntax,
|
||||||
Type::ReferenceType(it) => &it.syntax,
|
Type::ReferenceType(it) => &it.syntax,
|
||||||
Type::PlaceholderType(it) => &it.syntax,
|
Type::InferType(it) => &it.syntax,
|
||||||
Type::FnPointerType(it) => &it.syntax,
|
Type::FnPointerType(it) => &it.syntax,
|
||||||
Type::ForType(it) => &it.syntax,
|
Type::ForType(it) => &it.syntax,
|
||||||
Type::ImplTraitType(it) => &it.syntax,
|
Type::ImplTraitType(it) => &it.syntax,
|
||||||
|
@ -3719,7 +3719,7 @@ impl std::fmt::Display for ReferenceType {
|
||||||
std::fmt::Display::fmt(self.syntax(), f)
|
std::fmt::Display::fmt(self.syntax(), f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl std::fmt::Display for PlaceholderType {
|
impl std::fmt::Display for InferType {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
std::fmt::Display::fmt(self.syntax(), f)
|
std::fmt::Display::fmt(self.syntax(), f)
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ SOURCE_FILE@0..22
|
||||||
WHITESPACE@16..17 " "
|
WHITESPACE@16..17 " "
|
||||||
EQ@17..18 "="
|
EQ@17..18 "="
|
||||||
WHITESPACE@18..19 " "
|
WHITESPACE@18..19 " "
|
||||||
PLACEHOLDER_TYPE@19..20
|
INFER_TYPE@19..20
|
||||||
UNDERSCORE@19..20 "_"
|
UNDERSCORE@19..20 "_"
|
||||||
SEMICOLON@20..21 ";"
|
SEMICOLON@20..21 ";"
|
||||||
WHITESPACE@21..22 "\n"
|
WHITESPACE@21..22 "\n"
|
||||||
|
|
|
@ -19,7 +19,7 @@ SOURCE_FILE@0..33
|
||||||
PATH@16..19
|
PATH@16..19
|
||||||
PATH_SEGMENT@16..19
|
PATH_SEGMENT@16..19
|
||||||
L_ANGLE@16..17 "<"
|
L_ANGLE@16..17 "<"
|
||||||
PLACEHOLDER_TYPE@17..18
|
INFER_TYPE@17..18
|
||||||
UNDERSCORE@17..18 "_"
|
UNDERSCORE@17..18 "_"
|
||||||
R_ANGLE@18..19 ">"
|
R_ANGLE@18..19 ">"
|
||||||
COLON2@19..21 "::"
|
COLON2@19..21 "::"
|
||||||
|
|
|
@ -1640,10 +1640,10 @@ SOURCE_FILE@0..3813
|
||||||
COLON@2956..2957 ":"
|
COLON@2956..2957 ":"
|
||||||
TUPLE_TYPE@2957..2962
|
TUPLE_TYPE@2957..2962
|
||||||
L_PAREN@2957..2958 "("
|
L_PAREN@2957..2958 "("
|
||||||
PLACEHOLDER_TYPE@2958..2959
|
INFER_TYPE@2958..2959
|
||||||
UNDERSCORE@2958..2959 "_"
|
UNDERSCORE@2958..2959 "_"
|
||||||
COMMA@2959..2960 ","
|
COMMA@2959..2960 ","
|
||||||
PLACEHOLDER_TYPE@2960..2961
|
INFER_TYPE@2960..2961
|
||||||
UNDERSCORE@2960..2961 "_"
|
UNDERSCORE@2960..2961 "_"
|
||||||
R_PAREN@2961..2962 ")"
|
R_PAREN@2961..2962 ")"
|
||||||
COMMA@2962..2963 ","
|
COMMA@2962..2963 ","
|
||||||
|
|
|
@ -117,7 +117,7 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc {
|
||||||
"ARRAY_TYPE",
|
"ARRAY_TYPE",
|
||||||
"SLICE_TYPE",
|
"SLICE_TYPE",
|
||||||
"REFERENCE_TYPE",
|
"REFERENCE_TYPE",
|
||||||
"PLACEHOLDER_TYPE",
|
"INFER_TYPE",
|
||||||
"FN_POINTER_TYPE",
|
"FN_POINTER_TYPE",
|
||||||
"FOR_TYPE",
|
"FOR_TYPE",
|
||||||
"IMPL_TRAIT_TYPE",
|
"IMPL_TRAIT_TYPE",
|
||||||
|
|
|
@ -197,7 +197,7 @@ Type =
|
||||||
| ArrayType
|
| ArrayType
|
||||||
| SliceType
|
| SliceType
|
||||||
| ReferenceType
|
| ReferenceType
|
||||||
| PlaceholderType
|
| InferType
|
||||||
| FnPointerType
|
| FnPointerType
|
||||||
| ForType
|
| ForType
|
||||||
| ImplTraitType
|
| ImplTraitType
|
||||||
|
@ -206,28 +206,28 @@ Type =
|
||||||
ParenType =
|
ParenType =
|
||||||
'(' Type ')'
|
'(' Type ')'
|
||||||
|
|
||||||
TupleType =
|
|
||||||
'(' fields:Type* ')'
|
|
||||||
|
|
||||||
NeverType =
|
NeverType =
|
||||||
'!'
|
'!'
|
||||||
|
|
||||||
PathType =
|
PathType =
|
||||||
Path
|
Path
|
||||||
|
|
||||||
|
TupleType =
|
||||||
|
'(' fields:(Type (',' Type)* ','?)? ')'
|
||||||
|
|
||||||
PointerType =
|
PointerType =
|
||||||
'*' ('const' | 'mut') Type
|
'*' ('const' | 'mut') Type
|
||||||
|
|
||||||
|
ReferenceType =
|
||||||
|
'&' 'lifetime'? 'mut'? Type
|
||||||
|
|
||||||
ArrayType =
|
ArrayType =
|
||||||
'[' Type ';' Expr ']'
|
'[' Type ';' Expr ']'
|
||||||
|
|
||||||
SliceType =
|
SliceType =
|
||||||
'[' Type ']'
|
'[' Type ']'
|
||||||
|
|
||||||
ReferenceType =
|
InferType =
|
||||||
'&' 'lifetime'? 'mut'? Type
|
|
||||||
|
|
||||||
PlaceholderType =
|
|
||||||
'_'
|
'_'
|
||||||
|
|
||||||
FnPointerType =
|
FnPointerType =
|
||||||
|
|
Loading…
Reference in a new issue