From 18c09dfbba230cb4b5072ba2b28d56043cea3e9b Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 2 Apr 2021 00:20:35 -0400 Subject: [PATCH 1/3] Add test of big array repetition --- tests/test.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test.rs b/tests/test.rs index d5a3490..b42e591 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -78,6 +78,18 @@ fn test_iter() { assert_eq!("X , X , X , X", quote!(#(#primes),*).to_string()); } +#[test] +fn test_array() { + let array: [u8; 40] = [0; 40]; + let _ = quote!(#(#array #array)*); + + let ref_array: &[u8; 40] = &[0; 40]; + let _ = quote!(#(#ref_array #ref_array)*); + + let ref_slice: &[u8] = &[0; 40]; + let _ = quote!(#(#ref_slice #ref_slice)*); +} + #[test] fn test_advanced() { let generics = quote!( <'a, T> ); From 3dfd33a2a7b54a43c2e85ff5889a0b130b85fd05 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 2 Apr 2021 00:23:08 -0400 Subject: [PATCH 2/3] Test arrays containing non-Copy element too --- tests/test.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test.rs b/tests/test.rs index b42e591..fa12a89 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -88,6 +88,15 @@ fn test_array() { let ref_slice: &[u8] = &[0; 40]; let _ = quote!(#(#ref_slice #ref_slice)*); + + let array: [X; 2] = [X, X]; // !Copy + let _ = quote!(#(#array #array)*); + + let ref_array: &[X; 2] = &[X, X]; + let _ = quote!(#(#ref_array #ref_array)*); + + let ref_slice: &[X] = &[X, X]; + let _ = quote!(#(#ref_slice #ref_slice)*); } #[test] From 58bc466f0d0ae2ede9575c46bfe552bcefdedfdc Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 2 Apr 2021 00:23:27 -0400 Subject: [PATCH 3/3] Delete fixed sized array repetition impls --- src/runtime.rs | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/runtime.rs b/src/runtime.rs index 8144855..92e00f7 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -123,25 +123,6 @@ pub mod ext { } } - macro_rules! array_rep_slice { - ($($l:tt)*) => { - $( - impl<'q, T: 'q> RepAsIteratorExt<'q> for [T; $l] { - type Iter = slice::Iter<'q, T>; - - fn quote_into_iter(&'q self) -> (Self::Iter, HasIter) { - (self.iter(), HasIter) - } - } - )* - }; - } - - array_rep_slice!( - 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 - 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 - ); - impl<'q, T: RepAsIteratorExt<'q>> RepAsIteratorExt<'q> for RepInterp { type Iter = T::Iter;