Skip to content

Commit

Permalink
lowering
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbastian committed Feb 21, 2024
1 parent 05ddab1 commit b2fc961
Show file tree
Hide file tree
Showing 3 changed files with 207 additions and 201 deletions.
11 changes: 7 additions & 4 deletions core/src/hir/elision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,20 +244,23 @@ impl<'ast> BaseLifetimeLowerer<'ast> {

impl<'ast> SelfParamLifetimeLowerer<'ast> {
/// Returns a new [`SelfParamLifetimeLowerer`].
pub fn new(lifetime_env: &'ast ast::LifetimeEnv, ctx: &mut LoweringContext) -> Option<Self> {
let mut hir_nodes = Some(SmallVec::new());
pub fn new(
lifetime_env: &'ast ast::LifetimeEnv,
ctx: &mut LoweringContext,
) -> Result<Self, ()> {
let mut hir_nodes = Ok(SmallVec::new());

for ast_node in lifetime_env.nodes.iter() {
let lifetime = ctx.lower_ident(ast_node.lifetime.name(), "named lifetime");
match (lifetime, &mut hir_nodes) {
(Some(lifetime), Some(hir_nodes)) => {
(Ok(lifetime), Ok(hir_nodes)) => {
hir_nodes.push(BoundedLifetime::new(
lifetime,
ast_node.longer.iter().map(|i| Lifetime::new(*i)).collect(),
ast_node.shorter.iter().map(|i| Lifetime::new(*i)).collect(),
));
}
_ => hir_nodes = None,
_ => hir_nodes = Err(()),
}
}

Expand Down
Loading

0 comments on commit b2fc961

Please sign in to comment.