@@ -59,7 +59,6 @@ struct TestCtxt<'a> {
59
59
testfns : Vec < Test > ,
60
60
reexport_test_harness_main : Option < InternedString > ,
61
61
is_test_crate : bool ,
62
- config : ast:: CrateConfig ,
63
62
64
63
// top-level re-export submodule, filled out after folding is finished
65
64
toplevel_reexport : Option < ast:: Ident > ,
@@ -68,14 +67,9 @@ struct TestCtxt<'a> {
68
67
// Traverse the crate, collecting all the test functions, eliding any
69
68
// existing main functions, and synthesizing a main test harness
70
69
pub fn modify_for_testing ( sess : & ParseSess ,
71
- cfg : & ast :: CrateConfig ,
70
+ should_test : bool ,
72
71
krate : ast:: Crate ,
73
72
span_diagnostic : & errors:: Handler ) -> ast:: Crate {
74
- // We generate the test harness when building in the 'test'
75
- // configuration, either with the '--test' or '--cfg test'
76
- // command line options.
77
- let should_test = attr:: contains_name ( & krate. config , "test" ) ;
78
-
79
73
// Check for #[reexport_test_harness_main = "some_name"] which
80
74
// creates a `use some_name = __test::main;`. This needs to be
81
75
// unconditional, so that the attribute is still marked as used in
@@ -85,7 +79,7 @@ pub fn modify_for_testing(sess: &ParseSess,
85
79
"reexport_test_harness_main" ) ;
86
80
87
81
if should_test {
88
- generate_test_harness ( sess, reexport_test_harness_main, krate, cfg , span_diagnostic)
82
+ generate_test_harness ( sess, reexport_test_harness_main, krate, span_diagnostic)
89
83
} else {
90
84
strip_test_functions ( krate)
91
85
}
@@ -271,7 +265,6 @@ fn mk_reexport_mod(cx: &mut TestCtxt, tests: Vec<ast::Ident>,
271
265
fn generate_test_harness ( sess : & ParseSess ,
272
266
reexport_test_harness_main : Option < InternedString > ,
273
267
krate : ast:: Crate ,
274
- cfg : & ast:: CrateConfig ,
275
268
sd : & errors:: Handler ) -> ast:: Crate {
276
269
// Remove the entry points
277
270
let mut cleaner = EntryPointCleaner { depth : 0 } ;
@@ -281,14 +274,13 @@ fn generate_test_harness(sess: &ParseSess,
281
274
let mut cx: TestCtxt = TestCtxt {
282
275
sess : sess,
283
276
span_diagnostic : sd,
284
- ext_cx : ExtCtxt :: new ( sess, cfg . clone ( ) ,
277
+ ext_cx : ExtCtxt :: new ( sess, vec ! [ ] ,
285
278
ExpansionConfig :: default ( "test" . to_string ( ) ) ,
286
279
& mut feature_gated_cfgs) ,
287
280
path : Vec :: new ( ) ,
288
281
testfns : Vec :: new ( ) ,
289
282
reexport_test_harness_main : reexport_test_harness_main,
290
283
is_test_crate : is_test_crate ( & krate) ,
291
- config : krate. config . clone ( ) ,
292
284
toplevel_reexport : None ,
293
285
} ;
294
286
cx. ext_cx . crate_root = Some ( "std" ) ;
0 commit comments