Skip to content

Commit 11eb59d

Browse files
committed
cleanup lowering fns
1 parent 269ce59 commit 11eb59d

File tree

1 file changed

+12
-30
lines changed
  • compiler/rustc_ast_lowering/src

1 file changed

+12
-30
lines changed

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2311,52 +2311,35 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23112311
) -> hir::ConstItemRhs<'hir> {
23122312
match rhs {
23132313
Some(ConstItemRhs::TypeConst(anon)) => {
2314-
hir::ConstItemRhs::TypeConst(self.lower_item_body_to_const_arg(Some(anon)))
2314+
hir::ConstItemRhs::TypeConst(self.lower_anon_const_to_const_arg(anon))
2315+
}
2316+
None if attr::contains_name(attrs, sym::type_const) => {
2317+
let const_arg = ConstArg {
2318+
hir_id: self.next_id(),
2319+
kind: hir::ConstArgKind::Error(
2320+
DUMMY_SP,
2321+
self.dcx().span_delayed_bug(DUMMY_SP, "no block"),
2322+
),
2323+
};
2324+
hir::ConstItemRhs::TypeConst(self.arena.alloc(const_arg))
23152325
}
23162326
Some(ConstItemRhs::Body(body)) => {
23172327
hir::ConstItemRhs::Body(self.lower_const_body(span, Some(body)))
23182328
}
2319-
None if attr::contains_name(attrs, sym::type_const) => {
2320-
hir::ConstItemRhs::TypeConst(self.lower_item_body_to_const_arg(None))
2321-
}
23222329
None => hir::ConstItemRhs::Body(self.lower_const_body(span, None)),
23232330
}
23242331
}
23252332

2326-
/// See [`hir::ConstArg`] for when to use this function vs
2327-
/// [`Self::lower_anon_const_to_anon_const`].
2328-
fn lower_item_body_to_const_arg(
2329-
&mut self,
2330-
anon: Option<&AnonConst>,
2331-
) -> &'hir hir::ConstArg<'hir> {
2332-
let Some(anon) = anon else {
2333-
let const_arg = ConstArg {
2334-
hir_id: self.next_id(),
2335-
kind: hir::ConstArgKind::Error(
2336-
DUMMY_SP,
2337-
self.dcx().span_delayed_bug(DUMMY_SP, "no block"),
2338-
),
2339-
};
2340-
return self.arena.alloc(const_arg);
2341-
};
2342-
2343-
self.arena.alloc(self.lower_anon_const_to_const_arg_direct(
2344-
anon,
2345-
!self.tcx.features().min_generic_const_args(),
2346-
))
2347-
}
2348-
23492333
/// See [`hir::ConstArg`] for when to use this function vs
23502334
/// [`Self::lower_anon_const_to_anon_const`].
23512335
fn lower_anon_const_to_const_arg(&mut self, anon: &AnonConst) -> &'hir hir::ConstArg<'hir> {
2352-
self.arena.alloc(self.lower_anon_const_to_const_arg_direct(anon, false))
2336+
self.arena.alloc(self.lower_anon_const_to_const_arg_direct(anon))
23532337
}
23542338

23552339
#[instrument(level = "debug", skip(self))]
23562340
fn lower_anon_const_to_const_arg_direct(
23572341
&mut self,
23582342
anon: &AnonConst,
2359-
always_lower_to_anon_const: bool,
23602343
) -> hir::ConstArg<'hir> {
23612344
let tcx = self.tcx;
23622345
// Unwrap a block, so that e.g. `{ P }` is recognised as a parameter. Const arguments
@@ -2376,7 +2359,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23762359
&& path.is_potential_trivial_const_arg(tcx.features().min_generic_const_args())
23772360
&& (tcx.features().min_generic_const_args()
23782361
|| matches!(maybe_res, Some(Res::Def(DefKind::ConstParam, _))))
2379-
&& !always_lower_to_anon_const
23802362
{
23812363
let qpath = self.lower_qpath(
23822364
expr.id,

0 commit comments

Comments
 (0)