@@ -164,7 +164,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
164164 let expn_id = self . cstore ( ) . expn_that_defined_untracked ( self . tcx , def_id) ;
165165 return Some ( self . new_extern_module (
166166 parent,
167- ModuleKind :: Def ( def_kind, def_id, Some ( self . tcx . item_name ( def_id) ) ) ,
167+ ModuleKind :: Def (
168+ def_kind,
169+ def_id,
170+ Some ( ( self . tcx . item_name ( def_id) , false ) ) ,
171+ ) ,
168172 expn_id,
169173 self . def_span ( def_id) ,
170174 // FIXME: Account for `#[no_implicit_prelude]` attributes.
@@ -665,14 +669,14 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
665669 // Disallow `use $crate;`
666670 if source. ident . name == kw:: DollarCrate && module_path. is_empty ( ) {
667671 let crate_root = self . r . resolve_crate_root ( source. ident ) ;
668- let crate_name = match crate_root. kind {
669- ModuleKind :: Def ( .., name ) => name ,
672+ let crate_name_and_transparent = match crate_root. kind {
673+ ModuleKind :: Def ( .., name_and_transparent ) => name_and_transparent ,
670674 ModuleKind :: Block => unreachable ! ( ) ,
671675 } ;
672676 // HACK(eddyb) unclear how good this is, but keeping `$crate`
673677 // in `source` breaks `tests/ui/imports/import-crate-var.rs`,
674678 // while the current crate doesn't have a valid `crate_name`.
675- if let Some ( crate_name) = crate_name {
679+ if let Some ( ( crate_name, _transparent ) ) = crate_name_and_transparent {
676680 // `crate_name` should not be interpreted as relative.
677681 module_path. push ( Segment :: from_ident_and_id (
678682 Ident :: new ( kw:: PathRoot , source. ident . span ) ,
@@ -853,9 +857,18 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
853857 {
854858 self . r . mods_with_parse_errors . insert ( def_id) ;
855859 }
860+ let transparent = AttributeParser :: parse_limited (
861+ self . r . tcx . sess ,
862+ & item. attrs ,
863+ sym:: transparent,
864+ item. span ,
865+ item. id ,
866+ None ,
867+ )
868+ . is_some ( ) ;
856869 self . parent_scope . module = self . r . new_local_module (
857870 Some ( parent) ,
858- ModuleKind :: Def ( def_kind, def_id, Some ( ident. name ) ) ,
871+ ModuleKind :: Def ( def_kind, def_id, Some ( ( ident. name , transparent ) ) ) ,
859872 expansion. to_expn_id ( ) ,
860873 item. span ,
861874 parent. no_implicit_prelude
@@ -888,7 +901,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
888901
889902 self . parent_scope . module = self . r . new_local_module (
890903 Some ( parent) ,
891- ModuleKind :: Def ( def_kind, def_id, Some ( ident. name ) ) ,
904+ ModuleKind :: Def ( def_kind, def_id, Some ( ( ident. name , false ) ) ) ,
892905 expansion. to_expn_id ( ) ,
893906 item. span ,
894907 parent. no_implicit_prelude ,
0 commit comments