diff options
| author | bors <bors@rust-lang.org> | 2024-03-31 10:26:55 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-03-31 10:26:55 +0000 |
| commit | 395f780cd8da001b35d7e588177bbad82d5cf8fa (patch) | |
| tree | 6dc2159a09374f03d0fefe1eade9f234759d3632 /compiler/rustc_pattern_analysis/src | |
| parent | 688c30dc9f8434d63bddb65bd6a4d2258d19717c (diff) | |
| parent | 9abf4bcadb350e1688d0dc7ee1eef517702fcf1a (diff) | |
| download | rust-395f780cd8da001b35d7e588177bbad82d5cf8fa.tar.gz rust-395f780cd8da001b35d7e588177bbad82d5cf8fa.zip | |
Auto merge of #123264 - matthiaskrgr:rollup-smyy7j9, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - #123189 (Log BOLT args in bootstrap `rustc` shim) - #123211 (Stop calling visitors `V`) - #123242 (pattern analysis: Require enum indices to be contiguous) - #123260 (Miri subtree update) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_pattern_analysis/src')
| -rw-r--r-- | compiler/rustc_pattern_analysis/src/constructor.rs | 11 | ||||
| -rw-r--r-- | compiler/rustc_pattern_analysis/src/lib.rs | 49 |
2 files changed, 8 insertions, 52 deletions
diff --git a/compiler/rustc_pattern_analysis/src/constructor.rs b/compiler/rustc_pattern_analysis/src/constructor.rs index 95c5556410d..1c9a9ab0f72 100644 --- a/compiler/rustc_pattern_analysis/src/constructor.rs +++ b/compiler/rustc_pattern_analysis/src/constructor.rs @@ -155,13 +155,13 @@ use std::iter::once; use smallvec::SmallVec; use rustc_apfloat::ieee::{DoubleS, IeeeFloat, SingleS}; -use rustc_index::bit_set::GrowableBitSet; +use rustc_index::bit_set::{BitSet, GrowableBitSet}; +use rustc_index::IndexVec; use self::Constructor::*; use self::MaybeInfiniteInt::*; use self::SliceKind::*; -use crate::index; use crate::PatCx; /// Whether we have seen a constructor in the column or not. @@ -920,10 +920,7 @@ pub enum ConstructorSet<Cx: PatCx> { Struct { empty: bool }, /// This type has the following list of constructors. If `variants` is empty and /// `non_exhaustive` is false, don't use this; use `NoConstructors` instead. - Variants { - variants: index::IdxContainer<Cx::VariantIdx, VariantVisibility>, - non_exhaustive: bool, - }, + Variants { variants: IndexVec<Cx::VariantIdx, VariantVisibility>, non_exhaustive: bool }, /// The type is `&T`. Ref, /// The type is a union. @@ -1025,7 +1022,7 @@ impl<Cx: PatCx> ConstructorSet<Cx> { } } ConstructorSet::Variants { variants, non_exhaustive } => { - let mut seen_set = index::IdxSet::new_empty(variants.len()); + let mut seen_set = BitSet::new_empty(variants.len()); for idx in seen.iter().filter_map(|c| c.as_variant()) { seen_set.insert(idx); } diff --git a/compiler/rustc_pattern_analysis/src/lib.rs b/compiler/rustc_pattern_analysis/src/lib.rs index 1a1da5c55f6..6e8843d9049 100644 --- a/compiler/rustc_pattern_analysis/src/lib.rs +++ b/compiler/rustc_pattern_analysis/src/lib.rs @@ -25,50 +25,9 @@ rustc_fluent_macro::fluent_messages! { "../messages.ftl" } use std::fmt; -#[cfg(feature = "rustc")] -pub mod index { - // Faster version when the indices of variants are `0..variants.len()`. - pub use rustc_index::bit_set::BitSet as IdxSet; - pub use rustc_index::Idx; - pub use rustc_index::IndexVec as IdxContainer; -} -#[cfg(not(feature = "rustc"))] -pub mod index { - // Slower version when the indices of variants are something else. - pub trait Idx: Copy + PartialEq + Eq + std::hash::Hash {} - impl<T: Copy + PartialEq + Eq + std::hash::Hash> Idx for T {} - - #[derive(Debug)] - pub struct IdxContainer<K, V>(pub rustc_hash::FxHashMap<K, V>); - impl<K: Idx, V> IdxContainer<K, V> { - pub fn len(&self) -> usize { - self.0.len() - } - pub fn iter_enumerated(&self) -> impl Iterator<Item = (K, &V)> { - self.0.iter().map(|(k, v)| (*k, v)) - } - } - - impl<V> FromIterator<V> for IdxContainer<usize, V> { - fn from_iter<T: IntoIterator<Item = V>>(iter: T) -> Self { - Self(iter.into_iter().enumerate().collect()) - } - } - - #[derive(Debug)] - pub struct IdxSet<T>(pub rustc_hash::FxHashSet<T>); - impl<T: Idx> IdxSet<T> { - pub fn new_empty(_len: usize) -> Self { - Self(Default::default()) - } - pub fn contains(&self, elem: T) -> bool { - self.0.contains(&elem) - } - pub fn insert(&mut self, elem: T) { - self.0.insert(elem); - } - } -} +// Re-exports to avoid rustc_index version issues. +pub use rustc_index::Idx; +pub use rustc_index::IndexVec; #[cfg(feature = "rustc")] use rustc_middle::ty::Ty; @@ -96,7 +55,7 @@ pub trait PatCx: Sized + fmt::Debug { /// Errors that can abort analysis. type Error: fmt::Debug; /// The index of an enum variant. - type VariantIdx: Clone + index::Idx + fmt::Debug; + type VariantIdx: Clone + Idx + fmt::Debug; /// A string literal type StrLit: Clone + PartialEq + fmt::Debug; /// Extra data to store in a match arm. |
