Skip to content

Commit f43ef2d

Browse files
address review
1 parent 9e3e2ee commit f43ef2d

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

compiler/rustc_resolve/src/build_reduced_graph.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
6161
ident: Ident,
6262
ns: Namespace,
6363
res: Res,
64-
vis: Visibility<impl Into<DefId>>,
64+
vis: Visibility,
6565
span: Span,
6666
expn_id: LocalExpnId,
6767
) {
68+
assert!(parent.is_local());
69+
assert!(res.opt_def_id().is_none_or(|def_id| def_id.is_local()));
6870
let binding = self.arenas.new_res_binding(res, vis.to_def_id(), span, expn_id);
6971
self.define_binding_local(parent, ident, ns, binding)
7072
}
@@ -76,18 +78,18 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
7678
ident: Ident,
7779
ns: Namespace,
7880
res: Res,
79-
vis: Visibility<impl Into<DefId>>,
81+
vis: Visibility<DefId>,
8082
span: Span,
8183
expn_id: LocalExpnId,
8284
) {
83-
let binding = self.arenas.new_res_binding(res, vis.to_def_id(), span, expn_id);
85+
assert!(!parent.is_local());
86+
assert!(!res.opt_def_id().is_some_and(|def_id| def_id.is_local()), "res: {res:?} is local");
87+
let binding = self.arenas.new_res_binding(res, vis, span, expn_id);
8488
let key = self.new_disambiguated_key(ident, ns);
85-
self.check_reserved_macro_name(key.ident, binding.res());
8689
let resolution = &mut *self.resolution(parent, key).borrow_mut();
8790
if resolution.binding.is_some() {
8891
panic!("An external binding was already defined");
8992
}
90-
// FIXME: maybe some handling of glob-importers
9193
resolution.binding = Some(binding);
9294
}
9395

compiler/rustc_resolve/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,10 @@ impl<'ra> Module<'ra> {
691691
}
692692
}
693693

694+
fn is_local(self) -> bool {
695+
self.opt_def_id().is_none_or(|def_id| def_id.is_local())
696+
}
697+
694698
// `self` resolves to the first module ancestor that `is_normal`.
695699
fn is_normal(self) -> bool {
696700
matches!(self.kind, ModuleKind::Def(DefKind::Mod, _, _))

0 commit comments

Comments
 (0)