Add helper methods checking for "#[non_exhaustive] that's active"
A check for `#[non_exhaustive]` is often done in combination with checking whether the type is local to the crate, in a variety of ways. Create a helper method and standardize on it as the way to check for this.
This commit is contained in:
parent
59a9b9e9d7
commit
61f70003c2
15 changed files with 46 additions and 46 deletions
|
@ -277,8 +277,7 @@ impl<'tcx> MatchPairTree<'tcx> {
|
|||
.inhabited_predicate(cx.tcx, adt_def)
|
||||
.instantiate(cx.tcx, args)
|
||||
.apply_ignore_module(cx.tcx, cx.infcx.typing_env(cx.param_env))
|
||||
}) && (adt_def.did().is_local()
|
||||
|| !adt_def.is_variant_list_non_exhaustive());
|
||||
}) && !adt_def.variant_list_has_applicable_non_exhaustive();
|
||||
if irrefutable { None } else { Some(TestCase::Variant { adt_def, variant_index }) }
|
||||
}
|
||||
|
||||
|
|
|
@ -613,9 +613,9 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for NonExhaustivePatternsTypeNo
|
|||
diag.span_note(span, fluent::mir_build_def_note);
|
||||
}
|
||||
|
||||
let is_variant_list_non_exhaustive = matches!(self.ty.kind(),
|
||||
ty::Adt(def, _) if def.is_variant_list_non_exhaustive() && !def.did().is_local());
|
||||
if is_variant_list_non_exhaustive {
|
||||
let is_non_exhaustive = matches!(self.ty.kind(),
|
||||
ty::Adt(def, _) if def.variant_list_has_applicable_non_exhaustive());
|
||||
if is_non_exhaustive {
|
||||
diag.note(fluent::mir_build_non_exhaustive_type_note);
|
||||
} else {
|
||||
diag.note(fluent::mir_build_type_note);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue