@@ -242,7 +242,7 @@ use rustc_hir::{HirId, RangeEnd};
242
242
use rustc_middle:: mir:: interpret:: { truncate, AllocId , ConstValue , Pointer , Scalar } ;
243
243
use rustc_middle:: mir:: Field ;
244
244
use 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 } ;
246
246
use rustc_session:: lint;
247
247
use rustc_span:: { Span , DUMMY_SP } ;
248
248
use rustc_target:: abi:: { Integer , Size , VariantIdx } ;
@@ -1771,11 +1771,7 @@ impl<'tcx> fmt::Debug for MissingConstructors<'tcx> {
1771
1771
/// to a set of such vectors `m` - this is defined as there being a set of
1772
1772
/// inputs that will match `v` but not any of the sets in `m`.
1773
1773
///
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.
1779
1775
///
1780
1776
/// This is used both for reachability checking (if a pattern isn't useful in
1781
1777
/// relation to preceding patterns, it is not reachable) and exhaustiveness
@@ -1839,34 +1835,7 @@ crate fn is_useful<'p, 'tcx>(
1839
1835
return if any_is_useful { Useful ( unreachable_pats) } else { NotUseful } ;
1840
1836
}
1841
1837
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 } ;
1870
1839
1871
1840
debug ! ( "is_useful_expand_first_col: pcx={:#?}, expanding {:#?}" , pcx, v. head( ) ) ;
1872
1841
0 commit comments