From df701a292ce552fddad2048cfcb6edaf90222d85 Mon Sep 17 00:00:00 2001 From: Simonas Kazlauskas Date: Fri, 24 Sep 2021 18:02:02 +0300 Subject: Querify `global_backend_features` At the very least this serves to deduplicate the diagnostics that are output about unknown target features provided via CLI. --- compiler/rustc_data_structures/src/small_c_str.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'compiler/rustc_data_structures/src') diff --git a/compiler/rustc_data_structures/src/small_c_str.rs b/compiler/rustc_data_structures/src/small_c_str.rs index 33e72914e19..cd902524562 100644 --- a/compiler/rustc_data_structures/src/small_c_str.rs +++ b/compiler/rustc_data_structures/src/small_c_str.rs @@ -66,3 +66,15 @@ impl Deref for SmallCStr { self.as_c_str() } } + +impl<'a> FromIterator<&'a str> for SmallCStr { + fn from_iter>(iter: T) -> Self { + let mut data = + iter.into_iter().flat_map(|s| s.as_bytes()).copied().collect::>(); + data.push(0); + if let Err(e) = ffi::CStr::from_bytes_with_nul(&data) { + panic!("The iterator {:?} cannot be converted into a CStr: {}", data, e); + } + Self { data } + } +} -- cgit 1.4.1-3-g733a5