Skip to content

Commit 56cb5d5

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 b0a581d commit 56cb5d5

2 files changed

Lines changed: 25 additions & 20 deletions

File tree

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 15 additions & 12 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_and_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_and_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_and_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_and_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_and_alloc(anon))
23712371
}
23722372
None if attr::contains_name(attrs, sym::type_const) => {
23732373
let const_arg = ConstArg {
@@ -2414,7 +2414,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24142414
let def_id = self.local_def_id(anon_const.id);
24152415
let def_kind = self.tcx.def_kind(def_id);
24162416
assert_eq!(DefKind::AnonConst, def_kind);
2417-
self.lower_anon_const_to_const_arg_direct(anon_const)
2417+
self.lower_anon_const_to_const_arg(anon_const)
24182418
} else {
24192419
self.lower_expr_to_const_arg_direct(arg)
24202420
};
@@ -2467,7 +2467,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24672467
let def_kind = self.tcx.def_kind(def_id);
24682468
assert_eq!(DefKind::AnonConst, def_kind);
24692469

2470-
self.lower_anon_const_to_const_arg_direct(anon_const)
2470+
self.lower_anon_const_to_const_arg(anon_const)
24712471
} else {
24722472
self.lower_expr_to_const_arg_direct(&f.expr)
24732473
};
@@ -2508,12 +2508,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
25082508

25092509
/// See [`hir::ConstArg`] for when to use this function vs
25102510
/// [`Self::lower_anon_const_to_anon_const`].
2511-
fn lower_anon_const_to_const_arg(&mut self, anon: &AnonConst) -> &'hir hir::ConstArg<'hir> {
2512-
self.arena.alloc(self.lower_anon_const_to_const_arg_direct(anon))
2511+
fn lower_anon_const_to_const_arg_and_alloc(
2512+
&mut self,
2513+
anon: &AnonConst,
2514+
) -> &'hir hir::ConstArg<'hir> {
2515+
self.arena.alloc(self.lower_anon_const_to_const_arg(anon))
25132516
}
25142517

25152518
#[instrument(level = "debug", skip(self))]
2516-
fn lower_anon_const_to_const_arg_direct(&mut self, anon: &AnonConst) -> hir::ConstArg<'hir> {
2519+
fn lower_anon_const_to_const_arg(&mut self, anon: &AnonConst) -> hir::ConstArg<'hir> {
25172520
let tcx = self.tcx;
25182521

25192522
// 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
@@ -444,16 +444,18 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
444444
let pat_hir_id = self.lower_node_id(pattern.id);
445445
let node = match &pattern.kind {
446446
TyPatKind::Range(e1, e2, Spanned { node: end, span }) => hir::TyPatKind::Range(
447-
e1.as_deref().map(|e| self.lower_anon_const_to_const_arg(e)).unwrap_or_else(|| {
448-
self.lower_ty_pat_range_end(
449-
hir::LangItem::RangeMin,
450-
span.shrink_to_lo(),
451-
base_type,
452-
)
453-
}),
447+
e1.as_deref()
448+
.map(|e| self.lower_anon_const_to_const_arg_and_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+
}),
454456
e2.as_deref()
455457
.map(|e| match end {
456-
RangeEnd::Included(..) => self.lower_anon_const_to_const_arg(e),
458+
RangeEnd::Included(..) => self.lower_anon_const_to_const_arg_and_alloc(e),
457459
RangeEnd::Excluded => self.lower_excluded_range_end(e),
458460
})
459461
.unwrap_or_else(|| {

0 commit comments

Comments
 (0)