@@ -161,7 +161,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
161161 let expn_id = self . cstore ( ) . expn_that_defined_untracked ( self . tcx , def_id) ;
162162 return Some ( self . new_extern_module (
163163 parent,
164- ModuleKind :: Def ( def_kind, def_id, Some ( self . tcx . item_name ( def_id) ) ) ,
164+ ModuleKind :: Def (
165+ def_kind,
166+ def_id,
167+ Some ( ( self . tcx . item_name ( def_id) , false ) ) ,
168+ ) ,
165169 expn_id,
166170 self . def_span ( def_id) ,
167171 // 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 ) ,
@@ -854,9 +858,18 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
854858 {
855859 self . r . mods_with_parse_errors . insert ( def_id) ;
856860 }
861+ let transparent = AttributeParser :: parse_limited (
862+ self . r . tcx . sess ,
863+ & item. attrs ,
864+ sym:: transparent,
865+ item. span ,
866+ item. id ,
867+ None ,
868+ )
869+ . is_some ( ) ;
857870 self . parent_scope . module = self . r . new_local_module (
858871 Some ( parent) ,
859- ModuleKind :: Def ( def_kind, def_id, Some ( ident. name ) ) ,
872+ ModuleKind :: Def ( def_kind, def_id, Some ( ( ident. name , transparent ) ) ) ,
860873 expansion. to_expn_id ( ) ,
861874 item. span ,
862875 parent. no_implicit_prelude
@@ -889,7 +902,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
889902
890903 self . parent_scope . module = self . r . new_local_module (
891904 Some ( parent) ,
892- ModuleKind :: Def ( def_kind, def_id, Some ( ident. name ) ) ,
905+ ModuleKind :: Def ( def_kind, def_id, Some ( ( ident. name , false ) ) ) ,
893906 expansion. to_expn_id ( ) ,
894907 item. span ,
895908 parent. no_implicit_prelude ,
0 commit comments