Move generic arg/param validation to create_substs_for_generic_args to resolve various const generics issues#68434
Conversation
|
Some changes occurred in diagnostic error codes |
9b4b01e to
d2a750c
Compare
eddyb
left a comment
There was a problem hiding this comment.
LGTM, but I'd like a second opinion from @rust-lang/compiler (and maybe we need a check-mode crater run? I doubt it though)
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1174b94 to
afad00d
Compare
src/librustc_typeck/astconv.rs
Outdated
There was a problem hiding this comment.
No reordering suggestion for this case?
There was a problem hiding this comment.
I'd rather leave this PR for the bug-fixes and follow up with the diagnostics improvements. That's a good follow up, though.
|
r? @nikomatsakis for a second opinion (#68434 (review)) |
src/librustc_typeck/astconv.rs
Outdated
There was a problem hiding this comment.
Oh, that'd be cute. :)
There was a problem hiding this comment.
Are we tracking this anywhere?
|
Is this PR waiting on anything specific? |
|
@yodaldevoid: a second reviewer's opinion on the PR. |
|
☔ The latest upstream changes (presumably #68893) made this pull request unmergeable. Please resolve the merge conflicts. |
nikomatsakis
left a comment
There was a problem hiding this comment.
I didn't follow 100% of what's going on here, but it overall seems pretty reasonable -- except that I think the new errors are kind of confusingly worded. Am I missing something?
There was a problem hiding this comment.
why does this error go away?
There was a problem hiding this comment.
Previously if we encountered an incorrect generic argument, we would just try to skip it and continue going: https://github.com/rust-lang/rust/pull/68434/files#diff-1b4d50b82a87f1031cd5f99b64123de7L578. Now we just stop checking the remaining arguments, because there's a high likelihood the remaining arguments are invalid and we'd just spit out lots of errors that aren't particularly helpful.
src/librustc_typeck/astconv.rs
Outdated
There was a problem hiding this comment.
(Annoying, it'd be nice to change this to a custom enum -- but obviously pre-existing for this PR.)
There was a problem hiding this comment.
I find this error quite a bit more confusing than the old one. It suggests to me that the fix is to change T into a lifetime -- but that won't help.
There was a problem hiding this comment.
I'm not quite sure what the "mental model" is that we are trying to convey to users.
There was a problem hiding this comment.
I'm convinced we should be suggesting the correct order in all of these cases.
There was a problem hiding this comment.
The reason I changed this is because there isn't really a restriction on the order of generic arguments: the restriction is on generic parameters, but generic arguments must match the order of generic parameters. The fact that lifetime arguments must precede type arguments is a side-effect of the parameter order. I'll try tweaking the wording to improve this. As @estebank says, ideally we'd suggest the correct order, but I'd like to get this merged sooner rather than later, as I don't know how much time I'll have for more elaborate changes now.
There was a problem hiding this comment.
OK, I see. I still find the message more confusing than the old one, but perhaps I now better understand what this PR is aiming for.
src/librustc_typeck/astconv.rs
Outdated
There was a problem hiding this comment.
Oh, that'd be cute. :)
src/test/ui/const-generics/const-param-after-const-literal-arg.rs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
I'm convinced we should be suggesting the correct order in all of these cases.
332b61f to
b0b88e7
Compare
|
@nikomatsakis: I've addressed the code comments, and also added a note to the error messages making them as descriptive as the previous ones. I'll open an issue for suggesting the correct order of all provided arguments: I'd rather split it out into a separate PR than conflate it with this one. |
This comment has been minimized.
This comment has been minimized.
b0b88e7 to
bead79e
Compare
|
📌 Commit bead79e has been approved by |
|
☀️ Test successful - checks-azure |
|
📣 Toolstate changed by #68434! Tested on commit 6d69cab. 🎉 book on windows: test-fail → test-pass (cc @carols10cents @steveklabnik). |
Tested on commit rust-lang/rust@6d69cab. Direct link to PR: <rust-lang/rust#68434> 🎉 book on windows: test-fail → test-pass (cc @carols10cents @steveklabnik).
This changes some diagnostics, but I think they're around as helpful as the previous ones, and occur infrequently regardless.
Fixes #68257.
Fixes #68398.
r? @eddyb