-
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
Correct generic parameter ordering in error note for E0747 #72848
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @varkor (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
src/librustc_typeck/astconv.rs
Outdated
"lifetime" => ParamKindOrd::Lifetime, | ||
"type" => ParamKindOrd::Type, | ||
"constant" => ParamKindOrd::Const, | ||
_ => panic!(), |
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.
Is this the right way to trigger an ICE?
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 believe that bug!
is the preferred way to trigger an ICE.
In this case, I would recommend changing opt_span_bug_fmt
to take the original GenericParamDefKind
, rather than its string description. That will allow you to write an exhaustive match, removing the need for an explicit panic!
/bug!
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.
Thanks for the tip! I'm new to contributing to rustc, so could you describe the change you're recommending in more detail?
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.
On closer examination, it turns out that the two callers of this function actually have two different "original" types: GenericParamDefKind
and GenericArg
.
I believe your change is actually perfectly correct.
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 went through the same thought process @Aaron1011. It would be a little cleaner to pass ParamKindOrd
directly, but I'm not sure it's worth making more changes.
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.
Is it worth opening an issue?
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.
It would be easy to change in this pull request if desired, but I'm not sure it's worth doing: it adds quite a bit of boilerplate code, and it's only used in this one case. If we ever find ourselves doing something similar again in the future, we should revisit it.
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.
Thanks @camelid, this looks good! Just one tweak: we use bug!
instead of panic!
in the compiler, and it's helpful to give it at least a little message in case it is ever triggered. r=me after that change.
Co-authored-by: varkor <[email protected]>
📌 Commit fd76d23 has been approved by |
Thanks for reviewing it! :) |
Co-authored-by: hafiz <[email protected]>
@varkor could you re-approve this? Thanks! |
@bors r+ |
📌 Commit 56f87ef has been approved by |
Rollup of 5 pull requests Successful merges: - rust-lang#72704 (Remote testing fixes) - rust-lang#72820 (InstCombine: Don't optimize `&mut *x` into `x`) - rust-lang#72848 (Correct generic parameter ordering in error note for E0747) - rust-lang#72902 (Add a test to ensure Fuse stays covariant) - rust-lang#72921 (Add assert to Vec with_capacity docs) Failed merges: r? @ghost
Fixes #72815.
r? @varkor