From 7bec2c5ce684c488e2b7a2d47c7b737c275de162 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 5505476c..7ea14924 100644 --- a/src/map.rs +++ b/src/map.rs @@ -1340,7 +1340,7 @@ where } } -#[cfg(has_std)] +#[cfg(all(has_std, rustc_1_51))] impl From<[(K, V); N]> for IndexMap where K: Hash + Eq, @@ -1855,6 +1855,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 960fa24e..36a34478 100644 --- a/src/set.rs +++ b/src/set.rs @@ -838,7 +838,7 @@ where } } -#[cfg(has_std)] +#[cfg(all(has_std, rustc_1_51))] impl From<[T; N]> for IndexSet where T: Eq + Hash, @@ -1726,6 +1726,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();