Skip to content

Commit 7af4ee8

Browse files
committed
resolve: Inline with_mod_rib
1 parent d6c7cf7 commit 7af4ee8

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
@@ -1528,19 +1528,6 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
15281528
ret
15291529
}
15301530

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

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

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

0 commit comments

Comments
 (0)