Skip to content

Commit 598d01b

Browse files
committed
rename the lower_anon_const_to_const_arg and
`lower_anon_const_to_const_arg_direct` to `lower_anon_const_to_const_arg_and_alloc` and `lower_anon_const_to_const_arg`
1 parent ad0d25a commit 598d01b

File tree

2 files changed

+44
-40
lines changed

2 files changed

+44
-40
lines changed

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
11261126
AssocItemConstraintKind::Equality { term } => {
11271127
let term = match term {
11281128
Term::Ty(ty) => self.lower_ty_alloc(ty, itctx).into(),
1129-
Term::Const(c) => self.lower_anon_const_to_const_arg(c).into(),
1129+
Term::Const(c) => self.lower_anon_const_to_const_arg_alloc(c).into(),
11301130
};
11311131
hir::AssocItemConstraintKind::Equality { term }
11321132
}
@@ -1252,9 +1252,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
12521252
}
12531253
GenericArg::Type(self.lower_ty_alloc(ty, itctx).try_as_ambig_ty().unwrap())
12541254
}
1255-
ast::GenericArg::Const(ct) => {
1256-
GenericArg::Const(self.lower_anon_const_to_const_arg(ct).try_as_ambig_ct().unwrap())
1257-
}
1255+
ast::GenericArg::Const(ct) => GenericArg::Const(
1256+
self.lower_anon_const_to_const_arg_alloc(ct).try_as_ambig_ct().unwrap(),
1257+
),
12581258
}
12591259
}
12601260

@@ -2066,7 +2066,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20662066
false
20672067
}
20682068
})
2069-
.map(|def| self.lower_anon_const_to_const_arg(def));
2069+
.map(|def| self.lower_anon_const_to_const_arg_alloc(def));
20702070

20712071
(
20722072
hir::ParamName::Plain(self.lower_ident(param.ident)),
@@ -2288,7 +2288,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
22882288
let ct_kind = hir::ConstArgKind::Infer(self.lower_span(c.value.span), ());
22892289
self.arena.alloc(hir::ConstArg { hir_id: self.lower_node_id(c.id), kind: ct_kind })
22902290
}
2291-
_ => self.lower_anon_const_to_const_arg(c),
2291+
_ => self.lower_anon_const_to_const_arg_alloc(c),
22922292
}
22932293
}
22942294

@@ -2367,7 +2367,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23672367
) -> hir::ConstItemRhs<'hir> {
23682368
match rhs {
23692369
Some(ConstItemRhs::TypeConst(anon)) => {
2370-
hir::ConstItemRhs::TypeConst(self.lower_anon_const_to_const_arg(anon))
2370+
hir::ConstItemRhs::TypeConst(self.lower_anon_const_to_const_arg_alloc(anon))
23712371
}
23722372
None if attr::contains_name(attrs, sym::type_const) => {
23732373
let const_arg = ConstArg {
@@ -2438,7 +2438,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24382438
let def_kind = self.tcx.def_kind(def_id);
24392439
assert_eq!(DefKind::AnonConst, def_kind);
24402440

2441-
self.lower_anon_const_to_const_arg_direct(anon_const)
2441+
self.lower_anon_const_to_const_arg(anon_const)
24422442
} else {
24432443
self.lower_expr_to_const_arg_direct(&f.expr)
24442444
};
@@ -2476,12 +2476,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24762476

24772477
/// See [`hir::ConstArg`] for when to use this function vs
24782478
/// [`Self::lower_anon_const_to_anon_const`].
2479-
fn lower_anon_const_to_const_arg(&mut self, anon: &AnonConst) -> &'hir hir::ConstArg<'hir> {
2480-
self.arena.alloc(self.lower_anon_const_to_const_arg_direct(anon))
2479+
fn lower_anon_const_to_const_arg_alloc(
2480+
&mut self,
2481+
anon: &AnonConst,
2482+
) -> &'hir hir::ConstArg<'hir> {
2483+
self.arena.alloc(self.lower_anon_const_to_const_arg(anon))
24812484
}
24822485

24832486
#[instrument(level = "debug", skip(self))]
2484-
fn lower_anon_const_to_const_arg_direct(&mut self, anon: &AnonConst) -> hir::ConstArg<'hir> {
2487+
fn lower_anon_const_to_const_arg(&mut self, anon: &AnonConst) -> hir::ConstArg<'hir> {
24852488
let tcx = self.tcx;
24862489

24872490
// We cannot change parsing depending on feature gates available,

compiler/rustc_ast_lowering/src/pat.rs

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -441,36 +441,37 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
441441
fn lower_ty_pat_mut(&mut self, pattern: &TyPat, base_type: Span) -> hir::TyPat<'hir> {
442442
// loop here to avoid recursion
443443
let pat_hir_id = self.lower_node_id(pattern.id);
444-
let node = match &pattern.kind {
445-
TyPatKind::Range(e1, e2, Spanned { node: end, span }) => hir::TyPatKind::Range(
446-
e1.as_deref().map(|e| self.lower_anon_const_to_const_arg(e)).unwrap_or_else(|| {
447-
self.lower_ty_pat_range_end(
448-
hir::LangItem::RangeMin,
449-
span.shrink_to_lo(),
450-
base_type,
451-
)
452-
}),
453-
e2.as_deref()
454-
.map(|e| match end {
455-
RangeEnd::Included(..) => self.lower_anon_const_to_const_arg(e),
456-
RangeEnd::Excluded => self.lower_excluded_range_end(e),
457-
})
458-
.unwrap_or_else(|| {
459-
self.lower_ty_pat_range_end(
460-
hir::LangItem::RangeMax,
461-
span.shrink_to_hi(),
462-
base_type,
463-
)
464-
}),
465-
),
466-
TyPatKind::NotNull => hir::TyPatKind::NotNull,
467-
TyPatKind::Or(variants) => {
468-
hir::TyPatKind::Or(self.arena.alloc_from_iter(
444+
let node =
445+
match &pattern.kind {
446+
TyPatKind::Range(e1, e2, Spanned { node: end, span }) => hir::TyPatKind::Range(
447+
e1.as_deref()
448+
.map(|e| self.lower_anon_const_to_const_arg_alloc(e))
449+
.unwrap_or_else(|| {
450+
self.lower_ty_pat_range_end(
451+
hir::LangItem::RangeMin,
452+
span.shrink_to_lo(),
453+
base_type,
454+
)
455+
}),
456+
e2.as_deref()
457+
.map(|e| match end {
458+
RangeEnd::Included(..) => self.lower_anon_const_to_const_arg_alloc(e),
459+
RangeEnd::Excluded => self.lower_excluded_range_end(e),
460+
})
461+
.unwrap_or_else(|| {
462+
self.lower_ty_pat_range_end(
463+
hir::LangItem::RangeMax,
464+
span.shrink_to_hi(),
465+
base_type,
466+
)
467+
}),
468+
),
469+
TyPatKind::NotNull => hir::TyPatKind::NotNull,
470+
TyPatKind::Or(variants) => hir::TyPatKind::Or(self.arena.alloc_from_iter(
469471
variants.iter().map(|pat| self.lower_ty_pat_mut(pat, base_type)),
470-
))
471-
}
472-
TyPatKind::Err(guar) => hir::TyPatKind::Err(*guar),
473-
};
472+
)),
473+
TyPatKind::Err(guar) => hir::TyPatKind::Err(*guar),
474+
};
474475

475476
hir::TyPat { hir_id: pat_hir_id, kind: node, span: self.lower_span(pattern.span) }
476477
}

0 commit comments

Comments
 (0)