make rustc_target usable outside of rustc
This commit is contained in:
parent
1dda298ad3
commit
09a384643e
11 changed files with 163 additions and 77 deletions
|
@ -1,17 +1,20 @@
|
|||
#![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))]
|
||||
#![cfg_attr(feature = "nightly", feature(extend_one))]
|
||||
#![cfg_attr(feature = "nightly", feature(min_specialization))]
|
||||
#![cfg_attr(feature = "nightly", feature(new_uninit))]
|
||||
#![cfg_attr(feature = "nightly", feature(step_trait))]
|
||||
#![cfg_attr(feature = "nightly", feature(stmt_expr_attributes))]
|
||||
#![cfg_attr(feature = "nightly", feature(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.
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#[cfg(feature = "rustc_serialize")]
|
||||
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
|
||||
|
||||
use std::fmt;
|
||||
|
@ -61,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 }
|
||||
|
@ -359,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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue