Skip to content

Commit

Permalink
refactor: migrate ast lowering pass to ErrorGuaranteed (#81)
Browse files Browse the repository at this point in the history
This is a first pass over the module. There are still some unnecessary
Result types being returned here, but that's cleanup for another day.
  • Loading branch information
junlarsen authored Feb 15, 2025
1 parent 3c56767 commit fbf1c1e
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 82 deletions.
2 changes: 1 addition & 1 deletion compiler/eight-driver/src/operations/ast_lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ impl<'c> PipelinePass<'c, AstTranslationUnit<'c>, HirModule<'c>> for AstLowerPas
input: AstTranslationUnit<'c>,
) -> Result<HirModule<'c>, PipelineError> {
let mut lowering_pass = AstLoweringPass::new(pipeline.session);
let module = lowering_pass.visit_translation_unit(&input)?;
let module = lowering_pass.visit_translation_unit(input)?;
Ok(module)
}
}
8 changes: 4 additions & 4 deletions compiler/eight-middle/src/hir/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::hir::{
HirReferenceExpr, HirReturnStmt, HirStmt, HirTrait, HirTraitSignature,
};
use crate::hir::{HirReferenceSymbol, HirTy};
use crate::{HirResult, LinkageType};
use crate::LinkageType;
use eight_support::span::Span;
use std::collections::BTreeMap;

Expand All @@ -33,10 +33,10 @@ impl<'hir> HirBuilder {
///
/// This saves us from having to write `.iter().map(|x| ...).collect()` every time we want to
/// collect something into a vector.
pub fn build_vec<A, B>(
pub fn build_vec<A, B, E>(
iter: impl IntoIterator<Item = A>,
f: impl FnMut(A) -> HirResult<B>,
) -> HirResult<Vec<B>> {
f: impl FnMut(A) -> Result<B, E>,
) -> Result<Vec<B>, E> {
iter.into_iter().map(f).collect()
}

Expand Down
Loading

0 comments on commit fbf1c1e

Please sign in to comment.