File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
src/librustc_mir_build/hair/pattern Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -880,15 +880,15 @@ impl<'tcx> Constructor<'tcx> {
880880 let ty = field. ty ( cx. tcx , substs) ;
881881 let is_visible = adt. is_enum ( )
882882 || field. vis . is_accessible_from ( cx. module , cx. tcx ) ;
883- let is_uninhabited = cx. is_uninhabited ( ty) ;
884- // Treat all non-visible fields as `TyErr`. They can't appear
885- // in any other pattern from this match (because they are
883+ let is_inhabited = ! cx. is_uninhabited ( ty) ;
884+ // Treat all uninhabited non-visible fields as `TyErr`. They can't
885+ // appear in any other pattern from this match (because they are
886886 // private), so their type does not matter - but we don't want
887887 // to know they are uninhabited.
888888 // Also treat all uninhabited types in non-exhaustive variants as
889889 // `TyErr`.
890890 let allowed_to_inspect =
891- is_visible && ! ( is_non_exhaustive && is_uninhabited ) ;
891+ is_inhabited || ( is_visible && !is_non_exhaustive ) ;
892892
893893 if allowed_to_inspect {
894894 Pat :: wildcard_from_ty ( ty)
You can’t perform that action at this time.
0 commit comments