Skip to content

Commit 7fa114c

Browse files
committed
Re-enable ConstArgKind::Path lowering by default
...and remove the `const_arg_path` feature gate as a result. It was only a stopgap measure to fix the regression that the new lowering introduced (which should now be fixed by this PR).
1 parent 6834dfe commit 7fa114c

File tree

7 files changed

+7
-21
lines changed

7 files changed

+7
-21
lines changed

compiler/rustc_ast_lowering/src/asm.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
220220
let parent_def_id = self.current_def_id_parent;
221221
let node_id = self.next_node_id();
222222
// HACK(min_generic_const_args): see lower_anon_const
223-
if !self.tcx.features().const_arg_path
224-
|| !expr.is_potential_trivial_const_arg()
225-
{
223+
if !expr.is_potential_trivial_const_arg() {
226224
self.create_def(
227225
parent_def_id,
228226
node_id,

compiler/rustc_ast_lowering/src/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
387387
let node_id = self.next_node_id();
388388

389389
// HACK(min_generic_const_args): see lower_anon_const
390-
if !self.tcx.features().const_arg_path || !arg.is_potential_trivial_const_arg() {
390+
if !arg.is_potential_trivial_const_arg() {
391391
// Add a definition for the in-band const def.
392392
self.create_def(parent_def_id, node_id, kw::Empty, DefKind::AnonConst, f.span);
393393
}

compiler/rustc_ast_lowering/src/lib.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -2335,7 +2335,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23352335
span: Span,
23362336
) -> &'hir hir::ConstArg<'hir> {
23372337
let ct_kind = match res {
2338-
Res::Def(DefKind::ConstParam, _) if self.tcx.features().const_arg_path => {
2338+
Res::Def(DefKind::ConstParam, _) => {
23392339
let qpath = self.lower_qpath(
23402340
ty_id,
23412341
&None,
@@ -2410,8 +2410,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24102410
self.resolver.get_partial_res(expr.id).and_then(|partial_res| partial_res.full_res());
24112411
debug!("res={:?}", maybe_res);
24122412
// FIXME(min_generic_const_args): for now we only lower params to ConstArgKind::Path
2413-
if self.tcx.features().const_arg_path
2414-
&& let Some(res) = maybe_res
2413+
if let Some(res) = maybe_res
24152414
&& let Res::Def(DefKind::ConstParam, _) = res
24162415
&& let ExprKind::Path(qself, path) = &expr.kind
24172416
{
@@ -2442,7 +2441,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24422441
/// See [`hir::ConstArg`] for when to use this function vs
24432442
/// [`Self::lower_anon_const_to_const_arg`].
24442443
fn lower_anon_const_to_anon_const(&mut self, c: &AnonConst) -> &'hir hir::AnonConst {
2445-
if self.tcx.features().const_arg_path && c.value.is_potential_trivial_const_arg() {
2444+
if c.value.is_potential_trivial_const_arg() {
24462445
// HACK(min_generic_const_args): see DefCollector::visit_anon_const
24472446
// Over there, we guess if this is a bare param and only create a def if
24482447
// we think it's not. However we may can guess wrong (see there for example)

compiler/rustc_feature/src/unstable.rs

-2
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,6 @@ declare_features! (
193193
(unstable, anonymous_lifetime_in_impl_trait, "1.63.0", None),
194194
/// Allows identifying the `compiler_builtins` crate.
195195
(internal, compiler_builtins, "1.13.0", None),
196-
/// Gating for a new desugaring of const arguments of usages of const parameters
197-
(internal, const_arg_path, "1.81.0", None),
198196
/// Allows writing custom MIR
199197
(internal, custom_mir, "1.65.0", None),
200198
/// Outputs useful `assert!` messages

compiler/rustc_middle/src/ty/consts.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -302,13 +302,7 @@ impl<'tcx> Const<'tcx> {
302302
),
303303
) = expr.kind
304304
{
305-
if tcx.features().const_arg_path {
306-
span_bug!(
307-
expr.span,
308-
"try_from_lit: received const param which shouldn't be possible"
309-
);
310-
}
311-
return Some(Const::from_param(tcx, qpath, expr.hir_id));
305+
span_bug!(expr.span, "try_from_lit: received const param which shouldn't be possible");
312306
};
313307

314308
let lit_input = match expr.kind {

compiler/rustc_resolve/src/def_collector.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,7 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
347347
}
348348

349349
fn visit_anon_const(&mut self, constant: &'a AnonConst) {
350-
if self.resolver.tcx.features().const_arg_path
351-
&& constant.value.is_potential_trivial_const_arg()
352-
{
350+
if constant.value.is_potential_trivial_const_arg() {
353351
// HACK(min_generic_const_args): don't create defs for anon consts if we think they will
354352
// later be turned into ConstArgKind::Path's. because this is before resolve is done, we
355353
// may accidentally identify a construction of a unit struct as a param and not create a

compiler/rustc_span/src/symbol.rs

-1
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,6 @@ symbols! {
599599
conservative_impl_trait,
600600
console,
601601
const_allocate,
602-
const_arg_path,
603602
const_async_blocks,
604603
const_closures,
605604
const_compare_raw_pointers,

0 commit comments

Comments
 (0)