-
Notifications
You must be signed in to change notification settings - Fork 13.6k
pattern_analysis: add option to get a full set of witnesses #144171
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
Conversation
This comment has been minimized.
This comment has been minimized.
b30d696
to
180b931
Compare
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 needs a change in one more place:
rust/compiler/rustc_pattern_analysis/src/usefulness.rs
Lines 993 to 1002 in a413f77
let report_individual_missing_ctors = self.is_scrutinee || !all_missing; | |
if !missing_ctors.is_empty() && !report_individual_missing_ctors { | |
// Report `_` as missing. | |
missing_ctors = vec![Constructor::Wildcard]; | |
} else if missing_ctors.iter().any(|c| c.is_non_exhaustive()) { | |
// We need to report a `_` anyway, so listing other constructors would be redundant. | |
// `NonExhaustive` is displayed as `_` just like `Wildcard`, but it will be picked | |
// up by diagnostics to add a note about why `_` is required here. | |
missing_ctors = vec![Constructor::NonExhaustive]; | |
} |
should be:
let report_individual_missing_ctors =
cx.exhaustive_witnesses() || self.is_scrutinee || !all_missing;
if !missing_ctors.is_empty() && !report_individual_missing_ctors {
// Report `_` as missing.
missing_ctors = vec![Constructor::Wildcard];
} else if !cx.exhaustive_witnesses() && missing_ctors.iter().any(|c| c.is_non_exhaustive())
{
// We need to report a `_` anyway, so listing other constructors would be redundant.
// `NonExhaustive` is displayed as `_` just like `Wildcard`, but it will be picked
// up by diagnostics to add a note about why `_` is required here.
missing_ctors = vec![Constructor::NonExhaustive];
}
I chose not to do that on purpose because that added too many witnesses. EDIT: you're right about the |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
3ca51e0
to
af07c08
Compare
r? compiler |
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.
Assuming this satisfies r-a's needs, r=me
I believe it does! @bors r=davidtwco |
Rollup of 9 pull requests Successful merges: - #144089 (Rehome 35 `tests/ui/issues/` tests to other subdirectories under `tests/ui/`) - #144171 (pattern_analysis: add option to get a full set of witnesses) - #144201 (Mention type that could be `Clone` but isn't in more cases) - #144316 (bootstrap: Move musl-root fallback out of sanity check) - #144339 (Enable dwarf-mixed-versions-lto.rs test on RISC-V (riscv64)) - #144341 (Enable const-vector.rs test on RISC-V (riscv64)) - #144352 (RustWrapper: Suppress getNextNonDebugInfoInstruction) - #144356 (Add `ignore-backends` annotations in failing GCC backend ui tests) - #144364 (Update `dlmalloc` dependency of libstd) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #144171 - Nadrieril:exhaustive-witnesses, r=davidtwco pattern_analysis: add option to get a full set of witnesses This adds an option to the rustc_pattern_analysis machinery to have it report a complete set of patterns when a match is non-exhaustive (by default we only guarantee to report _some_ missing patterns). This is for use in rust-analyzer. Leaving as draft until I'm sure this is what r-a needs. r? ghost
This adds an option to the rustc_pattern_analysis machinery to have it report a complete set of patterns when a match is non-exhaustive (by default we only guarantee to report some missing patterns). This is for use in rust-analyzer.
Leaving as draft until I'm sure this is what r-a needs.
r? ghost