From 4547b622d8d29df964fa2914213088b148c498fc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:18:32 +0200 Subject: Merging upstream version 1.67.1+dfsg1. Signed-off-by: Daniel Baumann --- compiler/rustc_index/src/vec.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'compiler/rustc_index/src/vec.rs') 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 { // not the phantom data. unsafe impl Send for IndexVec where T: Send {} +#[cfg(feature = "rustc_serialize")] impl> Encodable for IndexVec { fn encode(&self, s: &mut S) { Encodable::encode(&self.raw, s); } } +#[cfg(feature = "rustc_serialize")] impl> Decodable for IndexVec { fn decode(d: &mut D) -> Self { IndexVec { raw: Decodable::decode(d), _marker: PhantomData } @@ -357,11 +362,13 @@ impl Extend for IndexVec { } #[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); } -- cgit v1.2.3