Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit ec58af9

Browse files
committed
pcx.span was no longer meaningful
1 parent 702d104 commit ec58af9

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -763,12 +763,7 @@ impl<'tcx> Constructor<'tcx> {
763763
(Opaque(self_id), Opaque(other_id)) => self_id == other_id,
764764
(Opaque(..), _) | (_, Opaque(..)) => false,
765765

766-
_ => span_bug!(
767-
pcx.span,
768-
"trying to compare incompatible constructors {:?} and {:?}",
769-
self,
770-
other
771-
),
766+
_ => bug!("trying to compare incompatible constructors {:?} and {:?}", self, other),
772767
}
773768
}
774769
}
@@ -1134,9 +1129,8 @@ impl<'p, 'tcx> Fields<'p, 'tcx> {
11341129
fn wildcards_from_tys(
11351130
cx: &MatchCheckCtxt<'p, 'tcx>,
11361131
tys: impl IntoIterator<Item = Ty<'tcx>>,
1137-
span: Span,
11381132
) -> Self {
1139-
Fields::from_iter(cx, tys.into_iter().map(|ty| DeconstructedPat::wildcard(ty, span)))
1133+
Fields::from_iter(cx, tys.into_iter().map(|ty| DeconstructedPat::wildcard(ty, DUMMY_SP)))
11401134
}
11411135

11421136
// In the cases of either a `#[non_exhaustive]` field list or a non-public field, we hide
@@ -1172,26 +1166,26 @@ impl<'p, 'tcx> Fields<'p, 'tcx> {
11721166
pub(super) fn wildcards(pcx: &PatCtxt<'_, 'p, 'tcx>, constructor: &Constructor<'tcx>) -> Self {
11731167
let ret = match constructor {
11741168
Single | Variant(_) => match pcx.ty.kind() {
1175-
ty::Tuple(fs) => Fields::wildcards_from_tys(pcx.cx, fs.iter(), pcx.span),
1176-
ty::Ref(_, rty, _) => Fields::wildcards_from_tys(pcx.cx, once(*rty), pcx.span),
1169+
ty::Tuple(fs) => Fields::wildcards_from_tys(pcx.cx, fs.iter()),
1170+
ty::Ref(_, rty, _) => Fields::wildcards_from_tys(pcx.cx, once(*rty)),
11771171
ty::Adt(adt, args) => {
11781172
if adt.is_box() {
11791173
// The only legal patterns of type `Box` (outside `std`) are `_` and box
11801174
// patterns. If we're here we can assume this is a box pattern.
1181-
Fields::wildcards_from_tys(pcx.cx, once(args.type_at(0)), pcx.span)
1175+
Fields::wildcards_from_tys(pcx.cx, once(args.type_at(0)))
11821176
} else {
11831177
let variant = &adt.variant(constructor.variant_index_for_adt(*adt));
11841178
let tys = Fields::list_variant_nonhidden_fields(pcx.cx, pcx.ty, variant)
11851179
.map(|(_, ty)| ty);
1186-
Fields::wildcards_from_tys(pcx.cx, tys, pcx.span)
1180+
Fields::wildcards_from_tys(pcx.cx, tys)
11871181
}
11881182
}
11891183
_ => bug!("Unexpected type for `Single` constructor: {:?}", pcx),
11901184
},
11911185
Slice(slice) => match *pcx.ty.kind() {
11921186
ty::Slice(ty) | ty::Array(ty, _) => {
11931187
let arity = slice.arity();
1194-
Fields::wildcards_from_tys(pcx.cx, (0..arity).map(|_| ty), pcx.span)
1188+
Fields::wildcards_from_tys(pcx.cx, (0..arity).map(|_| ty))
11951189
}
11961190
_ => bug!("bad slice pattern {:?} {:?}", constructor, pcx),
11971191
},
@@ -1488,7 +1482,7 @@ impl<'p, 'tcx> DeconstructedPat<'p, 'tcx> {
14881482
let wildcard: &_ = pcx
14891483
.cx
14901484
.pattern_arena
1491-
.alloc(DeconstructedPat::wildcard(inner_ty, pcx.span));
1485+
.alloc(DeconstructedPat::wildcard(inner_ty, DUMMY_SP));
14921486
let extra_wildcards = other_slice.arity() - self_slice.arity();
14931487
let extra_wildcards = (0..extra_wildcards).map(|_| wildcard);
14941488
prefix.iter().chain(extra_wildcards).chain(suffix).collect()

compiler/rustc_mir_build/src/thir/pattern/usefulness.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,6 @@ pub(super) struct PatCtxt<'a, 'p, 'tcx> {
360360
pub(super) cx: &'a MatchCheckCtxt<'p, 'tcx>,
361361
/// Type of the current column under investigation.
362362
pub(super) ty: Ty<'tcx>,
363-
/// Span of the current pattern under investigation.
364-
pub(super) span: Span,
365363
}
366364

367365
impl<'a, 'p, 'tcx> fmt::Debug for PatCtxt<'a, 'p, 'tcx> {
@@ -788,7 +786,7 @@ fn compute_usefulness<'p, 'tcx>(
788786

789787
let ty = matrix.head_ty();
790788
debug!("ty: {ty:?}");
791-
let pcx = &PatCtxt { cx, ty, span: DUMMY_SP };
789+
let pcx = &PatCtxt { cx, ty };
792790

793791
let ctors = matrix.heads().map(|p| p.ctor());
794792
let split_set = ConstructorSet::for_ty(pcx.cx, pcx.ty).split(pcx, ctors, is_top_level);
@@ -915,7 +913,7 @@ fn collect_nonexhaustive_missing_variants<'p, 'tcx>(
915913
column: &[&DeconstructedPat<'p, 'tcx>],
916914
) -> Vec<WitnessPat<'tcx>> {
917915
let ty = column[0].ty();
918-
let pcx = &PatCtxt { cx, ty, span: DUMMY_SP };
916+
let pcx = &PatCtxt { cx, ty };
919917

920918
let column_ctors = column.iter().map(|p| p.ctor());
921919
let set = ConstructorSet::for_ty(pcx.cx, pcx.ty).split(pcx, column_ctors, false);

0 commit comments

Comments
 (0)