rust icon indicating copy to clipboard operation
rust copied to clipboard

Reject overly generic assoc const binding types

Open fmease opened this issue 1 year ago • 1 comments

Split off from #119385 to make #119385 easier to review.


In the instantiated type of assoc const bindings

  1. reject early-bound generic params
    • Provide a rich error message instead of ICE'ing (#108271).
    • This is a temporary and semi-artificial restriction until the arrival of generic const generics.
    • It's quite possible that rustc could already perfectly support this subset of generic const generics if we just removed some checks (some .no_bound_vars().expect(…)) but even if that was the case, I'd rather gate it behind a new feature flag. Reporting an error instead of ICE'ing is a good first step towards an eventual feature gate error.
  2. reject escaping late-bound generic params
    • They lead to ICEs before & I'm pretty sure that they remain incorrect even in a world with generic const generics

https://github.com/rust-lang/rust/labels/S-waiting-on-author: I'd like to add more comments explaining why this approach was taken (why rustc_hir_analysis over rustc_resolve, why mod type_of was chosen over e.g. mod resolve_bound_vars, etc.) and I still need to get rid of some FIXMEs.

Together with #118668 (merged) & #119385, this supersedes #118360. Fixes #108271.

fmease avatar Feb 18 '24 10:02 fmease

:umbrella: The latest upstream changes (presumably #122190) made this pull request unmergeable. Please resolve the merge conflicts.

bors avatar Mar 08 '24 20:03 bors

Cool 👍

@bors r+

compiler-errors avatar Mar 18 '24 18:03 compiler-errors

:pushpin: Commit 0b2fb8db6540b0548230cd335e7b2a845686f7ea has been approved by compiler-errors

It is now in the queue for this repository.

bors avatar Mar 18 '24 18:03 bors