Skip to content

Commit eccb5d5

Browse files
bors[bot]matklad
andauthored
Merge #5619
5619: Reame PlaceholderType -> InferType r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 parents 8c802a3 + a6e45c6 commit eccb5d5

File tree

10 files changed

+28
-28
lines changed

10 files changed

+28
-28
lines changed

crates/ra_assists/src/handlers/add_explicit_type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub(crate) fn add_explicit_type(acc: &mut Assists, ctx: &AssistContext) -> Optio
4646
// and it has no placeholders
4747
let ascribed_ty = let_stmt.ty();
4848
if let Some(ty) = &ascribed_ty {
49-
if ty.syntax().descendants().find_map(ast::PlaceholderType::cast).is_none() {
49+
if ty.syntax().descendants().find_map(ast::InferType::cast).is_none() {
5050
return None;
5151
}
5252
}

crates/ra_hir_def/src/type_ref.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ impl TypeRef {
111111
let mutability = Mutability::from_mutable(inner.mut_token().is_some());
112112
TypeRef::Reference(Box::new(inner_ty), mutability)
113113
}
114-
ast::Type::PlaceholderType(_inner) => TypeRef::Placeholder,
114+
ast::Type::InferType(_inner) => TypeRef::Placeholder,
115115
ast::Type::FnPointerType(inner) => {
116116
let ret_ty = inner
117117
.ret_type()

crates/ra_parser/src/grammar/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ fn placeholder_type(p: &mut Parser) {
172172
assert!(p.at(T![_]));
173173
let m = p.start();
174174
p.bump(T![_]);
175-
m.complete(p, PLACEHOLDER_TYPE);
175+
m.complete(p, INFER_TYPE);
176176
}
177177

178178
// test fn_pointer_type

crates/ra_parser/src/syntax_kind/generated.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ pub enum SyntaxKind {
147147
ARRAY_TYPE,
148148
SLICE_TYPE,
149149
REFERENCE_TYPE,
150-
PLACEHOLDER_TYPE,
150+
INFER_TYPE,
151151
FN_POINTER_TYPE,
152152
FOR_TYPE,
153153
IMPL_TRAIT_TYPE,

crates/ra_syntax/src/ast/generated/nodes.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -594,10 +594,10 @@ impl ReferenceType {
594594
pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
595595
}
596596
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
597-
pub struct PlaceholderType {
597+
pub struct InferType {
598598
pub(crate) syntax: SyntaxNode,
599599
}
600-
impl PlaceholderType {
600+
impl InferType {
601601
pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) }
602602
}
603603
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -1291,7 +1291,7 @@ pub enum Type {
12911291
ArrayType(ArrayType),
12921292
SliceType(SliceType),
12931293
ReferenceType(ReferenceType),
1294-
PlaceholderType(PlaceholderType),
1294+
InferType(InferType),
12951295
FnPointerType(FnPointerType),
12961296
ForType(ForType),
12971297
ImplTraitType(ImplTraitType),
@@ -1988,8 +1988,8 @@ impl AstNode for ReferenceType {
19881988
}
19891989
fn syntax(&self) -> &SyntaxNode { &self.syntax }
19901990
}
1991-
impl AstNode for PlaceholderType {
1992-
fn can_cast(kind: SyntaxKind) -> bool { kind == PLACEHOLDER_TYPE }
1991+
impl AstNode for InferType {
1992+
fn can_cast(kind: SyntaxKind) -> bool { kind == INFER_TYPE }
19931993
fn cast(syntax: SyntaxNode) -> Option<Self> {
19941994
if Self::can_cast(syntax.kind()) {
19951995
Some(Self { syntax })
@@ -2871,8 +2871,8 @@ impl From<SliceType> for Type {
28712871
impl From<ReferenceType> for Type {
28722872
fn from(node: ReferenceType) -> Type { Type::ReferenceType(node) }
28732873
}
2874-
impl From<PlaceholderType> for Type {
2875-
fn from(node: PlaceholderType) -> Type { Type::PlaceholderType(node) }
2874+
impl From<InferType> for Type {
2875+
fn from(node: InferType) -> Type { Type::InferType(node) }
28762876
}
28772877
impl From<FnPointerType> for Type {
28782878
fn from(node: FnPointerType) -> Type { Type::FnPointerType(node) }
@@ -2890,7 +2890,7 @@ impl AstNode for Type {
28902890
fn can_cast(kind: SyntaxKind) -> bool {
28912891
match kind {
28922892
PAREN_TYPE | TUPLE_TYPE | NEVER_TYPE | PATH_TYPE | POINTER_TYPE | ARRAY_TYPE
2893-
| SLICE_TYPE | REFERENCE_TYPE | PLACEHOLDER_TYPE | FN_POINTER_TYPE | FOR_TYPE
2893+
| SLICE_TYPE | REFERENCE_TYPE | INFER_TYPE | FN_POINTER_TYPE | FOR_TYPE
28942894
| IMPL_TRAIT_TYPE | DYN_TRAIT_TYPE => true,
28952895
_ => false,
28962896
}
@@ -2905,7 +2905,7 @@ impl AstNode for Type {
29052905
ARRAY_TYPE => Type::ArrayType(ArrayType { syntax }),
29062906
SLICE_TYPE => Type::SliceType(SliceType { syntax }),
29072907
REFERENCE_TYPE => Type::ReferenceType(ReferenceType { syntax }),
2908-
PLACEHOLDER_TYPE => Type::PlaceholderType(PlaceholderType { syntax }),
2908+
INFER_TYPE => Type::InferType(InferType { syntax }),
29092909
FN_POINTER_TYPE => Type::FnPointerType(FnPointerType { syntax }),
29102910
FOR_TYPE => Type::ForType(ForType { syntax }),
29112911
IMPL_TRAIT_TYPE => Type::ImplTraitType(ImplTraitType { syntax }),
@@ -2924,7 +2924,7 @@ impl AstNode for Type {
29242924
Type::ArrayType(it) => &it.syntax,
29252925
Type::SliceType(it) => &it.syntax,
29262926
Type::ReferenceType(it) => &it.syntax,
2927-
Type::PlaceholderType(it) => &it.syntax,
2927+
Type::InferType(it) => &it.syntax,
29282928
Type::FnPointerType(it) => &it.syntax,
29292929
Type::ForType(it) => &it.syntax,
29302930
Type::ImplTraitType(it) => &it.syntax,
@@ -3719,7 +3719,7 @@ impl std::fmt::Display for ReferenceType {
37193719
std::fmt::Display::fmt(self.syntax(), f)
37203720
}
37213721
}
3722-
impl std::fmt::Display for PlaceholderType {
3722+
impl std::fmt::Display for InferType {
37233723
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
37243724
std::fmt::Display::fmt(self.syntax(), f)
37253725
}

crates/ra_syntax/test_data/parser/inline/ok/0023_placeholder_type.rast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ SOURCE_FILE@0..22
77
WHITESPACE@16..17 " "
88
EQ@17..18 "="
99
WHITESPACE@18..19 " "
10-
PLACEHOLDER_TYPE@19..20
10+
INFER_TYPE@19..20
1111
UNDERSCORE@19..20 "_"
1212
SEMICOLON@20..21 ";"
1313
WHITESPACE@21..22 "\n"

crates/ra_syntax/test_data/parser/inline/ok/0164_type_path_in_pattern.rast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ SOURCE_FILE@0..33
1919
PATH@16..19
2020
PATH_SEGMENT@16..19
2121
L_ANGLE@16..17 "<"
22-
PLACEHOLDER_TYPE@17..18
22+
INFER_TYPE@17..18
2323
UNDERSCORE@17..18 "_"
2424
R_ANGLE@18..19 ">"
2525
COLON2@19..21 "::"

crates/ra_syntax/test_data/parser/ok/0035_weird_exprs.rast

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,10 +1640,10 @@ SOURCE_FILE@0..3813
16401640
COLON@2956..2957 ":"
16411641
TUPLE_TYPE@2957..2962
16421642
L_PAREN@2957..2958 "("
1643-
PLACEHOLDER_TYPE@2958..2959
1643+
INFER_TYPE@2958..2959
16441644
UNDERSCORE@2958..2959 "_"
16451645
COMMA@2959..2960 ","
1646-
PLACEHOLDER_TYPE@2960..2961
1646+
INFER_TYPE@2960..2961
16471647
UNDERSCORE@2960..2961 "_"
16481648
R_PAREN@2961..2962 ")"
16491649
COMMA@2962..2963 ","

xtask/src/ast_src.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc {
117117
"ARRAY_TYPE",
118118
"SLICE_TYPE",
119119
"REFERENCE_TYPE",
120-
"PLACEHOLDER_TYPE",
120+
"INFER_TYPE",
121121
"FN_POINTER_TYPE",
122122
"FOR_TYPE",
123123
"IMPL_TRAIT_TYPE",

xtask/src/codegen/rust.ungram

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ Type =
197197
| ArrayType
198198
| SliceType
199199
| ReferenceType
200-
| PlaceholderType
200+
| InferType
201201
| FnPointerType
202202
| ForType
203203
| ImplTraitType
@@ -206,28 +206,28 @@ Type =
206206
ParenType =
207207
'(' Type ')'
208208

209-
TupleType =
210-
'(' fields:Type* ')'
211-
212209
NeverType =
213210
'!'
214211

215212
PathType =
216213
Path
217214

215+
TupleType =
216+
'(' fields:(Type (',' Type)* ','?)? ')'
217+
218218
PointerType =
219219
'*' ('const' | 'mut') Type
220220

221+
ReferenceType =
222+
'&' 'lifetime'? 'mut'? Type
223+
221224
ArrayType =
222225
'[' Type ';' Expr ']'
223226

224227
SliceType =
225228
'[' Type ']'
226229

227-
ReferenceType =
228-
'&' 'lifetime'? 'mut'? Type
229-
230-
PlaceholderType =
230+
InferType =
231231
'_'
232232

233233
FnPointerType =

0 commit comments

Comments
 (0)