-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix substs issues for const errors #60508
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
This currently breaks
because it tries to substitute a const for a type parameter. I think this was a pre-existing issue, but the bug this PR fixes was hiding it. I think that type parameters are still being ordered before const parameters (even if they appear afterwards in the source code), so there's a mismatch. |
@varkor the parser ignores the order when making the ast node but complains about the order so an error will be emitted. Why do we depend on source ordering here? |
@estebank: I haven't fully diagnosed the issue yet, but ideally parameters would preserve their source order throughout the compiler: there shouldn't be any reason lifetimes, types and consts should come in that order specifically. The error should essentially just be a lint. However, that hasn't always been the case and I imagine there are some broken assumptions here because of it. |
A quick fix would be to abort as soon as misordered const/type parameters are found in a signature. It should only regress diagnostics for const generics and I can fix the issue properly later. |
@varkor I think the order is lost because in the parser we collect independent vecs for each type of argument instead of one vec with annotated items. We could indeed |
--> $DIR/const-param-in-trait.rs:3:12 | ||
| | ||
LL | #![feature(const_generics)] | ||
| ^^^^^^^^^^^^^^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a first 😄
7cbf469
to
735714a
Compare
I've added a temporary |
@bors r+ |
📌 Commit 735714af24f422dcba10d1beabf35a0816f645c2 has been approved by |
735714a
to
1f47f12
Compare
1f47f12
to
3e6787c
Compare
@bors r=petrochenkov |
📌 Commit 3e6787c has been approved by |
Fix substs issues for const errors Fixes #60503.
☀️ Test successful - checks-travis, status-appveyor |
Fixes #60503.