summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_index
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:32 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:32 +0000
commit4547b622d8d29df964fa2914213088b148c498fc (patch)
tree9fc6b25f3c3add6b745be9a2400a6e96140046e9 /compiler/rustc_index
parentReleasing progress-linux version 1.66.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-4547b622d8d29df964fa2914213088b148c498fc.tar.xz
rustc-4547b622d8d29df964fa2914213088b148c498fc.zip
Merging upstream version 1.67.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_index')
-rw-r--r--compiler/rustc_index/Cargo.toml8
-rw-r--r--compiler/rustc_index/src/lib.rs22
-rw-r--r--compiler/rustc_index/src/vec.rs7
3 files changed, 28 insertions, 9 deletions
diff --git a/compiler/rustc_index/Cargo.toml b/compiler/rustc_index/Cargo.toml
index d8ea5aa80..e1cda5a9e 100644
--- a/compiler/rustc_index/Cargo.toml
+++ b/compiler/rustc_index/Cargo.toml
@@ -7,6 +7,10 @@ edition = "2021"
[dependencies]
arrayvec = { version = "0.7", default-features = false }
-rustc_serialize = { path = "../rustc_serialize" }
-rustc_macros = { path = "../rustc_macros" }
+rustc_serialize = { path = "../rustc_serialize", optional = true }
+rustc_macros = { path = "../rustc_macros", optional = true }
smallvec = "1.8.1"
+
+[features]
+default = ["nightly"]
+nightly = ["rustc_serialize", "rustc_macros"]
diff --git a/compiler/rustc_index/src/lib.rs b/compiler/rustc_index/src/lib.rs
index 23a4c1f06..db2c79152 100644
--- a/compiler/rustc_index/src/lib.rs
+++ b/compiler/rustc_index/src/lib.rs
@@ -1,17 +1,25 @@
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]
-#![feature(allow_internal_unstable)]
-#![feature(extend_one)]
-#![feature(min_specialization)]
-#![feature(new_uninit)]
-#![feature(step_trait)]
-#![feature(stmt_expr_attributes)]
-#![feature(test)]
+#![cfg_attr(
+ feature = "nightly",
+ feature(
+ allow_internal_unstable,
+ extend_one,
+ min_specialization,
+ new_uninit,
+ step_trait,
+ stmt_expr_attributes,
+ test
+ )
+)]
+#[cfg(feature = "nightly")]
pub mod bit_set;
+#[cfg(feature = "nightly")]
pub mod interval;
pub mod vec;
+#[cfg(feature = "rustc_macros")]
pub use rustc_macros::newtype_index;
/// Type size assertion. The first argument is a type and the second argument is its expected size.
diff --git a/compiler/rustc_index/src/vec.rs b/compiler/rustc_index/src/vec.rs
index 4172ce3bb..39aa27a23 100644
--- a/compiler/rustc_index/src/vec.rs
+++ b/compiler/rustc_index/src/vec.rs
@@ -1,3 +1,4 @@
+#[cfg(feature = "rustc_serialize")]
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
use std::fmt;
@@ -17,10 +18,12 @@ pub trait Idx: Copy + 'static + Eq + PartialEq + Debug + Hash {
fn index(self) -> usize;
+ #[inline]
fn increment_by(&mut self, amount: usize) {
*self = self.plus(amount);
}
+ #[inline]
fn plus(self, amount: usize) -> Self {
Self::new(self.index() + amount)
}
@@ -59,12 +62,14 @@ pub struct IndexVec<I: Idx, T> {
// not the phantom data.
unsafe impl<I: Idx, T> Send for IndexVec<I, T> where T: Send {}
+#[cfg(feature = "rustc_serialize")]
impl<S: Encoder, I: Idx, T: Encodable<S>> Encodable<S> for IndexVec<I, T> {
fn encode(&self, s: &mut S) {
Encodable::encode(&self.raw, s);
}
}
+#[cfg(feature = "rustc_serialize")]
impl<D: Decoder, I: Idx, T: Decodable<D>> Decodable<D> for IndexVec<I, T> {
fn decode(d: &mut D) -> Self {
IndexVec { raw: Decodable::decode(d), _marker: PhantomData }
@@ -357,11 +362,13 @@ impl<I: Idx, T> Extend<T> for IndexVec<I, T> {
}
#[inline]
+ #[cfg(feature = "nightly")]
fn extend_one(&mut self, item: T) {
self.raw.push(item);
}
#[inline]
+ #[cfg(feature = "nightly")]
fn extend_reserve(&mut self, additional: usize) {
self.raw.reserve(additional);
}