Skip to content

Decide about future of rustc_legacy_const_generics #146613

@traviscross

Description

@traviscross

Back in 2021, we converted stdarch intrinsics to use const generics:

However, we seem to have left open the question of how strongly we want to deprecate rustc_legacy_const_generics and whether it's appropriate to use rustc_legacy_const_generics on new APIs.

Following guidance (in #83167 (comment)) related to the experience for people on older MSRVs, our documentation still points people toward this "legacy" syntax (e.g.).

On the other hand, we recently made this legacy syntax significantly less functional than the const generic equivalent in:

Our discussion on that proceeded as follows (2024-10-30):

TC: This proposes to make an error out of:

std::arch::x86_64::_mm_blend_ps(loop {}, loop {}, foo::<3>());

...and similar cases that lean on legacy_const_generics.

This is not believed to break anything in practice and is being done for implementation reasons.

TC: This is marked as an easy decision for us. Do we agree?

Josh: We've thought about trying to make this a first-class feature. How difficult are the bugs in question to fix?

CE: If we ever wanted this as a first-class feature, we'd need to tear this out anyway and reimplement it. What's in the compiler now cannot architecturally support extending this feature more generally.

NM: We may in fact want this first-class feature. But I would want it to be approached as an equality constraint being introduced, not a "rewrite".

CE: It could certainly be done; just not how it was done.

TC: This is now in FCP.

For my part, I had taken from our decision and discussion that we mean to phase out as much as possible of what relies on the current implementation and concept of rustc_legacy_const_generics while at the same time being open to proposals for how we might approach this in a more appealing way. However, given the open questions we had left in 2021, it seems less clear to me now what our plan is.

Perhaps without noticing, we recently stabilized the AVX512 intrinsics with rustc_legacy_const_generics:

@RalfJung has proposed that, maybe, as this only went out in Rust 1.89, we could see about clawing this back. Conversely, there's a proposal, for consistently, to extend rustc_legacy_const_generics to all intrinsics with const generic parameters:

What do we want to do? The questions for us include:

  • Should rustc_legacy_const_generics be applied to new APIs? If not, should we mark it as "deprecated"?
  • Should rustc_legacy_const_generics be applied to existing APIs for consistency?
  • Should we see if we can claw back rustc_legacy_const_generics from AVX512 intrinsics?
  • Should we be lang FCPing the PRs for intrinsic stabilizations such as AVX512 so as to maybe catch this sort of thing? (We only FCPed the AVX512 target feature.)
  • Should rustdoc be suggesting the legacy syntax or the const generic syntax to people?
  • Do we have appetite to see about issuing FCWs or moving people off of rustc_legacy_const_generics over an edition?

cc @RalfJung @BoxyUwU @Amanieu @sayantn @rust-lang/project-const-generics @rust-lang/wg-const-eval @rust-lang/lang

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-discussionCategory: Discussion or questions that doesn't represent real issues.I-lang-nominatedNominated for discussion during a lang team meeting.I-lang-radarItems that are on lang's radar and will need eventual work or consideration.P-lang-drag-1Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-langT-langRelevant to the language team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions