Skip to content

Commit 27fedce

Browse files
committed
---
yaml --- r: 6587 b: refs/heads/master c: 03d4ec5 h: refs/heads/master i: 6585: d1030e2 6583: 007010e v: v3
1 parent b779e47 commit 27fedce

File tree

2 files changed

+26
-38
lines changed

2 files changed

+26
-38
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 89efb7d9810643eb1b25c04e63203b591915448f
2+
refs/heads/master: 03d4ec541578d381b56fa54094a6085181cbe2b6

trunk/src/comp/front/test.rs

Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ type test = {span: span, path: [ast::ident], ignore: bool, should_fail: bool};
1919
type test_ctxt =
2020
@{sess: session::session,
2121
crate: @ast::crate,
22-
next_node_id: node_id_gen,
2322
mutable path: [ast::ident],
2423
mutable testfns: [test]};
2524

@@ -28,22 +27,9 @@ type test_ctxt =
2827
fn modify_for_testing(sess: session::session,
2928
crate: @ast::crate) -> @ast::crate {
3029

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-
4330
let cx: test_ctxt =
4431
@{sess: sess,
4532
crate: crate,
46-
next_node_id: next_node_id_fn,
4733
mutable path: [],
4834
mutable testfns: []};
4935

@@ -187,7 +173,7 @@ fn mk_test_module(cx: test_ctxt) -> @ast::item {
187173
let item: ast::item =
188174
{ident: "__test",
189175
attrs: [],
190-
id: cx.next_node_id(),
176+
id: cx.sess.next_node_id(),
191177
node: item_,
192178
span: dummy_sp()};
193179

@@ -216,7 +202,7 @@ fn mk_tests(cx: test_ctxt) -> @ast::item {
216202
let test_descs = mk_test_desc_vec(cx);
217203

218204
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());
220206
let body = nospan(body_);
221207

222208
let fn_ = {decl: decl, proto: proto, body: body};
@@ -225,7 +211,7 @@ fn mk_tests(cx: test_ctxt) -> @ast::item {
225211
let item: ast::item =
226212
{ident: "tests",
227213
attrs: [],
228-
id: cx.next_node_id(),
214+
id: cx.sess.next_node_id(),
229215
node: item_,
230216
span: dummy_sp()};
231217
ret @item;
@@ -240,15 +226,15 @@ fn mk_test_desc_vec_ty(cx: test_ctxt) -> @ast::ty {
240226
idents: ["std", "test", "default_test_fn"],
241227
types: []
242228
}),
243-
cx.next_node_id()));
229+
cx.sess.next_node_id()));
244230

245231
let test_desc_ty_path =
246232
@nospan({global: false,
247233
idents: ["std", "test", "test_desc"],
248234
types: [@test_fn_ty]});
249235

250236
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()));
252238

253239
let vec_mt: ast::mt = {ty: @test_desc_ty, mut: ast::imm};
254240

@@ -263,7 +249,7 @@ fn mk_test_desc_vec(cx: test_ctxt) -> @ast::expr {
263249
descs += [mk_test_desc_rec(cx, test_)];
264250
}
265251

