-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Add note to non-exhaustive match on reference to empty #80651
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (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. |
I only see changes to the tests. Did you forget to commit the changes you made to the compiler? |
The job Click to see the possible cause of the failure (guessed by this bot)
|
Rust prints "type `&A` is non-empty" even is A is empty. This is the intended behavior, but can be confusing. This commit adds a note to non-exhaustive pattern errors if they are a reference to something uninhabited. I did not add tests to check that the note is not shown for non-references or inhabited references, because this is already done in other tests. Maybe the added test is superfluous, because `always-inhabited-union-ref` already checks for this case. This does not handle &&Void or &&&void etc. I could add those as special cases as well and ignore people who need quadruple references. Fixes rust-lang#78123
287c152
to
998bf0a
Compare
r? @Nadrieril |
The job Click to see the possible cause of the failure (guessed by this bot)
|
src/test/ui/pattern/usefulness/issue-78123-non-exhaustive-reference.rs
Outdated
Show resolved
Hide resolved
This test is also changed by adding a note about uninhabited references still counting as inhabited.
It seems you also need to update the output of
Fair enough, that's a simple enough case anyways.
Eh, I can't tell what's needed here. I'm happy either way.
After you add |
@rustbot label -S-waiting-on-author +S-waiting-on-review |
Looks good to me, thank you! @bors r+ |
📌 Commit 914bc17 has been approved by |
☀️ Test successful - checks-actions |
Summary: Turns out that reference to empty enum is consider inhabited: rust-lang/rust#80651 Fix by adding a unreachable clause. Differential Revision: D36850027 fbshipit-source-id: cc338becc4ebd57c33441c2d8575b07c3052229e
Summary: Turns out that reference to empty enum is consider inhabited: rust-lang/rust#80651 Fix by adding a unreachable clause. Reviewed By: brianc118 Differential Revision: D36850027 fbshipit-source-id: 83814b331d51bc843629885ed070d527792e9736
Rust prints "type
&A
is non-empty" even is A is empty.This is the intended behavior, but can be confusing.
This commit adds a note to non-exhaustive pattern errors if they are a
reference to something uninhabited.
I did not add tests to check that the note is not shown for
non-references or inhabited references, because this is already done
in other tests.
Maybe the added test is superfluous, because
always-inhabited-union-ref
already checks for this case.This does not handle &&Void or &&&void etc. I could add those as special
cases as well and ignore people who need quadruple
references.
Fixes #78123