Skip to content

Commit 5d67210

Browse files
committed
rename the lower_anon_const_to_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 c7aba60 commit 5d67210

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
11221122
AssocItemConstraintKind::Equality { term } => {
11231123
let term = match term {
11241124
Term::Ty(ty) => self.lower_ty_and_alloc(ty, itctx).into(),
1125-
Term::Const(c) => self.lower_anon_const_to_const_arg(c).into(),
1125+
Term::Const(c) => self.lower_anon_const_to_const_arg_and_alloc(c).into(),
11261126
};
11271127
hir::AssocItemConstraintKind::Equality { term }
11281128
}
@@ -1248,9 +1248,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
12481248
}
12491249
GenericArg::Type(self.lower_ty_and_alloc(ty, itctx).try_as_ambig_ty().unwrap())
12501250
}
1251-
ast::GenericArg::Const(ct) => {
1252-
GenericArg::Const(self.lower_anon_const_to_const_arg(ct).try_as_ambig_ct().unwrap())
1253-
}
1251+
ast::GenericArg::Const(ct) => GenericArg::Const(
1252+
self.lower_anon_const_to_const_arg_and_alloc(ct).try_as_ambig_ct().unwrap(),
1253+
),
12541254
}
12551255
}
12561256

@@ -2063,7 +2063,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20632063
false
20642064
}
20652065
})
2066-
.map(|def| self.lower_anon_const_to_const_arg(def));
2066+
.map(|def| self.lower_anon_const_to_const_arg_and_alloc(def));
20672067

20682068
(
20692069
hir::ParamName::Plain(self.lower_ident(param.ident)),
@@ -2285,7 +2285,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
22852285
let ct_kind = hir::ConstArgKind::Infer(self.lower_span(c.value.span), ());
22862286
self.arena.alloc(hir::ConstArg { hir_id: self.lower_node_id(c.id), kind: ct_kind })
22872287
}
2288-
_ => self.lower_anon_const_to_const_arg(c),
2288+
_ => self.lower_anon_const_to_const_arg_and_alloc(c),
22892289
}
22902290
}
22912291

@@ -2364,7 +2364,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23642364
) -> hir::ConstItemRhs<'hir> {
23652365
match rhs {
23662366
Some(ConstItemRhs::TypeConst(anon)) => {
2367-
hir::ConstItemRhs::TypeConst(self.lower_anon_const_to_const_arg(anon))
2367+
hir::ConstItemRhs::TypeConst(self.lower_anon_const_to_const_arg_and_alloc(anon))
23682368
}
23692369
None if attr::contains_name(attrs, sym::type_const) => {
23702370
let const_arg = ConstArg {
@@ -2432,12 +2432,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24322432

24332433
/// See [`hir::ConstArg`] for when to use this function vs
24342434
/// [`Self::lower_anon_const_to_anon_const`].
2435-
fn lower_anon_const_to_const_arg(&mut self, anon: &AnonConst) -> &'hir hir::ConstArg<'hir> {
2436-
self.arena.alloc(self.lower_anon_const_to_const_arg_direct(anon))
2435+
fn lower_anon_const_to_const_arg_and_alloc(
2436+
&mut self,
2437+
anon: &AnonConst,
2438+
) -> &'hir hir::ConstArg<'hir> {
2439+
self.arena.alloc(self.lower_anon_const_to_const_arg(anon))
24372440
}
24382441

24392442
#[instrument(level = "debug", skip(self))]
2440-
fn lower_anon_const_to_const_arg_direct(&mut self, anon: &AnonConst) -> hir::ConstArg<'hir> {
2443+
fn lower_anon_const_to_const_arg(&mut self, anon: &AnonConst) -> hir::ConstArg<'hir> {
24412444
let tcx = self.tcx;
24422445

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

compiler/rustc_ast_lowering/src/pat.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -443,16 +443,18 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
443443
let pat_hir_id = self.lower_node_id(pattern.id);
444444
let node = match &pattern.kind {
445445
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-
}),
446+
e1.as_deref()
447+
.map(|e| self.lower_anon_const_to_const_arg_and_alloc(e))
448+
.unwrap_or_else(|| {
449+
self.lower_ty_pat_range_end(
450+
hir::LangItem::RangeMin,
451+
span.shrink_to_lo(),
452+
base_type,
453+
)
454+
}),
453455
e2.as_deref()
454456
.map(|e| match end {
455-
RangeEnd::Included(..) => self.lower_anon_const_to_const_arg(e),
457+
RangeEnd::Included(..) => self.lower_anon_const_to_const_arg_and_alloc(e),
456458
RangeEnd::Excluded => self.lower_excluded_range_end(e),
457459
})
458460
.unwrap_or_else(|| {

0 commit comments

Comments
 (0)