266-
ret @{id: cx.next_node_id(),
252+
ret @{id: cx.sess.next_node_id(),
267253
node: ast::expr_vec(descs, ast::imm),
268254
span: dummy_sp()};
269255
}
@@ -277,7 +263,7 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
277263
let name_lit: ast::lit =
278264
nospan(ast::lit_str(ast_util::path_name_i(path)));
279265
let name_expr: ast::expr =
280-
{id: cx.next_node_id(),
266+
{id: cx.sess.next_node_id(),
281267
node: ast::expr_lit(@name_lit),
282268
span: span};
283269

@@ -287,7 +273,7 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
287273
let fn_path = @nospan({global: false, idents: path, types: []});
288274

289275
let fn_expr: ast::expr =
290-
{id: cx.next_node_id(),
276+
{id: cx.sess.next_node_id(),
291277
node: ast::expr_path(fn_path),
292278
span: span};
293279

@@ -299,7 +285,7 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
299285
let ignore_lit: ast::lit = nospan(ast::lit_bool(test.ignore));
300286

301287
let ignore_expr: ast::expr =
302-
{id: cx.next_node_id(),
288+
{id: cx.sess.next_node_id(),
303289
node: ast::expr_lit(@ignore_lit),
304290
span: span};
305291

@@ -309,7 +295,7 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
309295
let fail_lit: ast::lit = nospan(ast::lit_bool(test.should_fail));
310296

311297
let fail_expr: ast::expr =
312-
{id: cx.next_node_id(),
298+
{id: cx.sess.next_node_id(),
313299
node: ast::expr_lit(@fail_lit),
314300
span: span};
315301

@@ -320,7 +306,7 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
320306
ast::expr_rec([name_field, fn_field, ignore_field, fail_field],
321307
option::none);
322308
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};
324310
ret @desc_rec;
325311
}
326312

@@ -330,13 +316,13 @@ fn mk_test_wrapper(cx: test_ctxt,
330316
fn_path_expr: ast::expr,
331317
span: span) -> @ast::expr {
332318
let call_expr: ast::expr = {
333-
id: cx.next_node_id(),
319+
id: cx.sess.next_node_id(),
334320
node: ast::expr_call(@fn_path_expr, [], false),
335321
span: span
336322
};
337323

338324
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()));
340326

341327
let wrapper_decl: ast::fn_decl = {
342328
inputs: [],
@@ -351,7 +337,7 @@ fn mk_test_wrapper(cx: test_ctxt,
351337
view_items: [],
352338
stmts: [@call_stmt],
353339
expr: option::none,
354-
id: cx.next_node_id(),
340+
id: cx.sess.next_node_id(),
355341
rules: ast::default_blk
356342
});
357343

@@ -362,7 +348,7 @@ fn mk_test_wrapper(cx: test_ctxt,
362348
};
363349

364350
let wrapper_expr: ast::expr = {
365-
id: cx.next_node_id(),
351+
id: cx.sess.next_node_id(),
366352
node: ast::expr_fn(wrapper_fn),
367353
span: span
368354
};
@@ -379,7 +365,7 @@ fn mk_main(cx: test_ctxt) -> @ast::item {
379365
{mode: ast::by_val,
380366
ty: @args_ty,
381367
ident: "args",
382-
id: cx.next_node_id()};
368+
id: cx.sess.next_node_id()};
383369

384370
let ret_ty = nospan(ast::ty_nil);
385371

@@ -396,7 +382,7 @@ fn mk_main(cx: test_ctxt) -> @ast::item {
396382

397383
let body_: ast::blk_ =
398384
default_block([], option::some(test_main_call_expr),
399-
cx.next_node_id());
385+
cx.sess.next_node_id());
400386
let body = {node: body_, span: dummy_sp()};
401387

402388
let fn_ = {decl: decl, proto: proto, body: body};
@@ -405,7 +391,7 @@ fn mk_main(cx: test_ctxt) -> @ast::item {
405391
let item: ast::item =
406392
{ident: "main",
407393
attrs: [],
408-
id: cx.next_node_id(),
394+
id: cx.sess.next_node_id(),
409395
node: item_,
410396
span: dummy_sp()};
411397
ret @item;
@@ -420,7 +406,7 @@ fn mk_test_main_call(cx: test_ctxt) -> @ast::expr {
420406
let args_path_expr_: ast::expr_ = ast::expr_path(args_path);
421407

422408
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()};
424410

425411
// Call __test::test to generate the vector of test_descs
426412
let test_path =
@@ -429,12 +415,12 @@ fn mk_test_main_call(cx: test_ctxt) -> @ast::expr {
429415
let test_path_expr_: ast::expr_ = ast::expr_path(test_path);
430416

431417
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()};
433419

434420
let test_call_expr_ = ast::expr_call(@test_path_expr, [], false);
435421

436422
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()};
438424

439425
// Call std::test::test_main
440426
let test_main_path =
@@ -445,14 +431,16 @@ fn mk_test_main_call(cx: test_ctxt) -> @ast::expr {
445431
let test_main_path_expr_: ast::expr_ = ast::expr_path(test_main_path);
446432

447433
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()};
449436

450437
let test_main_call_expr_: ast::expr_ =
451438
ast::expr_call(@test_main_path_expr,
452439
[@args_path_expr, @test_call_expr], false);
453440

454441
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()};
456444

457445
ret @test_main_call_expr;
458446
}

0 commit comments

Comments
 (0)