Skip to content

Commit 706ea0a

Browse files
committed
wip: remove unused code, fix up warnings
1 parent 24cdf43 commit 706ea0a

13 files changed

Lines changed: 187 additions & 2702 deletions

File tree

src/ir/hir.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,9 @@ mod statement {
282282

283283
#[derive(Clone, Debug)]
284284
pub enum DeclarationTy {
285-
#[cfg_attr(
286-
not(test),
287-
expect(
288-
dead_code,
289-
reason = "will be used when variable declarations can be explicitly typed."
290-
)
285+
#[expect(
286+
dead_code,
287+
reason = "will be used when variable declarations can be explicitly typed."
291288
)]
292289
Type(TypeId),
293290
Inferred(ExpressionId),

src/ir/thir.rs

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,22 @@
1-
use crate::{
2-
prelude::*,
3-
ty::{TypeVarId, TypeVars},
4-
};
1+
use crate::prelude::*;
52

63
use hir::*;
74

8-
#[derive(Clone, Debug)]
95
pub struct Thir<'hir> {
10-
pub hir: &'hir Hir,
11-
pub types: HashMap<TypeVarId, TypeId>,
12-
pub type_vars: TypeVars,
13-
}
14-
15-
impl Deref for Thir<'_> {
16-
type Target = Hir;
17-
18-
fn deref(&self) -> &Self::Target {
19-
self.hir
20-
}
21-
}
22-
23-
impl<'hir> Thir<'hir> {
24-
pub fn new(hir: &'hir Hir, types: HashMap<TypeVarId, TypeId>, type_vars: TypeVars) -> Self {
25-
Self {
26-
hir,
27-
types,
28-
type_vars,
29-
}
30-
}
31-
32-
pub fn type_of(&self, id: impl Into<TypeVar>) -> TypeId {
33-
let var = self.type_vars.get(id.into());
34-
self.types[&var]
35-
}
36-
}
37-
38-
pub struct Thir2<'hir> {
396
pub hir: &'hir Hir,
407
pub identifier_tys: BTreeMap<IdentifierBindingId, TypeId>,
418
pub expression_tys: IndexedVec<ExpressionId, TypeId>,
429
}
4310

44-
impl Deref for Thir2<'_> {
11+
impl Deref for Thir<'_> {
4512
type Target = Hir;
4613

4714
fn deref(&self) -> &Self::Target {
4815
self.hir
4916
}
5017
}
5118

52-
impl<'hir> Thir2<'hir> {
19+
impl<'hir> Thir<'hir> {
5320
pub fn new(
5421
hir: &'hir Hir,
5522
identifiers_tys: BTreeMap<IdentifierBindingId, TypeId>,
@@ -68,17 +35,17 @@ impl<'hir> Thir2<'hir> {
6835
}
6936

7037
pub trait ThirIndex: Copy {
71-
fn type_of(self, thir: &Thir2<'_>) -> TypeId;
38+
fn type_of(self, thir: &Thir<'_>) -> TypeId;
7239
}
7340

7441
impl ThirIndex for IdentifierBindingId {
75-
fn type_of(self, thir: &Thir2<'_>) -> TypeId {
42+
fn type_of(self, thir: &Thir<'_>) -> TypeId {
7643
thir.identifier_tys[&self]
7744
}
7845
}
7946

8047
impl ThirIndex for ExpressionId {
81-
fn type_of(self, thir: &Thir2<'_>) -> TypeId {
48+
fn type_of(self, thir: &Thir<'_>) -> TypeId {
8249
thir.expression_tys[self]
8350
}
8451
}

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ fn run(source: &str) -> u8 {
8383
|> passes::cst_gen::CstGen
8484
|> passes::ast_gen::AstGen
8585
|> passes::hir_gen::HirGen
86-
|> passes::thir_gen_2::ThirGen
86+
|> passes::thir_gen::ThirGen
8787
|> passes::mir_gen::MirGen
8888
|> passes::codegen::Codegen => (&ink)
8989
}

src/passes/mir_gen.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use crate::{ir::hir::TraitImplementationKey, prelude::*};
22

33
use mir::{UnaryOperation, *};
4-
use thir::Thir2;
4+
use thir::Thir;
55

66
pub struct MirGen<'ctx, 'hir, 'thir> {
77
ctx: &'ctx mut Ctx,
8-
thir: &'thir Thir2<'hir>,
8+
thir: &'thir Thir<'hir>,
99

1010
mir: Mir,
1111

@@ -16,7 +16,7 @@ pub struct MirGen<'ctx, 'hir, 'thir> {
1616
}
1717

1818
impl<'ctx, 'hir, 'thir> Pass<'ctx, 'thir> for MirGen<'ctx, 'hir, 'thir> {
19-
type Input = Thir2<'hir>;
19+
type Input = Thir<'hir>;
2020
type Output = Mir;
2121
type Extra = ();
2222

@@ -45,7 +45,7 @@ impl<'ctx, 'hir, 'thir> Pass<'ctx, 'thir> for MirGen<'ctx, 'hir, 'thir> {
4545

4646
impl<'ctx, 'hir, 'thir> MirGen<'ctx, 'hir, 'thir> {
4747
/// Create a new instance.
48-
pub fn new(ctx: &'ctx mut Ctx, thir: &'thir Thir2<'hir>) -> Self {
48+
pub fn new(ctx: &'ctx mut Ctx, thir: &'thir Thir<'hir>) -> Self {
4949
Self {
5050
ctx,
5151
thir,

src/passes/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ pub mod cst_gen;
44
pub mod hir_gen;
55
pub mod mir_gen;
66
pub mod thir_gen;
7-
pub mod thir_gen_2;
87

98
use crate::prelude::*;
109

0 commit comments

Comments
 (0)