Improve compiler error message for wrong generic parameter order#72271
Improve compiler error message for wrong generic parameter order#72271bors merged 1 commit intorust-lang:masterfrom
Conversation
|
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
|
You'll need to add a regression test in |
|
Okay. But is my approach right though? |
|
@rakshith-ravi: this looks like the right idea, yes! I'll leave some more detailed comments soon. I would just use one |
|
#72441 will definitely interfere with this unfortunately |
|
Sounds fun. I'm looking forward to it xD Can you please help me understand what exactly that PR does? |
|
@rakshith-ravi Yeah definitely! Are you active on the |
|
Yup. You'll find me as |
|
@DoctorN I've merged your branch into mine. So all merge conflicts are now resolved. You can merge this into master once #72441 gets merged. @varkor I've added the changes you suggested as well. Sorting it out with a sort function call now, and removed those 3 Still need to update the tests. Will get on that soon |
|
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
|
@rakshith-ravi: once #72441 is merged, could you rebase over it? That would make it easier to review changes (it's frustrating that GitHub doesn't support dependent pull requests). |
|
Ignore me |
There was a problem hiding this comment.
Wait hold on, shouldn't type arguments be provided after lifetime arguments?
There was a problem hiding this comment.
Huh. Yes, they should be. But that didn't come from my PR though, so I'm scared to touch it. 😆
I mean, I know exactly where this error is thrown, but I'm not sure I should be doing it lol
|
☔ The latest upstream changes (presumably #72778) made this pull request unmergeable. Please resolve the merge conflicts. |
varkor
left a comment
There was a problem hiding this comment.
This is looking good, thanks @rakshith-ravi! Just a few comments!
src/test/ui/const-generics/const-arg-type-arg-misordered.stderr
Outdated
Show resolved
Hide resolved
|
☔ The latest upstream changes (presumably #72935) made this pull request unmergeable. Please resolve the merge conflicts. |
|
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
varkor
left a comment
There was a problem hiding this comment.
This is looking good! I just have a couple of comments about refactoring! After that, could you squash your commits down to one or two (e.g. by rebasing), and then I think we'll be good to go!
|
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
|
Sorry about the spam, my laptop isn't good enough for me to build this repo, so I'm trying my best to figure out the code without building it. |
|
You can use |
varkor
left a comment
There was a problem hiding this comment.
This is looking good! Just a few more comments. (Sorry I didn't spot that you had updated the pull request earlier.)
src/librustc_typeck/astconv.rs
Outdated
There was a problem hiding this comment.
Instead of two very similar match conditions, could we do something like the following?
let (ordered_params, mut params_present) = defs.params.clone().map(|param| (param, match param.kind { … })).sort_by_key(|(_, ord)| ord);
params_present.dedup();There was a problem hiding this comment.
This was marked as resolved, but we're still matching on param.kind twice?
There was a problem hiding this comment.
Yeah the code mentioned there doesn't seem to compile. It seems to complain something about not being able to convert from map to tuple
There was a problem hiding this comment.
I couldn't quite think off the top of my head what the types would be, so it may require a little adaption, but I think it would be good to only match on param.kind once if that results in cleaner code.
There was a problem hiding this comment.
Alright, cool. I'll come up with something
There was a problem hiding this comment.
Hey @varkor. I'm getting this error:
the trait `std::hash::Hash` is not implemented for `rustc_middle::ty::GenericParamDef`
when trying to insert a GenericParamDef into a hashset.
Any idea how I can overcome this?
There was a problem hiding this comment.
My idea was not to use a hash set any more: we're using a vector instead, but because it's sorted, once we dedup, the elements will be unique.
|
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
|
See if you can get something like this to work. In any case, I think it should be good after that, so could you squash your commits down to one or two commits to keep the history clean, and then I think it's ready to merge :) |
src/librustc_typeck/astconv.rs
Outdated
There was a problem hiding this comment.
Can you simply use unzip for this part?
|
One more comment; sorry for being so picky! |
|
No worries. Sorry, I didn't know |
|
@rakshith-ravi: great, thanks for your hard work! Could you squash your changes down to 1 or 2 commits? After that, it's good to be merged :) |
|
Squashed 😄 |
|
Thanks @rakshith-ravi! @bors r+ rollup |
|
📌 Commit 0624a5a has been approved by |
Improve compiler error message for wrong generic parameter order - Added optional "help" parameter that shows a help message on the compiler error if required. - Added a simple ordered parameter as a sample help. @varkor will make more changes as required. Let me know if I'm heading in the right direction. Fixes rust-lang#68437 r? @varkor
Improve compiler error message for wrong generic parameter order - Added optional "help" parameter that shows a help message on the compiler error if required. - Added a simple ordered parameter as a sample help. @varkor will make more changes as required. Let me know if I'm heading in the right direction. Fixes rust-lang#68437 r? @varkor
Improve compiler error message for wrong generic parameter order - Added optional "help" parameter that shows a help message on the compiler error if required. - Added a simple ordered parameter as a sample help. @varkor will make more changes as required. Let me know if I'm heading in the right direction. Fixes rust-lang#68437 r? @varkor
…arth Rollup of 9 pull requests Successful merges: - rust-lang#72271 (Improve compiler error message for wrong generic parameter order) - rust-lang#72493 ( move leak-check to during coherence, candidate eval) - rust-lang#73398 (A way forward for pointer equality in const eval) - rust-lang#73472 (Clean up E0689 explanation) - rust-lang#73496 (Account for multiple impl/dyn Trait in return type when suggesting `'_`) - rust-lang#73515 (Add second message for LiveDrop errors) - rust-lang#73567 (Clarify --extern documentation.) - rust-lang#73572 (Fix typos in doc comments) - rust-lang#73590 (bootstrap: no `config.toml` exists regression) Failed merges: r? @ghost
@varkor will make more changes as required. Let me know if I'm heading in the right direction.
Fixes #68437
r? @varkor