Make the rustc_data_structures
dependency optional
This commit is contained in:
parent
16bd6ac3ed
commit
e646c9f723
@ -7,7 +7,7 @@ edition = "2021"
|
||||
# tidy-alphabetical-start
|
||||
rustc_apfloat = "0.2.0"
|
||||
rustc_arena = { path = "../rustc_arena" }
|
||||
rustc_data_structures = { path = "../rustc_data_structures" }
|
||||
rustc_data_structures = { path = "../rustc_data_structures", optional = true }
|
||||
rustc_errors = { path = "../rustc_errors", optional = true }
|
||||
rustc_fluent_macro = { path = "../rustc_fluent_macro", optional = true }
|
||||
rustc_hir = { path = "../rustc_hir", optional = true }
|
||||
@ -24,6 +24,7 @@ tracing = "0.1"
|
||||
[features]
|
||||
default = ["rustc"]
|
||||
rustc = [
|
||||
"dep:rustc_data_structures",
|
||||
"dep:rustc_errors",
|
||||
"dep:rustc_fluent_macro",
|
||||
"dep:rustc_hir",
|
||||
|
@ -155,7 +155,7 @@ use std::iter::once;
|
||||
use smallvec::SmallVec;
|
||||
|
||||
use rustc_apfloat::ieee::{DoubleS, IeeeFloat, SingleS};
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_index::bit_set::{BitSet, GrowableBitSet};
|
||||
use rustc_index::IndexVec;
|
||||
|
||||
use self::Constructor::*;
|
||||
@ -546,7 +546,7 @@ impl Slice {
|
||||
// therefore `Presence::Seen` in the column.
|
||||
let mut min_var_len = usize::MAX;
|
||||
// Tracks the fixed-length slices we've seen, to mark them as `Presence::Seen`.
|
||||
let mut seen_fixed_lens = FxHashSet::default();
|
||||
let mut seen_fixed_lens = GrowableBitSet::new_empty();
|
||||
match &mut max_slice {
|
||||
VarLen(max_prefix_len, max_suffix_len) => {
|
||||
// A length larger than any fixed-length slice encountered.
|
||||
@ -614,7 +614,7 @@ impl Slice {
|
||||
|
||||
smaller_lengths.map(FixedLen).chain(once(max_slice)).map(move |kind| {
|
||||
let arity = kind.arity();
|
||||
let seen = if min_var_len <= arity || seen_fixed_lens.contains(&arity) {
|
||||
let seen = if min_var_len <= arity || seen_fixed_lens.contains(arity) {
|
||||
Presence::Seen
|
||||
} else {
|
||||
Presence::Unseen
|
||||
@ -906,12 +906,15 @@ impl<Cx: MatchCx> ConstructorSet<Cx> {
|
||||
}
|
||||
}
|
||||
ConstructorSet::Variants { variants, non_exhaustive } => {
|
||||
let seen_set: FxHashSet<_> = seen.iter().map(|c| c.as_variant().unwrap()).collect();
|
||||
let mut seen_set: BitSet<_> = BitSet::new_empty(variants.len());
|
||||
for idx in seen.iter().map(|c| c.as_variant().unwrap()) {
|
||||
seen_set.insert(idx);
|
||||
}
|
||||
let mut skipped_a_hidden_variant = false;
|
||||
|
||||
for (idx, visibility) in variants.iter_enumerated() {
|
||||
let ctor = Variant(idx);
|
||||
if seen_set.contains(&idx) {
|
||||
if seen_set.contains(idx) {
|
||||
present.push(ctor);
|
||||
} else {
|
||||
// We only put visible variants directly into `missing`.
|
||||
|
@ -79,6 +79,13 @@ pub struct MatchArm<'p, Cx: MatchCx> {
|
||||
|
||||
impl<'p, Cx: MatchCx> Copy for MatchArm<'p, Cx> {}
|
||||
|
||||
#[cfg(not(feature = "rustc"))]
|
||||
pub trait Captures<'a> {}
|
||||
#[cfg(not(feature = "rustc"))]
|
||||
impl<'a, T: ?Sized> Captures<'a> for T {}
|
||||
#[cfg(feature = "rustc")]
|
||||
pub use rustc_data_structures::captures::Captures;
|
||||
|
||||
/// The entrypoint for this crate. Computes whether a match is exhaustive and which of its arms are
|
||||
/// useful, and runs some lints.
|
||||
#[cfg(feature = "rustc")]
|
||||
|
@ -5,13 +5,11 @@ use std::fmt;
|
||||
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
|
||||
use rustc_data_structures::captures::Captures;
|
||||
|
||||
use self::Constructor::*;
|
||||
|
||||
use crate::constructor::{Constructor, Slice, SliceKind};
|
||||
use crate::usefulness::PatCtxt;
|
||||
use crate::MatchCx;
|
||||
use crate::{Captures, MatchCx};
|
||||
|
||||
use self::Constructor::*;
|
||||
|
||||
/// Values and patterns can be represented as a constructor applied to some fields. This represents
|
||||
/// a pattern in this form.
|
||||
|
@ -556,14 +556,20 @@ use smallvec::{smallvec, SmallVec};
|
||||
use std::fmt;
|
||||
|
||||
use rustc_arena::TypedArena;
|
||||
use rustc_data_structures::{captures::Captures, stack::ensure_sufficient_stack};
|
||||
|
||||
use crate::constructor::{Constructor, ConstructorSet};
|
||||
use crate::pat::{DeconstructedPat, WitnessPat};
|
||||
use crate::{MatchArm, MatchCx};
|
||||
use crate::{Captures, MatchArm, MatchCx};
|
||||
|
||||
use self::ValidityConstraint::*;
|
||||
|
||||
#[cfg(feature = "rustc")]
|
||||
use rustc_data_structures::stack::ensure_sufficient_stack;
|
||||
#[cfg(not(feature = "rustc"))]
|
||||
pub fn ensure_sufficient_stack<R>(f: impl FnOnce() -> R) -> R {
|
||||
f()
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct PatCtxt<'a, 'p, Cx: MatchCx> {
|
||||
pub(crate) cx: &'a Cx,
|
||||
|
Loading…
x
Reference in New Issue
Block a user