Skip to content

Commit 2443fba

Browse files
committed
Rewrite the comment on is_multivariant_adt
As Nadrieril remarked, the previous comment was misleadingly framed.
1 parent d05b1d7 commit 2443fba

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

compiler/rustc_hir_typeck/src/expr_use_visitor.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,9 +1855,14 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
18551855
/// builder code does a more specific check, filtering out variants that
18561856
/// happen to be uninhabited.
18571857
///
1858-
/// Here, we cannot perform such an accurate checks, because querying
1859-
/// whether a type is inhabited requires that it has been fully inferred,
1860-
/// which cannot be guaranteed at this point.
1858+
/// Here, it is not practical to perform such a check, because inhabitedness
1859+
/// queries require typeck results, and typeck requires closure capture analysis.
1860+
///
1861+
/// Moreover, the language is moving towards uninhabited variants still semantically
1862+
/// causing a discriminant read, so we *shouldn't* perform any such check.
1863+
///
1864+
/// FIXME(never_patterns): update this comment once the aforementioned MIR builder
1865+
/// code is changed to be insensitive to inhhabitedness.
18611866
#[instrument(skip(self, span), level = "debug")]
18621867
fn is_multivariant_adt(&self, ty: Ty<'tcx>, span: Span) -> bool {
18631868
if let ty::Adt(def, _) = self.cx.structurally_resolve_type(span, ty).kind() {

0 commit comments

Comments
 (0)