Uh oh!
There was an error while loading. Please reload this page.
ignore uninhabited non-exhaustive variant fields - #65414
Conversation
davidtwco
commented
Oct 14, 2019
I'm not sure if this is the best way to fix this, so I'm happy to take an alternate approach if anyone has a better solution. |
Nadrieril
commented
Oct 14, 2019
Yeah, I'd think there must be a better solution. |
Centril
commented
Oct 15, 2019
The idea is that with |
Nadrieril
commented
Oct 15, 2019
So this is about ignoring uninhabitedness when the variant is marked |
Nadrieril
commented
Oct 16, 2019
Okay I figured it out. I'll take this line as an example: That line would be detected as unreachable if the variant wasn't declared non_exhaustive. The reason for this behaviour is that we start with v = [PartiallyInhabitedVariants::Struct { x, .. }], then we specialize it by the PartiallyInhabitedVariants::Struct constructor. Then v = [_] where the wildcard has type !. So it is detected as unreachable.We can't avoid expanding So I'd say a good solution might be to specifically ignore the fields of Does that make sense ? PS: @davidtwco would you mind waiting for #65160 to get merged before merging this PR ? Otherwise I'd have to rebase the fix and it will be a pain. |
davidtwco
commented
Oct 16, 2019
I haven’t read this yet, will do later.
No worries, I just wanted to put something up to get review. |
11a0114 to
dd5bd7bComparedavidtwco
commented
Oct 18, 2019
Thanks @Nadrieril, I've updated the PR with your suggested approach. |
This comment has been minimized.
This comment has been minimized.
dd5bd7b to
1bf1236Comparedavidtwco
commented
Oct 21, 2019
r? @varkor |
Uh oh!
There was an error while loading. Please reload this page.
This commit modifies the uninhabitedness checking so that the fields of a non-exhaustive variant (which is not local) are ignored if they are uninhabited. This is an improvement over the previous behaviour which considered all non-local non-exhaustive variants useful because unreachable patterns are now detected. Signed-off-by: David Wood <david@davidtw.co>
1bf1236 to
7ffbd62Comparedavidtwco
commented
Oct 24, 2019
Centril
commented
Oct 24, 2019
Sounds reasonable; it does enhance the rationale for @Nadrieril to split their PR into parts. ;) |
varkor
commented
Oct 24, 2019
@bors r+ rollup |
bors
commented
Oct 24, 2019
📌 Commit 7ffbd62 has been approved by |
…e-always-useful, r=varkor ignore uninhabited non-exhaustive variant fields Fixesrust-lang#65157. This PR modifies the uninhabitedness checking so that the fields of a non-exhaustive variant (which is not local) are ignored if they are uninhabited. This is an improvement over the previous behaviour which considered all non-local non-exhaustive variants useful because unreachable patterns are now detected. r? @arielb1 cc @varkor
Rollup of 9 pull requests Successful merges: - #62959 (Add by-value iterator for arrays ) - #65390 (Add long error explanation for E0576) - #65408 (reorder config.toml.example options and add one missing option) - #65414 (ignore uninhabited non-exhaustive variant fields) - #65666 (Deprecated proc_macro doesn't trigger warning on build library) - #65742 (Pre-expansion gate most of the things) - #65747 (Adjust the tracking issue for `untagged_unions`.) - #65763 (Changed APIT with explicit generic args span to specific arg spans) - #65775 (Fix more `ReEmpty` ICEs) Failed merges: - #65519 (trait-based structural match implementation) r? @ghost
Fixes#65157.
This PR modifies the uninhabitedness checking so that the fields of
a non-exhaustive variant (which is not local) are ignored if they are
uninhabited. This is an improvement over the previous behaviour which
considered all non-local non-exhaustive variants useful because
unreachable patterns are now detected.
r? @arielb1
cc @varkor