@@ -242,7 +242,7 @@ use rustc_hir::{HirId, RangeEnd};
242242use rustc_middle:: mir:: interpret:: { truncate, AllocId , ConstValue , Pointer , Scalar } ;
243243use rustc_middle:: mir:: Field ;
244244use rustc_middle:: ty:: layout:: IntegerExt ;
245- use rustc_middle:: ty:: { self , Const , FieldDef , Ty , TyCtxt , TypeFoldable , VariantDef } ;
245+ use rustc_middle:: ty:: { self , Const , FieldDef , Ty , TyCtxt , VariantDef } ;
246246use rustc_session:: lint;
247247use rustc_span:: { Span , DUMMY_SP } ;
248248use rustc_target:: abi:: { Integer , Size , VariantIdx } ;
@@ -1771,11 +1771,7 @@ impl<'tcx> fmt::Debug for MissingConstructors<'tcx> {
17711771/// to a set of such vectors `m` - this is defined as there being a set of
17721772/// inputs that will match `v` but not any of the sets in `m`.
17731773///
1774- /// All the patterns at each column of the `matrix ++ v` matrix must
1775- /// have the same type, except that wildcard (PatKind::Wild) patterns
1776- /// with type `TyErr` are also allowed, even if the "type of the column"
1777- /// is not `TyErr`. That is used to represent private fields, as using their
1778- /// real type would assert that they are inhabited.
1774+ /// All the patterns at each column of the `matrix ++ v` matrix must have the same type.
17791775///
17801776/// This is used both for reachability checking (if a pattern isn't useful in
17811777/// relation to preceding patterns, it is not reachable) and exhaustiveness
@@ -1839,34 +1835,7 @@ crate fn is_useful<'p, 'tcx>(
18391835 return if any_is_useful { Useful ( unreachable_pats) } else { NotUseful } ;
18401836 }
18411837
1842- let ( ty, span) = matrix
1843- . heads ( )
1844- . map ( |r| ( r. ty , r. span ) )
1845- . find ( |( ty, _) | !ty. references_error ( ) )
1846- . unwrap_or ( ( v. head ( ) . ty , v. head ( ) . span ) ) ;
1847- let pcx = PatCtxt {
1848- // TyErr is used to represent the type of wildcard patterns matching
1849- // against inaccessible (private) fields of structs, so that we won't
1850- // be able to observe whether the types of the struct's fields are
1851- // inhabited.
1852- //
1853- // If the field is truly inaccessible, then all the patterns
1854- // matching against it must be wildcard patterns, so its type
1855- // does not matter.
1856- //
1857- // However, if we are matching against non-wildcard patterns, we
1858- // need to know the real type of the field so we can specialize
1859- // against it. This primarily occurs through constants - they
1860- // can include contents for fields that are inaccessible at the
1861- // location of the match. In that case, the field's type is
1862- // inhabited - by the constant - so we can just use it.
1863- //
1864- // FIXME: this might lead to "unstable" behavior with macro hygiene
1865- // introducing uninhabited patterns for inaccessible fields. We
1866- // need to figure out how to model that.
1867- ty,
1868- span,
1869- } ;
1838+ let pcx = PatCtxt { ty : v. head ( ) . ty , span : v. head ( ) . span } ;
18701839
18711840 debug ! ( "is_useful_expand_first_col: pcx={:#?}, expanding {:#?}" , pcx, v. head( ) ) ;
18721841
0 commit comments