@@ -19,7 +19,6 @@ type test = {span: span, path: [ast::ident], ignore: bool, should_fail: bool};
19
19
type test_ctxt =
20
20
@{ sess : session:: session ,
21
21
crate : @ast:: crate ,
22
- next_node_id : node_id_gen ,
23
22
mutable path: [ ast:: ident ] ,
24
23
mutable testfns: [ test ] } ;
25
24
@@ -28,22 +27,9 @@ type test_ctxt =
28
27
fn modify_for_testing ( sess : session:: session ,
29
28
crate : @ast:: crate ) -> @ast:: crate {
30
29
31
- // FIXME: This hackasaurus assumes that 200000 is a safe number to start
32
- // generating node_ids at (which is totally not the case). pauls is going
33
- // to land a patch that puts parse_sess into session, which will give us
34
- // access to the real next node_id.
35
- let next_node_id = @mutable 200000 ;
36
- let next_node_id_fn =
37
- bind fn ( next_node_id: @mutable ast:: node_id) -> ast:: node_id {
38
- let this_node_id = * next_node_id;
39
- * next_node_id += 1 ;
40
- ret this_node_id;
41
- } ( next_node_id) ;
42
-
43
30
let cx: test_ctxt =
44
31
@{ sess: sess,
45
32
crate : crate ,
46
- next_node_id: next_node_id_fn,
47
33
mutable path: [ ] ,
48
34
mutable testfns: [ ] } ;
49
35
@@ -187,7 +173,7 @@ fn mk_test_module(cx: test_ctxt) -> @ast::item {
187
173
let item: ast:: item =
188
174
{ ident: "__test" ,
189
175
attrs: [ ] ,
190
- id: cx. next_node_id ( ) ,
176
+ id: cx. sess . next_node_id ( ) ,
191
177
node: item_,
192
178
span: dummy_sp ( ) } ;
193
179
@@ -216,7 +202,7 @@ fn mk_tests(cx: test_ctxt) -> @ast::item {
216
202
let test_descs = mk_test_desc_vec ( cx) ;
217
203
218
204
let body_: ast:: blk_ =
219
- default_block ( [ ] , option:: some ( test_descs) , cx. next_node_id ( ) ) ;
205
+ default_block ( [ ] , option:: some ( test_descs) , cx. sess . next_node_id ( ) ) ;
220
206
let body = nospan ( body_) ;
221
207
222
208
let fn_ = { decl: decl, proto: proto, body: body} ;
@@ -225,7 +211,7 @@ fn mk_tests(cx: test_ctxt) -> @ast::item {
225
211
let item: ast:: item =
226
212
{ ident: "tests" ,
227
213
attrs: [ ] ,
228
- id: cx. next_node_id ( ) ,
214
+ id: cx. sess . next_node_id ( ) ,
229
215
node: item_,
230
216
span: dummy_sp ( ) } ;
231
217
ret @item;
@@ -240,15 +226,15 @@ fn mk_test_desc_vec_ty(cx: test_ctxt) -> @ast::ty {
240
226
idents: [ "std" , "test" , "default_test_fn" ] ,
241
227
types: [ ]
242
228
} ) ,
243
- cx. next_node_id ( ) ) ) ;
229
+ cx. sess . next_node_id ( ) ) ) ;
244
230
245
231
let test_desc_ty_path =
246
232
@nospan ( { global: false,
247
233
idents: [ "std" , "test" , "test_desc" ] ,
248
234
types: [ @test_fn_ty] } ) ;
249
235
250
236
let test_desc_ty: ast:: ty =
251
- nospan ( ast:: ty_path ( test_desc_ty_path, cx. next_node_id ( ) ) ) ;
237
+ nospan ( ast:: ty_path ( test_desc_ty_path, cx. sess . next_node_id ( ) ) ) ;
252
238
253
239
let vec_mt: ast:: mt = { ty: @test_desc_ty, mut : ast:: imm} ;
254
240
@@ -263,7 +249,7 @@ fn mk_test_desc_vec(cx: test_ctxt) -> @ast::expr {
263
249
descs += [ mk_test_desc_rec ( cx, test_) ] ;
264
250
}
265
251
266
- ret @{ id : cx. next_node_id ( ) ,
252
+ ret @{ id : cx. sess . next_node_id ( ) ,
267
253
node : ast:: expr_vec ( descs, ast:: imm) ,
268
254
span : dummy_sp ( ) } ;
269
255
}
@@ -277,7 +263,7 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
277
263
let name_lit: ast:: lit =
278
264
nospan ( ast:: lit_str ( ast_util:: path_name_i ( path) ) ) ;
279
265
let name_expr: ast:: expr =
280
- { id: cx. next_node_id ( ) ,
266
+ { id: cx. sess . next_node_id ( ) ,
281
267
node: ast:: expr_lit ( @name_lit) ,
282
268
span: span} ;
283
269
@@ -287,7 +273,7 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
287
273
let fn_path = @nospan ( { global: false, idents: path, types: [ ] } ) ;
288
274
289
275
let fn_expr: ast:: expr =
290
- { id: cx. next_node_id ( ) ,
276
+ { id: cx. sess . next_node_id ( ) ,
291
277
node: ast:: expr_path ( fn_path) ,
292
278
span: span} ;
293
279
@@ -299,7 +285,7 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
299
285
let ignore_lit: ast:: lit = nospan ( ast:: lit_bool ( test. ignore ) ) ;
300
286
301
287
let ignore_expr: ast:: expr =
302
- { id: cx. next_node_id ( ) ,
288
+ { id: cx. sess . next_node_id ( ) ,
303
289
node: ast:: expr_lit ( @ignore_lit) ,
304
290
span: span} ;
305
291
@@ -309,7 +295,7 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
309
295
let fail_lit: ast:: lit = nospan ( ast:: lit_bool ( test. should_fail ) ) ;
310
296
311
297
let fail_expr: ast:: expr =
312
- { id: cx. next_node_id ( ) ,
298
+ { id: cx. sess . next_node_id ( ) ,
313
299
node: ast:: expr_lit ( @fail_lit) ,
314
300
span: span} ;
315
301
@@ -320,7 +306,7 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
320
306
ast:: expr_rec ( [ name_field, fn_field, ignore_field, fail_field] ,
321
307
option:: none) ;
322
308
let desc_rec: ast:: expr =
323
- { id: cx. next_node_id ( ) , node: desc_rec_, span: span} ;
309
+ { id: cx. sess . next_node_id ( ) , node: desc_rec_, span: span} ;
324
310
ret @desc_rec;
325
311
}
326
312
@@ -330,13 +316,13 @@ fn mk_test_wrapper(cx: test_ctxt,
330
316
fn_path_expr : ast:: expr ,
331
317
span : span ) -> @ast:: expr {
332
318
let call_expr: ast:: expr = {
333
- id: cx. next_node_id ( ) ,
319
+ id: cx. sess . next_node_id ( ) ,
334
320
node: ast:: expr_call ( @fn_path_expr, [ ] , false ) ,
335
321
span: span
336
322
} ;
337
323
338
324
let call_stmt: ast:: stmt = nospan (
339
- ast:: stmt_expr ( @call_expr, cx. next_node_id ( ) ) ) ;
325
+ ast:: stmt_expr ( @call_expr, cx. sess . next_node_id ( ) ) ) ;
340
326
341
327
let wrapper_decl: ast:: fn_decl = {
342
328
inputs: [ ] ,
@@ -351,7 +337,7 @@ fn mk_test_wrapper(cx: test_ctxt,
351
337
view_items: [ ] ,
352
338
stmts: [ @call_stmt] ,
353
339
expr: option:: none,
354
- id: cx. next_node_id ( ) ,
340
+ id: cx. sess . next_node_id ( ) ,
355
341
rules: ast:: default_blk
356
342
} ) ;
357
343
@@ -362,7 +348,7 @@ fn mk_test_wrapper(cx: test_ctxt,
362
348
} ;
363
349
364
350
let wrapper_expr: ast:: expr = {
365
- id: cx. next_node_id ( ) ,
351
+ id: cx. sess . next_node_id ( ) ,
366
352
node: ast:: expr_fn ( wrapper_fn) ,
367
353
span: span
368
354
} ;
@@ -379,7 +365,7 @@ fn mk_main(cx: test_ctxt) -> @ast::item {
379
365
{ mode: ast:: by_val,
380
366
ty: @args_ty,
381
367
ident: "args" ,
382
- id: cx. next_node_id ( ) } ;
368
+ id: cx. sess . next_node_id ( ) } ;
383
369
384
370
let ret_ty = nospan ( ast:: ty_nil) ;
385
371
@@ -396,7 +382,7 @@ fn mk_main(cx: test_ctxt) -> @ast::item {
396
382
397
383
let body_: ast:: blk_ =
398
384
default_block ( [ ] , option:: some ( test_main_call_expr) ,
399
- cx. next_node_id ( ) ) ;
385
+ cx. sess . next_node_id ( ) ) ;
400
386
let body = { node: body_, span: dummy_sp ( ) } ;
401
387
402
388
let fn_ = { decl: decl, proto: proto, body: body} ;
@@ -405,7 +391,7 @@ fn mk_main(cx: test_ctxt) -> @ast::item {
405
391
let item: ast:: item =
406
392
{ ident: "main" ,
407
393
attrs: [ ] ,
408
- id: cx. next_node_id ( ) ,
394
+ id: cx. sess . next_node_id ( ) ,
409
395
node: item_,
410
396
span: dummy_sp ( ) } ;
411
397
ret @item;
@@ -420,7 +406,7 @@ fn mk_test_main_call(cx: test_ctxt) -> @ast::expr {
420
406
let args_path_expr_: ast:: expr_ = ast:: expr_path ( args_path) ;
421
407
422
408
let args_path_expr: ast:: expr =
423
- { id: cx. next_node_id ( ) , node: args_path_expr_, span: dummy_sp ( ) } ;
409
+ { id: cx. sess . next_node_id ( ) , node: args_path_expr_, span: dummy_sp ( ) } ;
424
410
425
411
// Call __test::test to generate the vector of test_descs
426
412
let test_path =
@@ -429,12 +415,12 @@ fn mk_test_main_call(cx: test_ctxt) -> @ast::expr {
429
415
let test_path_expr_: ast:: expr_ = ast:: expr_path ( test_path) ;
430
416
431
417
let test_path_expr: ast:: expr =
432
- { id: cx. next_node_id ( ) , node: test_path_expr_, span: dummy_sp ( ) } ;
418
+ { id: cx. sess . next_node_id ( ) , node: test_path_expr_, span: dummy_sp ( ) } ;
433
419
434
420
let test_call_expr_ = ast:: expr_call ( @test_path_expr, [ ] , false ) ;
435
421
436
422
let test_call_expr: ast:: expr =
437
- { id: cx. next_node_id ( ) , node: test_call_expr_, span: dummy_sp ( ) } ;
423
+ { id: cx. sess . next_node_id ( ) , node: test_call_expr_, span: dummy_sp ( ) } ;
438
424
439
425
// Call std::test::test_main
440
426
let test_main_path =
@@ -445,14 +431,16 @@ fn mk_test_main_call(cx: test_ctxt) -> @ast::expr {
445
431
let test_main_path_expr_: ast:: expr_ = ast:: expr_path ( test_main_path) ;
446
432
447
433
let test_main_path_expr: ast:: expr =
448
- { id: cx. next_node_id ( ) , node: test_main_path_expr_, span: dummy_sp ( ) } ;
434
+ { id: cx. sess . next_node_id ( ) , node: test_main_path_expr_,
435
+ span: dummy_sp ( ) } ;
449
436
450
437
let test_main_call_expr_: ast:: expr_ =
451
438
ast:: expr_call ( @test_main_path_expr,
452
439
[ @args_path_expr, @test_call_expr] , false ) ;
453
440
454
441
let test_main_call_expr: ast:: expr =
455
- { id: cx. next_node_id ( ) , node: test_main_call_expr_, span: dummy_sp ( ) } ;
442
+ { id: cx. sess . next_node_id ( ) , node: test_main_call_expr_,
443
+ span: dummy_sp ( ) } ;
456
444
457
445
ret @test_main_call_expr;
458
446
}
0 commit comments