Skip to content

Commit 274519f

Browse files
carljmMichaReiser
authored andcommitted
review comments on initial type env (#11113)
Review comments from 762fa0b
1 parent 0444ef1 commit 274519f

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

crates/red_knot/src/types.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use ruff_index::{newtype_index, IndexVec};
66
pub(crate) struct TypeId;
77

88
impl TypeId {
9-
pub(crate) fn typ(self, env: &TypeEnvironment) -> &Type {
9+
pub(crate) fn ty(self, env: &TypeEnvironment) -> &Type {
1010
env.type_for_id(self)
1111
}
1212
}
@@ -19,14 +19,14 @@ pub(crate) struct TypeEnvironment {
1919

2020
impl TypeEnvironment {
2121
pub(crate) fn add_class(&mut self, name: &str) -> TypeId {
22-
let class = Type::Class(TypeClass {
22+
let class = Type::Class(ClassType {
2323
name: Name::new(name),
2424
});
2525
self.types_by_id.push(class)
2626
}
2727

2828
pub(crate) fn add_function(&mut self, name: &str) -> TypeId {
29-
let function = Type::Function(TypeFunction {
29+
let function = Type::Function(FunctionType {
3030
name: Name::new(name),
3131
});
3232
self.types_by_id.push(function)
@@ -38,8 +38,8 @@ impl TypeEnvironment {
3838
}
3939

4040
pub(crate) enum Type {
41-
Class(TypeClass),
42-
Function(TypeFunction),
41+
Class(ClassType),
42+
Function(FunctionType),
4343
}
4444

4545
impl Type {
@@ -51,21 +51,21 @@ impl Type {
5151
}
5252
}
5353

54-
pub(crate) struct TypeClass {
54+
pub(crate) struct ClassType {
5555
name: Name,
5656
}
5757

58-
impl TypeClass {
58+
impl ClassType {
5959
pub(crate) fn name(&self) -> &str {
6060
self.name.as_str()
6161
}
6262
}
6363

64-
pub(crate) struct TypeFunction {
64+
pub(crate) struct FunctionType {
6565
name: Name,
6666
}
6767

68-
impl TypeFunction {
68+
impl FunctionType {
6969
pub(crate) fn name(&self) -> &str {
7070
self.name.as_str()
7171
}
@@ -79,13 +79,13 @@ mod tests {
7979
fn add_class() {
8080
let mut env = TypeEnvironment::default();
8181
let cid = env.add_class("C");
82-
assert_eq!(cid.typ(&env).name(), "C");
82+
assert_eq!(cid.ty(&env).name(), "C");
8383
}
8484

8585
#[test]
8686
fn add_function() {
8787
let mut env = TypeEnvironment::default();
8888
let fid = env.add_function("func");
89-
assert_eq!(fid.typ(&env).name(), "func");
89+
assert_eq!(fid.ty(&env).name(), "func");
9090
}
9191
}

0 commit comments

Comments
 (0)