File tree Expand file tree Collapse file tree 3 files changed +47
-8
lines changed Expand file tree Collapse file tree 3 files changed +47
-8
lines changed Original file line number Diff line number Diff line change 66 - rust : 1.15.0
77 - rust : stable
88 - rust : beta
9+ script : cargo test
910 - rust : nightly
1011 install : rustup target add wasm32-unknown-unknown
1112 script : cargo test --target wasm32-unknown-unknown --no-run
Original file line number Diff line number Diff line change @@ -17,14 +17,17 @@ fn main() {
1717 None => return ,
1818 } ;
1919
20- // Rust 1.30 stabilized the necessary APIs in the `proc_macro` crate
21- if minor >= 30 || cfg ! ( feature = "nightly" ) {
20+ // Rust 1.29 stabilized the necessary APIs in the `proc_macro` crate
21+ if minor >= 29 || cfg ! ( feature = "nightly" ) {
2222 println ! ( "cargo:rustc-cfg=wrap_proc_macro" ) ;
2323
2424 if cfg ! ( procmacro2_semver_exempt) {
2525 println ! ( "cargo:rustc-cfg=super_unstable" ) ;
2626 }
27- } else {
27+ }
28+
29+ if minor == 29 {
30+ println ! ( "cargo:rustc-cfg=slow_extend" ) ;
2831 }
2932}
3033
Original file line number Diff line number Diff line change @@ -210,11 +210,29 @@ impl Extend<TokenTree> for TokenStream {
210210 fn extend < I : IntoIterator < Item = TokenTree > > ( & mut self , streams : I ) {
211211 match self {
212212 TokenStream :: Nightly ( tts) => {
213- tts. extend (
214- streams
213+ #[ cfg( not( slow_extend) ) ]
214+ {
215+ tts. extend (
216+ streams
217+ . into_iter ( )
218+ . map ( |t| TokenStream :: from ( t) . unwrap_nightly ( ) ) ,
219+ ) ;
220+ }
221+ #[ cfg( slow_extend) ]
222+ {
223+ * tts = tts
224+ . clone ( )
215225 . into_iter ( )
216- . map ( |t| TokenStream :: from ( t) . unwrap_nightly ( ) ) ,
217- ) ;
226+ . chain (
227+ streams
228+ . into_iter ( )
229+ . map ( TokenStream :: from)
230+ . flat_map ( |t| match t {
231+ TokenStream :: Nightly ( tts) => tts. into_iter ( ) ,
232+ _ => mismatch ( ) ,
233+ } ) ,
234+ ) . collect ( ) ;
235+ }
218236 }
219237 TokenStream :: Stable ( tts) => tts. extend ( streams) ,
220238 }
@@ -225,7 +243,24 @@ impl Extend<TokenStream> for TokenStream {
225243 fn extend < I : IntoIterator < Item = TokenStream > > ( & mut self , streams : I ) {
226244 match self {
227245 TokenStream :: Nightly ( tts) => {
228- tts. extend ( streams. into_iter ( ) . map ( |stream| stream. unwrap_nightly ( ) ) )
246+ #[ cfg( not( slow_extend) ) ]
247+ {
248+ tts. extend ( streams. into_iter ( ) . map ( |stream| stream. unwrap_nightly ( ) ) ) ;
249+ }
250+ #[ cfg( slow_extend) ]
251+ {
252+ * tts = tts
253+ . clone ( )
254+ . into_iter ( )
255+ . chain (
256+ streams
257+ . into_iter ( )
258+ . flat_map ( |t| match t {
259+ TokenStream :: Nightly ( tts) => tts. into_iter ( ) ,
260+ _ => mismatch ( ) ,
261+ } ) ,
262+ ) . collect ( ) ;
263+ }
229264 }
230265 TokenStream :: Stable ( tts) => {
231266 tts. extend ( streams. into_iter ( ) . map ( |stream| stream. unwrap_stable ( ) ) )
You can’t perform that action at this time.
0 commit comments