Skip to content

Commit 9bb0158

Browse files
committed
resolve: Inline with_mod_rib
1 parent c23698f commit 9bb0158

File tree

1 file changed

+18
-26
lines changed

1 file changed

+18
-26
lines changed

compiler/rustc_resolve/src/late.rs

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,19 +1527,6 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
15271527
ret
15281528
}
15291529

1530-
fn with_mod_rib<T>(&mut self, id: NodeId, f: impl FnOnce(&mut Self) -> T) -> T {
1531-
let module = self.r.expect_module(self.r.local_def_id(id).to_def_id());
1532-
// Move down in the graph.
1533-
let orig_module = replace(&mut self.parent_scope.module, module);
1534-
self.with_rib(ValueNS, RibKind::Module(module), |this| {
1535-
this.with_rib(TypeNS, RibKind::Module(module), |this| {
1536-
let ret = f(this);
1537-
this.parent_scope.module = orig_module;
1538-
ret
1539-
})
1540-
})
1541-
}
1542-
15431530
fn visit_generic_params(&mut self, params: &'ast [GenericParam], add_self_upper: bool) {
15441531
// For type parameter defaults, we have to ban access
15451532
// to following type parameters, as the GenericArgs can only
@@ -2677,20 +2664,25 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
26772664
}
26782665

26792666
ItemKind::Mod(..) => {
2680-
self.with_mod_rib(item.id, |this| {
2681-
if mod_inner_docs {
2682-
this.resolve_doc_links(&item.attrs, MaybeExported::Ok(item.id));
2683-
}
2684-
let old_macro_rules = this.parent_scope.macro_rules;
2685-
visit::walk_item(this, item);
2686-
// Maintain macro_rules scopes in the same way as during early resolution
2687-
// for diagnostics and doc links.
2688-
if item.attrs.iter().all(|attr| {
2689-
!attr.has_name(sym::macro_use) && !attr.has_name(sym::macro_escape)
2690-
}) {
2691-
this.parent_scope.macro_rules = old_macro_rules;
2692-
}
2667+
let module = self.r.expect_module(self.r.local_def_id(item.id).to_def_id());
2668+
let orig_module = replace(&mut self.parent_scope.module, module);
2669+
self.with_rib(ValueNS, RibKind::Module(module), |this| {
2670+
this.with_rib(TypeNS, RibKind::Module(module), |this| {
2671+
if mod_inner_docs {
2672+
this.resolve_doc_links(&item.attrs, MaybeExported::Ok(item.id));
2673+
}
2674+
let old_macro_rules = this.parent_scope.macro_rules;
2675+
visit::walk_item(this, item);
2676+
// Maintain macro_rules scopes in the same way as during early resolution
2677+
// for diagnostics and doc links.
2678+
if item.attrs.iter().all(|attr| {
2679+
!attr.has_name(sym::macro_use) && !attr.has_name(sym::macro_escape)
2680+
}) {
2681+
this.parent_scope.macro_rules = old_macro_rules;
2682+
}
2683+
})
26932684
});
2685+
self.parent_scope.module = orig_module;
26942686
}
26952687

26962688
ItemKind::Static(box ast::StaticItem {

0 commit comments

Comments
 (0)