From a95d7dc3303b605b791c9c98e283cdb829053636 Mon Sep 17 00:00:00 2001 From: Andy Freeland Date: Sun, 24 Oct 2021 13:15:04 -0700 Subject: [PATCH] Require rustc 1.51+ for `IndexMap::from(array)` and `IndexSet::from(array)` https://github.com/rust-lang/rust/issues/74878 and https://github.com/rust-lang/rust/issues/65798 were both stabilized in 1.51. --- build.rs | 1 + src/map.rs | 3 ++- src/set.rs | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/build.rs b/build.rs index 9f9fa054..7c5b6d5e 100644 --- a/build.rs +++ b/build.rs @@ -4,5 +4,6 @@ fn main() { Some(_) => autocfg::emit("has_std"), None => autocfg::new().emit_sysroot_crate("std"), } + autocfg::new().emit_rustc_version(1, 51); autocfg::rerun_path("build.rs"); } diff --git a/src/map.rs b/src/map.rs index 3bdb78ef..8949679b 100644 --- a/src/map.rs +++ b/src/map.rs @@ -1342,7 +1342,7 @@ where } } -#[cfg(has_std)] +#[cfg(all(has_std, rustc_1_51))] impl From<[(K, V); N]> for IndexMap where K: Hash + Eq, @@ -1857,6 +1857,7 @@ mod tests { } #[test] + #[cfg(all(has_std, rustc_1_51))] fn from_array() { let map = IndexMap::from([(1, 2), (3, 4)]); let mut expected = IndexMap::new(); diff --git a/src/set.rs b/src/set.rs index a00e92db..115685cc 100644 --- a/src/set.rs +++ b/src/set.rs @@ -840,7 +840,7 @@ where } } -#[cfg(has_std)] +#[cfg(all(has_std, rustc_1_51))] impl From<[T; N]> for IndexSet where T: Eq + Hash, @@ -1728,6 +1728,7 @@ mod tests { } #[test] + #[cfg(all(has_std, rustc_1_51))] fn from_array() { let set1 = IndexSet::from([1, 2, 3, 4]); let set2: IndexSet<_> = [1, 2, 3, 4].into();