summary refs log tree commit diff
path: root/compiler/rustc_pattern_analysis
diff options
context:
space:
mode:
authorNadrieril <nadrieril+git@gmail.com>2023-12-11 21:56:17 +0100
committerNadrieril <nadrieril+git@gmail.com>2023-12-15 16:58:38 +0100
commit63c5b008e12355615a3dfe5b4c83b9a109b2bbc6 (patch)
tree28f6075190d0b1e3ff9ded5067fdb15a94ff3ff3 /compiler/rustc_pattern_analysis
parentf30c5956f5a755c532cc2a29f089a908bc0201fe (diff)
downloadrust-63c5b008e12355615a3dfe5b4c83b9a109b2bbc6.tar.gz
rust-63c5b008e12355615a3dfe5b4c83b9a109b2bbc6.zip
Make the crate compile on stable
Diffstat (limited to 'compiler/rustc_pattern_analysis')
-rw-r--r--compiler/rustc_pattern_analysis/Cargo.toml15
-rw-r--r--compiler/rustc_pattern_analysis/src/usefulness.rs5
2 files changed, 17 insertions, 3 deletions
diff --git a/compiler/rustc_pattern_analysis/Cargo.toml b/compiler/rustc_pattern_analysis/Cargo.toml
index 4c374056183..908d00cf105 100644
--- a/compiler/rustc_pattern_analysis/Cargo.toml
+++ b/compiler/rustc_pattern_analysis/Cargo.toml
@@ -6,24 +6,28 @@ edition = "2021"
 [dependencies]
 # tidy-alphabetical-start
 rustc_apfloat = "0.2.0"
-rustc_arena = { path = "../rustc_arena" }
+rustc_arena = { path = "../rustc_arena", optional = true }
 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 }
-rustc_index = { path = "../rustc_index" }
+rustc_index = { path = "../rustc_index", default-features = false }
 rustc_macros = { path = "../rustc_macros", optional = true }
 rustc_middle = { path = "../rustc_middle", optional = true }
 rustc_session = { path = "../rustc_session", optional = true }
 rustc_span = { path = "../rustc_span", optional = true }
 rustc_target = { path = "../rustc_target", optional = true }
-smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
+smallvec = { version = "1.8.1", features = ["union"] }
 tracing = "0.1"
+typed-arena = { version = "2.0.2", optional = true }
 # tidy-alphabetical-end
 
 [features]
 default = ["rustc"]
+# It's not possible to only enable the `typed_arena` dependency when the `rustc` feature is off, so
+# we use another feature instead. The crate won't compile if one of these isn't enabled.
 rustc = [
+    "dep:rustc_arena",
     "dep:rustc_data_structures",
     "dep:rustc_errors",
     "dep:rustc_fluent_macro",
@@ -33,4 +37,9 @@ rustc = [
     "dep:rustc_session",
     "dep:rustc_span",
     "dep:rustc_target",
+    "smallvec/may_dangle",
+    "rustc_index/nightly",
+]
+stable = [
+    "dep:typed-arena",
 ]
diff --git a/compiler/rustc_pattern_analysis/src/usefulness.rs b/compiler/rustc_pattern_analysis/src/usefulness.rs
index 01f3962b31f..3141e992f33 100644
--- a/compiler/rustc_pattern_analysis/src/usefulness.rs
+++ b/compiler/rustc_pattern_analysis/src/usefulness.rs
@@ -555,7 +555,12 @@
 use smallvec::{smallvec, SmallVec};
 use std::fmt;
 
+// It's not possible to only enable the `typed_arena` dependency when the `rustc` feature is off, so
+// we use another feature instead. The crate won't compile if one of these isn't enabled.
+#[cfg(feature = "rustc")]
 use rustc_arena::TypedArena;
+#[cfg(feature = "stable")]
+use typed_arena::Arena as TypedArena;
 
 use crate::constructor::{Constructor, ConstructorSet};
 use crate::pat::{DeconstructedPat, WitnessPat};