@@ -211,6 +211,10 @@ pub(crate) enum RibKind<'ra> {
211211 /// All other constants aren't allowed to use generic params at all.
212212 ConstantItem ( ConstantHasGenerics , Option < ( Ident , ConstantItemKind ) > ) ,
213213
214+ Block {
215+ module : Option < Module < ' ra > > ,
216+ } ,
217+
214218 /// We passed through a module.
215219 Module ( Module < ' ra > ) ,
216220
@@ -243,6 +247,7 @@ impl RibKind<'_> {
243247 pub ( crate ) fn contains_params ( & self ) -> bool {
244248 match self {
245249 RibKind :: Normal
250+ | RibKind :: Block { .. }
246251 | RibKind :: FnOrCoroutine
247252 | RibKind :: ConstantItem ( ..)
248253 | RibKind :: Module ( _)
@@ -258,13 +263,16 @@ impl RibKind<'_> {
258263 /// This rib forbids referring to labels defined in upwards ribs.
259264 fn is_label_barrier ( self ) -> bool {
260265 match self {
261- RibKind :: Normal | RibKind :: MacroDefinition ( ..) => false ,
266+ RibKind :: Normal | RibKind :: MacroDefinition ( ..) | RibKind :: Block { module : None } => {
267+ false
268+ }
262269
263270 RibKind :: AssocItem
264271 | RibKind :: FnOrCoroutine
265272 | RibKind :: Item ( ..)
266273 | RibKind :: ConstantItem ( ..)
267274 | RibKind :: Module ( ..)
275+ | RibKind :: Block { module : Some ( _) }
268276 | RibKind :: ForwardGenericParamBan ( _)
269277 | RibKind :: ConstParamTy
270278 | RibKind :: InlineAsmSym => true ,
@@ -2822,7 +2830,10 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
28222830 for parent_rib in self . ribs [ ns] . iter ( ) . rev ( ) {
28232831 // Break at mod level, to account for nested items which are
28242832 // allowed to shadow generic param names.
2825- if matches ! ( parent_rib. kind, RibKind :: Module ( ..) ) {
2833+ if matches ! (
2834+ parent_rib. kind,
2835+ RibKind :: Module ( ..) | RibKind :: Block { module: Some ( _) }
2836+ ) {
28262837 break ;
28272838 }
28282839
@@ -4662,11 +4673,11 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
46624673 let mut num_macro_definition_ribs = 0 ;
46634674 if let Some ( anonymous_module) = anonymous_module {
46644675 debug ! ( "(resolving block) found anonymous module, moving down" ) ;
4665- self . ribs [ ValueNS ] . push ( Rib :: new ( RibKind :: Module ( anonymous_module) ) ) ;
4666- self . ribs [ TypeNS ] . push ( Rib :: new ( RibKind :: Module ( anonymous_module) ) ) ;
4676+ self . ribs [ ValueNS ] . push ( Rib :: new ( RibKind :: Block { module : Some ( anonymous_module) } ) ) ;
4677+ self . ribs [ TypeNS ] . push ( Rib :: new ( RibKind :: Block { module : Some ( anonymous_module) } ) ) ;
46674678 self . parent_scope . module = anonymous_module;
46684679 } else {
4669- self . ribs [ ValueNS ] . push ( Rib :: new ( RibKind :: Normal ) ) ;
4680+ self . ribs [ ValueNS ] . push ( Rib :: new ( RibKind :: Block { module : None } ) ) ;
46704681 }
46714682
46724683 // Descend into the block.
0 commit comments