Skip to content

Commit 5e669d8

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 b0668f7 commit 5e669d8

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
@@ -1124,7 +1124,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
11241124
AssocItemConstraintKind::Equality { term } => {
11251125
let term = match term {
11261126
Term::Ty(ty) => self.lower_ty_and_alloc(ty, itctx).into(),
1127-
Term::Const(c) => self.lower_anon_const_to_const_arg(c).into(),
1127+
Term::Const(c) => self.lower_anon_const_to_const_arg_and_alloc(c).into(),
11281128
};
11291129
hir::AssocItemConstraintKind::Equality { term }
11301130
}
@@ -1250,9 +1250,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
12501250
}
12511251
GenericArg::Type(self.lower_ty_and_alloc(ty, itctx).try_as_ambig_ty().unwrap())
12521252
}
1253-
ast::GenericArg::Const(ct) => {
1254-
GenericArg::Const(self.lower_anon_const_to_const_arg(ct).try_as_ambig_ct().unwrap())
1255-
}
1253+
ast::GenericArg::Const(ct) => GenericArg::Const(
1254+
self.lower_anon_const_to_const_arg_and_alloc(ct).try_as_ambig_ct().unwrap(),
1255+
),
12561256
}
12571257
}
12581258

@@ -2065,7 +2065,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20652065
false
20662066
}
20672067
})
2068-
.map(|def| self.lower_anon_const_to_const_arg(def));
2068+
.map(|def| self.lower_anon_const_to_const_arg_and_alloc(def));
20692069

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

@@ -2366,7 +2366,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23662366
) -> hir::ConstItemRhs<'hir> {
23672367
match rhs {
23682368
Some(ConstItemRhs::TypeConst(anon)) => {
2369-
hir::ConstItemRhs::TypeConst(self.lower_anon_const_to_const_arg(anon))
2369+
hir::ConstItemRhs::TypeConst(self.lower_anon_const_to_const_arg_and_alloc(anon))
23702370
}
23712371
None if attr::contains_name(attrs, sym::type_const) => {
23722372
let const_arg = ConstArg {
@@ -2434,12 +2434,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24342434

24352435
/// See [`hir::ConstArg`] for when to use this function vs
24362436
/// [`Self::lower_anon_const_to_anon_const`].
2437-
fn lower_anon_const_to_const_arg(&mut self, anon: &AnonConst) -> &'hir hir::ConstArg<'hir> {
2438-
self.arena.alloc(self.lower_anon_const_to_const_arg_direct(anon))
2437+
fn lower_anon_const_to_const_arg_and_alloc(
2438+
&mut self,
2439+
anon: &AnonConst,
2440+
) -> &'hir hir::ConstArg<'hir> {
2441+
self.arena.alloc(self.lower_anon_const_to_const_arg(anon))
24392442
}
24402443

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

24452448
// 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)