Skip to content
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

Merged
merged 3 commits into from
Jun 3, 2020

Conversation

camelid
Copy link
Member

@camelid camelid commented Jun 1, 2020

Fixes #72815.

r? @varkor

@rust-highfive
Copy link
Collaborator

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.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 1, 2020
"lifetime" => ParamKindOrd::Lifetime,
"type" => ParamKindOrd::Type,
"constant" => ParamKindOrd::Const,
_ => panic!(),
Copy link
Member Author

@camelid camelid Jun 1, 2020

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?

Copy link
Member

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!

Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member

@varkor varkor left a 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.

src/librustc_typeck/astconv.rs Outdated Show resolved Hide resolved
Co-authored-by: varkor <github@varkor.com>
@varkor
Copy link
Member

varkor commented Jun 1, 2020

@bors r+ rollup

Thanks for the pull request, @camelid!

@bors
Copy link
Contributor

bors commented Jun 1, 2020

📌 Commit fd76d23 has been approved by varkor

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 1, 2020
@camelid
Copy link
Member Author

camelid commented Jun 1, 2020

Thanks for reviewing it! :)

Co-authored-by: hafiz <20735482+ayazhafiz@users.noreply.github.com>
@camelid
Copy link
Member Author

camelid commented Jun 1, 2020

@varkor could you re-approve this? Thanks!

@varkor
Copy link
Member

varkor commented Jun 2, 2020

@bors r+

@bors
Copy link
Contributor

bors commented Jun 2, 2020

📌 Commit 56f87ef has been approved by varkor

bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 3, 2020
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
@bors bors merged commit 69a1ac3 into rust-lang:master Jun 3, 2020
@camelid camelid deleted the fix-72815 branch June 3, 2020 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect generic parameter ordering for E0747
6 participants