@@ -450,14 +450,12 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
450450 let ( fragment_with_placeholders, invocations) = {
451451 let mut collector = InvocationCollector {
452452 cfg : StripUnconfigured {
453- should_test : self . cx . ecfg . should_test ,
454453 sess : self . cx . parse_sess ,
455454 features : self . cx . ecfg . features ,
456455 } ,
457456 cx : self . cx ,
458457 invocations : Vec :: new ( ) ,
459458 monotonic : self . monotonic ,
460- tests_nameable : true ,
461459 } ;
462460 ( fragment. fold_with ( & mut collector) , collector. invocations )
463461 } ;
@@ -475,7 +473,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
475473
476474 fn fully_configure ( & mut self , item : Annotatable ) -> Annotatable {
477475 let mut cfg = StripUnconfigured {
478- should_test : self . cx . ecfg . should_test ,
479476 sess : self . cx . parse_sess ,
480477 features : self . cx . ecfg . features ,
481478 } ;
@@ -1047,11 +1044,6 @@ struct InvocationCollector<'a, 'b: 'a> {
10471044 cfg : StripUnconfigured < ' a > ,
10481045 invocations : Vec < Invocation > ,
10491046 monotonic : bool ,
1050-
1051- /// Test functions need to be nameable. Tests inside functions or in other
1052- /// unnameable locations need to be ignored. `tests_nameable` tracks whether
1053- /// any test functions found in the current context would be nameable.
1054- tests_nameable : bool ,
10551047}
10561048
10571049impl < ' a , ' b > InvocationCollector < ' a , ' b > {
@@ -1069,20 +1061,6 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
10691061 placeholder ( fragment_kind, NodeId :: placeholder_from_mark ( mark) )
10701062 }
10711063
1072- /// Folds the item allowing tests to be expanded because they are still nameable.
1073- /// This should probably only be called with module items
1074- fn fold_nameable ( & mut self , item : P < ast:: Item > ) -> OneVector < P < ast:: Item > > {
1075- fold:: noop_fold_item ( item, self )
1076- }
1077-
1078- /// Folds the item but doesn't allow tests to occur within it
1079- fn fold_unnameable ( & mut self , item : P < ast:: Item > ) -> OneVector < P < ast:: Item > > {
1080- let was_nameable = mem:: replace ( & mut self . tests_nameable , false ) ;
1081- let items = fold:: noop_fold_item ( item, self ) ;
1082- self . tests_nameable = was_nameable;
1083- items
1084- }
1085-
10861064 fn collect_bang ( & mut self , mac : ast:: Mac , span : Span , kind : AstFragmentKind ) -> AstFragment {
10871065 self . collect ( kind, InvocationKind :: Bang { mac : mac, ident : None , span : span } )
10881066 }
@@ -1297,7 +1275,7 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> {
12971275 fn fold_item ( & mut self , item : P < ast:: Item > ) -> OneVector < P < ast:: Item > > {
12981276 let item = configure ! ( self , item) ;
12991277
1300- let ( attr, traits, mut item) = self . classify_item ( item) ;
1278+ let ( attr, traits, item) = self . classify_item ( item) ;
13011279 if attr. is_some ( ) || !traits. is_empty ( ) {
13021280 let item = Annotatable :: Item ( item) ;
13031281 return self . collect_attr ( attr, traits, item, AstFragmentKind :: Items ) . make_items ( ) ;
@@ -1319,7 +1297,7 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> {
13191297 }
13201298 ast:: ItemKind :: Mod ( ast:: Mod { inner, .. } ) => {
13211299 if item. ident == keywords:: Invalid . ident ( ) {
1322- return self . fold_nameable ( item) ;
1300+ return noop_fold_item ( item, self ) ;
13231301 }
13241302
13251303 let orig_directory_ownership = self . cx . current_expansion . directory_ownership ;
@@ -1359,32 +1337,13 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> {
13591337
13601338 let orig_module =
13611339 mem:: replace ( & mut self . cx . current_expansion . module , Rc :: new ( module) ) ;
1362- let result = self . fold_nameable ( item) ;
1340+ let result = noop_fold_item ( item, self ) ;
13631341 self . cx . current_expansion . module = orig_module;
13641342 self . cx . current_expansion . directory_ownership = orig_directory_ownership;
13651343 result
13661344 }
13671345
1368- // Ensure that test items can be exported by the harness generator.
1369- // #[test] fn foo() {}
1370- // becomes:
1371- // #[test] pub fn foo_gensym(){}
1372- ast:: ItemKind :: Const ( ..)
1373- | ast:: ItemKind :: Static ( ..)
1374- | ast:: ItemKind :: Fn ( ..) if self . cx . ecfg . should_test => {
1375- if self . tests_nameable && attr:: contains_name ( & item. attrs , "test_case" ) {
1376- // Publicize the item under gensymed name to avoid pollution
1377- // This means #[test_case] items can't be referenced by user code
1378- item = item. map ( |mut item| {
1379- item. vis = respan ( item. vis . span , ast:: VisibilityKind :: Public ) ;
1380- item. ident = item. ident . gensym ( ) ;
1381- item
1382- } ) ;
1383- }
1384-
1385- self . fold_unnameable ( item)
1386- }
1387- _ => self . fold_unnameable ( item) ,
1346+ _ => noop_fold_item ( item, self ) ,
13881347 }
13891348 }
13901349
@@ -1609,6 +1568,7 @@ impl<'feat> ExpansionConfig<'feat> {
16091568 feature_tests ! {
16101569 fn enable_quotes = quote,
16111570 fn enable_asm = asm,
1571+ fn enable_custom_test_frameworks = custom_test_frameworks,
16121572 fn enable_global_asm = global_asm,
16131573 fn enable_log_syntax = log_syntax,
16141574 fn enable_concat_idents = concat_idents,
0 commit comments