diff --git a/build.rs b/build.rs index a345b72..9f2a5c6 100644 --- a/build.rs +++ b/build.rs @@ -55,6 +55,10 @@ fn main() { println!("cargo:rustc-cfg=std_unicode"); } + if ver.commit_date.as_ref().map_or(false,|d| &**d>"2017-06-15") { + println!("cargo:rustc-cfg=collections_in_alloc"); + } + let mut dest_path=PathBuf::from(env::var_os("OUT_DIR").unwrap()); dest_path.push("io.rs"); let mut f=File::create(&dest_path).unwrap(); diff --git a/patches/cb56b2d1522e83c5bb0613abcf78b686e994df9e.patch b/patches/cb56b2d1522e83c5bb0613abcf78b686e994df9e.patch index 483d0be..9183e1f 100644 --- a/patches/cb56b2d1522e83c5bb0613abcf78b686e994df9e.patch +++ b/patches/cb56b2d1522e83c5bb0613abcf78b686e994df9e.patch @@ -969,7 +969,7 @@ diff --git a/mod.rs b/mod.rs index d403bf6..50bbc9d 100644 --- a/mod.rs +++ b/mod.rs -@@ -268,50 +268,33 @@ +@@ -268,50 +268,35 @@ //! [`Result`]: ../result/enum.Result.html //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap @@ -1012,6 +1012,8 @@ index d403bf6..50bbc9d 100644 -#[unstable(feature = "libstd_io_internals", issue = "42788")] -#[doc(no_inline, hidden)] -pub use self::stdio::{set_panic, set_print}; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; pub mod prelude; -mod buffered; diff --git a/src/lib.rs b/src/lib.rs index aed4244..daacb32 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,9 +6,16 @@ #![feature(question_mark,const_fn,collections,alloc,unicode,copy_from_slice,str_char,try_from,str_internals,slice_internals)] #![no_std] -#[cfg_attr(feature="collections",macro_use)] -#[cfg(feature="collections")] extern crate collections; -#[cfg(feature="alloc")] extern crate alloc; +#[cfg_attr(all(feature="collections", not(collections_in_alloc)), macro_use)] +#[cfg(all(feature="collections", not(collections_in_alloc)))] extern crate collections; + +#[cfg_attr(all(feature="collections", collections_in_alloc), macro_use)] +#[cfg(any(all(feature="collections", collections_in_alloc), feature="alloc"))] +extern crate alloc; + +#[cfg(all(feature="collections", collections_in_alloc))] +use alloc as collections; + #[cfg(rustc_unicode)] extern crate rustc_unicode; #[cfg(std_unicode)]