put hir::AnonConst on the hir arena

This commit is contained in:
Oli Scherer
2024-04-26 12:57:02 +00:00
parent e7da0fa62f
commit 4dc46f7f17
11 changed files with 47 additions and 41 deletions

View File

@@ -1181,10 +1181,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
tokens: None,
};
let ct = self.with_new_scopes(span, |this| hir::AnonConst {
def_id,
hir_id: this.lower_node_id(node_id),
body: this.lower_const_body(path_expr.span, Some(&path_expr)),
let ct = self.with_new_scopes(span, |this| {
self.arena.alloc(hir::AnonConst {
def_id,
hir_id: this.lower_node_id(node_id),
body: this
.lower_const_body(path_expr.span, Some(&path_expr)),
})
});
return GenericArg::Const(ConstArg {
value: ct,
@@ -2318,7 +2321,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
fn lower_array_length(&mut self, c: &AnonConst) -> hir::ArrayLen {
fn lower_array_length(&mut self, c: &AnonConst) -> hir::ArrayLen<'hir> {
match c.value.kind {
ExprKind::Underscore => {
if self.tcx.features().generic_arg_infer {
@@ -2341,12 +2344,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}
}
fn lower_anon_const(&mut self, c: &AnonConst) -> hir::AnonConst {
self.with_new_scopes(c.value.span, |this| hir::AnonConst {
fn lower_anon_const(&mut self, c: &AnonConst) -> &'hir hir::AnonConst {
self.arena.alloc(self.with_new_scopes(c.value.span, |this| hir::AnonConst {
def_id: this.local_def_id(c.id),
hir_id: this.lower_node_id(c.id),
body: this.lower_const_body(c.value.span, Some(&c.value)),
})
}))
}
fn lower_unsafe_source(&mut self, u: UnsafeSource) -> hir::UnsafeSource {
@@ -2653,7 +2656,7 @@ impl<'hir> GenericArgsCtor<'hir> {
lcx.children.push((def_id, hir::MaybeOwner::NonOwner(hir_id)));
self.args.push(hir::GenericArg::Const(hir::ConstArg {
value: hir::AnonConst { def_id, hir_id, body },
value: lcx.arena.alloc(hir::AnonConst { def_id, hir_id, body }),
span,
is_desugared_from_effects: true,
}))