Skip to content

Commit 0e1e406

Browse files
committed
rename flavor to kind
1 parent cb5001c commit 0e1e406

File tree

6 files changed

+53
-53
lines changed

6 files changed

+53
-53
lines changed

crates/ra_hir/src/adt.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::sync::Arc;
66
use ra_arena::{RawId, Arena, impl_arena_id};
77
use ra_syntax::{
88
TreeArc,
9-
ast::{self, NameOwner, StructFlavor, TypeAscriptionOwner}
9+
ast::{self, NameOwner, StructKind, TypeAscriptionOwner}
1010
};
1111

1212
use crate::{
@@ -47,7 +47,7 @@ pub struct StructData {
4747
impl StructData {
4848
fn new(struct_def: &ast::StructDef) -> StructData {
4949
let name = struct_def.name().map(|n| n.as_name());
50-
let variant_data = VariantData::new(struct_def.flavor());
50+
let variant_data = VariantData::new(struct_def.kind());
5151
let variant_data = Arc::new(variant_data);
5252
StructData { name, variant_data }
5353
}
@@ -94,7 +94,7 @@ impl EnumData {
9494
let variants = variants(&*enum_def)
9595
.map(|var| EnumVariantData {
9696
name: var.name().map(|it| it.as_name()),
97-
variant_data: Arc::new(VariantData::new(var.flavor())),
97+
variant_data: Arc::new(VariantData::new(var.kind())),
9898
})
9999
.collect();
100100
Arc::new(EnumData { name, variants })
@@ -143,9 +143,9 @@ impl VariantData {
143143
}
144144

145145
impl VariantData {
146-
fn new(flavor: StructFlavor) -> Self {
146+
fn new(flavor: StructKind) -> Self {
147147
let inner = match flavor {
148-
ast::StructFlavor::Tuple(fl) => {
148+
ast::StructKind::Tuple(fl) => {
149149
let fields = fl
150150
.fields()
151151
.enumerate()
@@ -156,7 +156,7 @@ impl VariantData {
156156
.collect();
157157
VariantDataInner::Tuple(fields)
158158
}
159-
ast::StructFlavor::Named(fl) => {
159+
ast::StructKind::Named(fl) => {
160160
let fields = fl
161161
.fields()
162162
.map(|fd| StructFieldData {
@@ -166,7 +166,7 @@ impl VariantData {
166166
.collect();
167167
VariantDataInner::Struct(fields)
168168
}
169-
ast::StructFlavor::Unit => VariantDataInner::Unit,
169+
ast::StructKind::Unit => VariantDataInner::Unit,
170170
};
171171
VariantData(inner)
172172
}
@@ -200,27 +200,27 @@ impl StructField {
200200
let fields = var_data.fields().unwrap();
201201
let ss;
202202
let es;
203-
let (file_id, struct_flavor) = match self.parent {
203+
let (file_id, struct_kind) = match self.parent {
204204
VariantDef::Struct(s) => {
205205
let (file_id, source) = s.source(db);
206206
ss = source;
207-
(file_id, ss.flavor())
207+
(file_id, ss.kind())
208208
}
209209
VariantDef::EnumVariant(e) => {
210210
let (file_id, source) = e.source(db);
211211
es = source;
212-
(file_id, es.flavor())
212+
(file_id, es.kind())
213213
}
214214
};
215215

216-
let field_sources = match struct_flavor {
217-
ast::StructFlavor::Tuple(fl) => {
216+
let field_sources = match struct_kind {
217+
ast::StructKind::Tuple(fl) => {
218218
fl.fields().map(|it| FieldSource::Pos(it.to_owned())).collect()
219219
}
220-
ast::StructFlavor::Named(fl) => {
220+
ast::StructKind::Named(fl) => {
221221
fl.fields().map(|it| FieldSource::Named(it.to_owned())).collect()
222222
}
223-
ast::StructFlavor::Unit => Vec::new(),
223+
ast::StructKind::Unit => Vec::new(),
224224
};
225225
let field = field_sources
226226
.into_iter()

crates/ra_hir/src/code_model_impl/function.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ impl FnSignature {
2020
TypeRef::from_ast(type_ref)
2121
} else {
2222
let self_type = TypeRef::Path(Name::self_type().into());
23-
match self_param.flavor() {
24-
ast::SelfParamFlavor::Owned => self_type,
25-
ast::SelfParamFlavor::Ref => {
23+
match self_param.kind() {
24+
ast::SelfParamKind::Owned => self_type,
25+
ast::SelfParamKind::Ref => {
2626
TypeRef::Reference(Box::new(self_type), Mutability::Shared)
2727
}
28-
ast::SelfParamFlavor::MutRef => {
28+
ast::SelfParamKind::MutRef => {
2929
TypeRef::Reference(Box::new(self_type), Mutability::Mut)
3030
}
3131
}

crates/ra_hir/src/expr.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_hash::FxHashMap;
66
use ra_arena::{Arena, RawId, impl_arena_id, map::ArenaMap};
77
use ra_syntax::{
88
SyntaxNodePtr, AstPtr, AstNode,
9-
ast::{self, LoopBodyOwner, ArgListOwner, NameOwner, LiteralFlavor, TypeAscriptionOwner}
9+
ast::{self, LoopBodyOwner, ArgListOwner, NameOwner, LiteralKind, TypeAscriptionOwner}
1010
};
1111

1212
use crate::{
@@ -726,8 +726,8 @@ impl ExprCollector {
726726
self.alloc_expr(Expr::Array { exprs }, syntax_ptr)
727727
}
728728
ast::ExprKind::Literal(e) => {
729-
let lit = match e.flavor() {
730-
LiteralFlavor::IntNumber { suffix } => {
729+
let lit = match e.kind() {
730+
LiteralKind::IntNumber { suffix } => {
731731
let known_name = suffix
732732
.and_then(|it| IntTy::from_suffix(&it).map(UncertainIntTy::Known));
733733

@@ -736,7 +736,7 @@ impl ExprCollector {
736736
known_name.unwrap_or(UncertainIntTy::Unknown),
737737
)
738738
}
739-
LiteralFlavor::FloatNumber { suffix } => {
739+
LiteralKind::FloatNumber { suffix } => {
740740
let known_name = suffix
741741
.and_then(|it| FloatTy::from_suffix(&it).map(UncertainFloatTy::Known));
742742

@@ -745,13 +745,13 @@ impl ExprCollector {
745745
known_name.unwrap_or(UncertainFloatTy::Unknown),
746746
)
747747
}
748-
LiteralFlavor::ByteString => Literal::ByteString(Default::default()),
749-
LiteralFlavor::String => Literal::String(Default::default()),
750-
LiteralFlavor::Byte => {
748+
LiteralKind::ByteString => Literal::ByteString(Default::default()),
749+
LiteralKind::String => Literal::String(Default::default()),
750+
LiteralKind::Byte => {
751751
Literal::Int(Default::default(), UncertainIntTy::Known(IntTy::u8()))
752752
}
753-
LiteralFlavor::Bool => Literal::Bool(Default::default()),
754-
LiteralFlavor::Char => Literal::Char(Default::default()),
753+
LiteralKind::Bool => Literal::Bool(Default::default()),
754+
LiteralKind::Char => Literal::Char(Default::default()),
755755
};
756756
self.alloc_expr(Expr::Literal(lit), syntax_ptr)
757757
}

crates/ra_syntax/src/ast.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ pub use self::{
1616
generated::*,
1717
traits::*,
1818
tokens::*,
19-
extensions::{PathSegmentKind, StructFlavor, SelfParamFlavor},
20-
expr_extensions::{ElseBranch, PrefixOp, BinOp, LiteralFlavor},
19+
extensions::{PathSegmentKind, StructKind, SelfParamKind},
20+
expr_extensions::{ElseBranch, PrefixOp, BinOp, LiteralKind},
2121
};
2222

2323
/// The main trait to go from untyped `SyntaxNode` to a typed ast. The

crates/ra_syntax/src/ast/expr_extensions.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl ast::BinExpr {
192192
}
193193

194194
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
195-
pub enum LiteralFlavor {
195+
pub enum LiteralKind {
196196
String,
197197
ByteString,
198198
Char,
@@ -210,7 +210,7 @@ impl ast::Literal {
210210
}
211211
}
212212

213-
pub fn flavor(&self) -> LiteralFlavor {
213+
pub fn kind(&self) -> LiteralKind {
214214
match self.token().kind() {
215215
INT_NUMBER => {
216216
let allowed_suffix_list = [
@@ -222,7 +222,7 @@ impl ast::Literal {
222222
.iter()
223223
.find(|&s| text.ends_with(s))
224224
.map(|&suf| SmolStr::new(suf));
225-
LiteralFlavor::IntNumber { suffix }
225+
LiteralKind::IntNumber { suffix }
226226
}
227227
FLOAT_NUMBER => {
228228
let allowed_suffix_list = ["f64", "f32"];
@@ -231,13 +231,13 @@ impl ast::Literal {
231231
.iter()
232232
.find(|&s| text.ends_with(s))
233233
.map(|&suf| SmolStr::new(suf));
234-
LiteralFlavor::FloatNumber { suffix: suffix }
234+
LiteralKind::FloatNumber { suffix: suffix }
235235
}
236-
STRING | RAW_STRING => LiteralFlavor::String,
237-
TRUE_KW | FALSE_KW => LiteralFlavor::Bool,
238-
BYTE_STRING | RAW_BYTE_STRING => LiteralFlavor::ByteString,
239-
CHAR => LiteralFlavor::Char,
240-
BYTE => LiteralFlavor::Byte,
236+
STRING | RAW_STRING => LiteralKind::String,
237+
TRUE_KW | FALSE_KW => LiteralKind::Bool,
238+
BYTE_STRING | RAW_BYTE_STRING => LiteralKind::ByteString,
239+
CHAR => LiteralKind::Char,
240+
BYTE => LiteralKind::Byte,
241241
_ => unreachable!(),
242242
}
243243
}

crates/ra_syntax/src/ast/extensions.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -159,27 +159,27 @@ impl ast::ImplBlock {
159159
}
160160

161161
#[derive(Debug, Clone, PartialEq, Eq)]
162-
pub enum StructFlavor<'a> {
162+
pub enum StructKind<'a> {
163163
Tuple(&'a ast::PosFieldDefList),
164164
Named(&'a ast::NamedFieldDefList),
165165
Unit,
166166
}
167167

168-
impl StructFlavor<'_> {
169-
fn from_node<N: AstNode>(node: &N) -> StructFlavor {
168+
impl StructKind<'_> {
169+
fn from_node<N: AstNode>(node: &N) -> StructKind {
170170
if let Some(nfdl) = child_opt::<_, ast::NamedFieldDefList>(node) {
171-
StructFlavor::Named(nfdl)
171+
StructKind::Named(nfdl)
172172
} else if let Some(pfl) = child_opt::<_, ast::PosFieldDefList>(node) {
173-
StructFlavor::Tuple(pfl)
173+
StructKind::Tuple(pfl)
174174
} else {
175-
StructFlavor::Unit
175+
StructKind::Unit
176176
}
177177
}
178178
}
179179

180180
impl ast::StructDef {
181-
pub fn flavor(&self) -> StructFlavor {
182-
StructFlavor::from_node(self)
181+
pub fn kind(&self) -> StructKind {
182+
StructKind::from_node(self)
183183
}
184184
}
185185

@@ -191,8 +191,8 @@ impl ast::EnumVariant {
191191
.and_then(ast::EnumDef::cast)
192192
.expect("EnumVariants are always nested in Enums")
193193
}
194-
pub fn flavor(&self) -> StructFlavor {
195-
StructFlavor::from_node(self)
194+
pub fn kind(&self) -> StructKind {
195+
StructKind::from_node(self)
196196
}
197197
}
198198

@@ -243,7 +243,7 @@ impl ast::ReferenceType {
243243
}
244244

245245
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
246-
pub enum SelfParamFlavor {
246+
pub enum SelfParamKind {
247247
/// self
248248
Owned,
249249
/// &self
@@ -261,7 +261,7 @@ impl ast::SelfParam {
261261
.expect("invalid tree: self param must have self")
262262
}
263263

264-
pub fn flavor(&self) -> SelfParamFlavor {
264+
pub fn kind(&self) -> SelfParamKind {
265265
let borrowed = self.syntax().children_with_tokens().any(|n| n.kind() == AMP);
266266
if borrowed {
267267
// check for a `mut` coming after the & -- `mut &self` != `&mut self`
@@ -271,12 +271,12 @@ impl ast::SelfParam {
271271
.skip_while(|n| n.kind() != AMP)
272272
.any(|n| n.kind() == MUT_KW)
273273
{
274-
SelfParamFlavor::MutRef
274+
SelfParamKind::MutRef
275275
} else {
276-
SelfParamFlavor::Ref
276+
SelfParamKind::Ref
277277
}
278278
} else {
279-
SelfParamFlavor::Owned
279+
SelfParamKind::Owned
280280
}
281281
}
282282
}

0 commit comments

Comments
 (0)