@@ -13,7 +13,7 @@ use rustc_ast::token;
13
13
use rustc_ast:: tokenstream:: TokenStream ;
14
14
use rustc_ast:: visit:: { self , AssocCtxt , Visitor } ;
15
15
use rustc_ast:: { self as ast, AttrItem , Block , LitKind , NodeId , PatKind , Path } ;
16
- use rustc_ast:: { ItemKind , MacArgs , MacCallStmt , MacStmtStyle , StmtKind } ;
16
+ use rustc_ast:: { ItemKind , MacArgs , MacCallStmt , MacStmtStyle , StmtKind , Unsafe } ;
17
17
use rustc_ast_pretty:: pprust;
18
18
use rustc_attr:: { self as attr, is_builtin_attr, HasAttrs } ;
19
19
use rustc_data_structures:: map_in_place:: MapInPlace ;
@@ -370,11 +370,21 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
370
370
None => {
371
371
// Resolution failed so we return an empty expansion
372
372
krate. attrs = vec ! [ ] ;
373
- krate. module = ast:: Mod { inner : orig_mod_span, items : vec ! [ ] , inline : true } ;
373
+ krate. module = ast:: Mod {
374
+ inner : orig_mod_span,
375
+ unsafety : Unsafe :: No ,
376
+ items : vec ! [ ] ,
377
+ inline : true ,
378
+ } ;
374
379
}
375
380
Some ( ast:: Item { span, kind, .. } ) => {
376
381
krate. attrs = vec ! [ ] ;
377
- krate. module = ast:: Mod { inner : orig_mod_span, items : vec ! [ ] , inline : true } ;
382
+ krate. module = ast:: Mod {
383
+ inner : orig_mod_span,
384
+ unsafety : Unsafe :: No ,
385
+ items : vec ! [ ] ,
386
+ inline : true ,
387
+ } ;
378
388
self . cx . span_err (
379
389
span,
380
390
& format ! (
@@ -1441,8 +1451,15 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
1441
1451
push_directory ( & self . cx . sess , ident, & item. attrs , dir)
1442
1452
} else {
1443
1453
// We have an outline `mod foo;` so we need to parse the file.
1444
- let ( new_mod, dir) =
1445
- parse_external_mod ( & self . cx . sess , ident, span, dir, & mut attrs, pushed) ;
1454
+ let ( new_mod, dir) = parse_external_mod (
1455
+ & self . cx . sess ,
1456
+ ident,
1457
+ span,
1458
+ old_mod. unsafety ,
1459
+ dir,
1460
+ & mut attrs,
1461
+ pushed,
1462
+ ) ;
1446
1463
1447
1464
let krate = ast:: Crate {
1448
1465
span : new_mod. inner ,
0 commit comments