-
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 panic in 'remove semicolon' when types are not local #81991
Conversation
r? @lcnr (rust-highfive has picked a reviewer for you, use r? to override) |
I'm not sure if this is the best "fix" for #81839. This is the error message with this patch: (without the patch the repro panics)
There should be some way of comparing two non-local opaque types for type checking. We should be able to use the same method to compare types of these two branches and generate the suggestion. I couldn't find how to do the comparison though.. See also my question in Zulip. |
Last commit brings back the "consider removing this semicolon" help. Current error message:
This help is not great IMO, but I think improving it is outside of the scope of #81839. |
Should I add a 'run_make' test for this? Does anyone know a better way to test this? |
This comment has been minimized.
This comment has been minimized.
Hm, I think the new output of the failing test is actually an improvement. Relevant parts of the test: async fn async_dummy() {}
async fn async_extra_semicolon_same() {
let _ = match true {
true => {
async_dummy();
}
false => async_dummy(),
};
} Error message in
Error message with this PR:
So we no longer suggest boxing, which is a good thing because just deleting the semicolon is enough to make this program type check. |
Ping @lcnr |
yes, you can have multicrate tests by adding |
It's not possible to check if removing a semicolon fixes the type error when checking match arms and one or both of the last arm's and the current arm's return types are imported "opaque" types. In these cases we don't generate a "consider removing semicolon" suggestions. Fixes rust-lang#81839
Thanks @lcnr , I added a regression test now and rebased the branch. Let me know if it looks good and I'll squash the commits. |
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.
this method seems a bit weird to me, even when ignoring your changes so I want to look at it in a bit more depth. Don't have a lot of time rn so I might not get to it during the next two weeks.
The added tests looks good 👍
@estebank would be interested in taking this over?
r? @estebank |
@bors r+ rollup It's great to get the review by the time all my potential nits have been addressed :) Looks great! |
📌 Commit 9ef67e0 has been approved by |
Fix panic in 'remove semicolon' when types are not local It's not possible to check if removing a semicolon fixes the type error when checking match arms and one or both of the last arm's and the current arm's return types are imported "opaque" types. In these cases we don't generate a "consider removing semicolon" suggestions. Fixes rust-lang#81839 --- I'm not sure how to add a test for this. I think the test would need at least two crates. Do we have any existing tests that do this so that I can take a look?
Fix panic in 'remove semicolon' when types are not local It's not possible to check if removing a semicolon fixes the type error when checking match arms and one or both of the last arm's and the current arm's return types are imported "opaque" types. In these cases we don't generate a "consider removing semicolon" suggestions. Fixes rust-lang#81839 --- I'm not sure how to add a test for this. I think the test would need at least two crates. Do we have any existing tests that do this so that I can take a look?
…laumeGomez Rollup of 7 pull requests Successful merges: - rust-lang#80595 (`impl PartialEq<Punct> for char`; symmetry for rust-lang#78636) - rust-lang#81991 (Fix panic in 'remove semicolon' when types are not local) - rust-lang#82176 (fix MIR fn-ptr pretty-printing) - rust-lang#82244 (Keep consistency in example for Stdin StdinLock) - rust-lang#82260 (rustc: Show ``@path`` usage in stable) - rust-lang#82316 (Fix minor mistake in LTO docs.) - rust-lang#82332 (Don't generate src link on dummy spans) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
It's not possible to check if removing a semicolon fixes the type error
when checking match arms and one or both of the last arm's and the
current arm's return types are imported "opaque" types. In these cases
we don't generate a "consider removing semicolon" suggestions.
Fixes #81839
I'm not sure how to add a test for this. I think the test would need at least two crates. Do we have any existing tests that do this so that I can take a look?