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 6
6
- rust : 1.15.0
7
7
- rust : stable
8
8
- rust : beta
9
+ script : cargo test
9
10
- rust : nightly
10
11
install : rustup target add wasm32-unknown-unknown
11
12
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() {
17
17
None => return ,
18
18
} ;
19
19
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" ) {
22
22
println ! ( "cargo:rustc-cfg=wrap_proc_macro" ) ;
23
23
24
24
if cfg ! ( procmacro2_semver_exempt) {
25
25
println ! ( "cargo:rustc-cfg=super_unstable" ) ;
26
26
}
27
- } else {
27
+ }
28
+
29
+ if minor == 29 {
30
+ println ! ( "cargo:rustc-cfg=slow_extend" ) ;
28
31
}
29
32
}
30
33
Original file line number Diff line number Diff line change @@ -210,11 +210,29 @@ impl Extend<TokenTree> for TokenStream {
210
210
fn extend < I : IntoIterator < Item = TokenTree > > ( & mut self , streams : I ) {
211
211
match self {
212
212
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 ( )
215
225
. 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
+ }
218
236
}
219
237
TokenStream :: Stable ( tts) => tts. extend ( streams) ,
220
238
}
@@ -225,7 +243,24 @@ impl Extend<TokenStream> for TokenStream {
225
243
fn extend < I : IntoIterator < Item = TokenStream > > ( & mut self , streams : I ) {
226
244
match self {
227
245
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
+ }
229
264
}
230
265
TokenStream :: Stable ( tts) => {
231
266
tts. extend ( streams. into_iter ( ) . map ( |stream| stream. unwrap_stable ( ) ) )
You can’t perform that action at this time.
0 commit comments