@@ -1412,6 +1412,59 @@ fn contains_novel_literal(item: &ast::MetaItem) -> bool {
14121412}
14131413
14141414impl < ' a > PostExpansionVisitor < ' a > {
1415+ fn check_modular_attr ( & mut self , attr : & ast:: Attribute ) {
1416+ if !self . context . parse_sess . combine_tests {
1417+ return ;
1418+ }
1419+ if let Some ( name) = attr. name ( ) {
1420+ let whitelist = & [
1421+ "feature" ,
1422+ "path" ,
1423+ "deny" ,
1424+ "allow" ,
1425+ "forbid" ,
1426+ "doc" ,
1427+ "repr" ,
1428+ "derive" ,
1429+ "automatically_derived" ,
1430+ "rustc_copy_clone_marker" ,
1431+ "structural_match" ,
1432+ "unsafe_destructor_blind_to_params" ,
1433+ "cfg" ,
1434+ "macro_use" ,
1435+ "inline" ,
1436+ "used" ,
1437+ "thread_local" ,
1438+ "macro_export" ,
1439+ "may_dangle" ,
1440+ "unwind" ,
1441+ "link" ,
1442+ "link_name" ,
1443+ "link_section" ,
1444+ "export_name" ,
1445+ "no_mangle" ,
1446+ "non_exhaustive" ,
1447+ "target_feature" ,
1448+ "prelude_import" ] ;
1449+ if !whitelist. iter ( ) . any ( |a| & * name. as_str ( ) == * a) &&
1450+ !attr. is_sugared_doc {
1451+ let mut err = self . context . parse_sess . span_diagnostic . struct_span_err (
1452+ attr. span ,
1453+ & format ! ( "combined test has unknown attribute `{}`" , name)
1454+ ) ;
1455+ err. help ( "add `// no-combine` at the top of the test file" ) ;
1456+ err. emit ( ) ;
1457+ }
1458+ } else {
1459+ let mut err = self . context . parse_sess . span_diagnostic . struct_span_err (
1460+ attr. span ,
1461+ & format ! ( "combined test has unnamed attribute" )
1462+ ) ;
1463+ err. help ( "add `// no-combine` at the top of the test file" ) ;
1464+ err. emit ( ) ;
1465+ }
1466+ }
1467+
14151468 fn visit_module_item ( & mut self , item : & ' a ast:: Item ) {
14161469 let is_module = match item. node {
14171470 ast:: ItemKind :: Mod ( ast:: Mod { inner, .. } ) => Some ( inner) ,
@@ -1488,6 +1541,8 @@ impl<'a> PostExpansionVisitor<'a> {
14881541
14891542impl < ' a > Visitor < ' a > for PostExpansionVisitor < ' a > {
14901543 fn visit_attribute ( & mut self , attr : & ast:: Attribute ) {
1544+ self . check_modular_attr ( attr) ;
1545+
14911546 if !attr. span . allows_unstable ( ) {
14921547 // check for gated attributes
14931548 self . context . check_attribute ( attr, false ) ;
0 commit comments