Skip to content

Commit 7d0177f

Browse files
committed
Clean up dead code
1 parent ef3403e commit 7d0177f

File tree

3 files changed

+10
-24
lines changed

3 files changed

+10
-24
lines changed

Diff for: compiler/rustc_pattern_analysis/src/constructor.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -858,12 +858,14 @@ impl<Cx: TypeCx> ConstructorSet<Cx> {
858858
/// any) are missing; 2/ split constructors to handle non-trivial intersections e.g. on ranges
859859
/// or slices. This can get subtle; see [`SplitConstructorSet`] for details of this operation
860860
/// and its invariants.
861-
#[instrument(level = "debug", skip(self, pcx, ctors), ret)]
861+
#[instrument(level = "debug", skip(self, ctors), ret)]
862862
pub(crate) fn split<'a>(
863863
&self,
864-
pcx: &PlaceCtxt<'a, '_, Cx>,
865864
ctors: impl Iterator<Item = &'a Constructor<Cx>> + Clone,
866-
) -> SplitConstructorSet<Cx> {
865+
) -> SplitConstructorSet<Cx>
866+
where
867+
Cx: 'a,
868+
{
867869
let mut present: SmallVec<[_; 1]> = SmallVec::new();
868870
// Empty constructors found missing.
869871
let mut missing_empty = Vec::new();

Diff for: compiler/rustc_pattern_analysis/src/lints.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl<'p, 'tcx> PatternColumn<'p, 'tcx> {
5454
/// Do constructor splitting on the constructors of the column.
5555
fn analyze_ctors(&self, pcx: &PlaceCtxt<'_, 'p, 'tcx>) -> SplitConstructorSet<'p, 'tcx> {
5656
let column_ctors = self.patterns.iter().map(|p| p.ctor());
57-
pcx.ctors_for_ty().split(pcx, column_ctors)
57+
pcx.ctors_for_ty().split(column_ctors)
5858
}
5959

6060
fn iter(&self) -> impl Iterator<Item = &'p DeconstructedPat<'p, 'tcx>> + Captures<'_> {

Diff for: compiler/rustc_pattern_analysis/src/usefulness.rs

+4-20
Original file line numberDiff line numberDiff line change
@@ -736,15 +736,13 @@ pub(crate) struct PlaceCtxt<'a, 'p, Cx: TypeCx> {
736736
pub(crate) mcx: MatchCtxt<'a, 'p, Cx>,
737737
/// Type of the place under investigation.
738738
pub(crate) ty: Cx::Ty,
739-
/// Whether the place is the original scrutinee place, as opposed to a subplace of it.
740-
pub(crate) is_scrutinee: bool,
741739
}
742740

743741
impl<'a, 'p, Cx: TypeCx> PlaceCtxt<'a, 'p, Cx> {
744742
/// A `PlaceCtxt` when code other than `is_useful` needs one.
745743
#[cfg_attr(not(feature = "rustc"), allow(dead_code))]
746744
pub(crate) fn new_dummy(mcx: MatchCtxt<'a, 'p, Cx>, ty: Cx::Ty) -> Self {
747-
PlaceCtxt { mcx, ty, is_scrutinee: false }
745+
PlaceCtxt { mcx, ty }
748746
}
749747

750748
pub(crate) fn ctor_arity(&self, ctor: &Constructor<Cx>) -> usize {
@@ -767,30 +765,16 @@ impl<'a, 'p, Cx: TypeCx> PlaceCtxt<'a, 'p, Cx> {
767765
pub enum ValidityConstraint {
768766
ValidOnly,
769767
MaybeInvalid,
770-
/// Option for backwards compatibility: the place is not known to be valid but we allow omitting
771-
/// `useful && !reachable` arms anyway.
772-
MaybeInvalidButAllowOmittingArms,
773768
}
774769

775770
impl ValidityConstraint {
776771
pub fn from_bool(is_valid_only: bool) -> Self {
777772
if is_valid_only { ValidOnly } else { MaybeInvalid }
778773
}
779774

780-
fn allow_omitting_side_effecting_arms(self) -> Self {
781-
match self {
782-
MaybeInvalid | MaybeInvalidButAllowOmittingArms => MaybeInvalidButAllowOmittingArms,
783-
// There are no side-effecting empty arms here, nothing to do.
784-
ValidOnly => ValidOnly,
785-
}
786-
}
787-
788775
fn is_known_valid(self) -> bool {
789776
matches!(self, ValidOnly)
790777
}
791-
fn allows_omitting_empty_arms(self) -> bool {
792-
matches!(self, ValidOnly | MaybeInvalidButAllowOmittingArms)
793-
}
794778

795779
/// If the place has validity given by `self` and we read that the value at the place has
796780
/// constructor `ctor`, this computes what we can assume about the validity of the constructor
@@ -813,7 +797,7 @@ impl fmt::Display for ValidityConstraint {
813797
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
814798
let s = match self {
815799
ValidOnly => "✓",
816-
MaybeInvalid | MaybeInvalidButAllowOmittingArms => "?",
800+
MaybeInvalid => "?",
817801
};
818802
write!(f, "{s}")
819803
}
@@ -1374,7 +1358,7 @@ fn compute_exhaustiveness_and_usefulness<'a, 'p, Cx: TypeCx>(
13741358
};
13751359

13761360
debug!("ty: {ty:?}");
1377-
let pcx = &PlaceCtxt { mcx, ty, is_scrutinee: is_top_level };
1361+
let pcx = &PlaceCtxt { mcx, ty };
13781362
let ctors_for_ty = pcx.ctors_for_ty();
13791363
// Whether the place/column we are inspecting is known to contain valid data.
13801364
let place_validity = matrix.place_validity[0];
@@ -1390,7 +1374,7 @@ fn compute_exhaustiveness_and_usefulness<'a, 'p, Cx: TypeCx>(
13901374

13911375
// Analyze the constructors present in this column.
13921376
let ctors = matrix.heads().map(|p| p.ctor());
1393-
let split_set = ctors_for_ty.split(pcx, ctors);
1377+
let split_set = ctors_for_ty.split(ctors);
13941378
let all_missing = split_set.present.is_empty();
13951379
// Build the set of constructors we will specialize with. It must cover the whole type.
13961380
let mut split_ctors = split_set.present;

0 commit comments

Comments
 (0)