Skip to content

Commit 7ce099a

Browse files
address review
1 parent 37904a1 commit 7ce099a

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
@@ -60,10 +60,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
6060
ident: Ident,
6161
ns: Namespace,
6262
res: Res,
63-
vis: Visibility<impl Into<DefId>>,
63+
vis: Visibility,
6464
span: Span,
6565
expn_id: LocalExpnId,
6666
) {
67+
assert!(parent.is_local());
68+
assert!(res.opt_def_id().is_none_or(|def_id| def_id.is_local()));
6769
let binding = self.arenas.new_res_binding(res, vis.to_def_id(), span, expn_id);
6870
self.define_binding_local(parent, ident, ns, binding)
6971
}
@@ -75,18 +77,18 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
7577
ident: Ident,
7678
ns: Namespace,
7779
res: Res,
78-
vis: Visibility<impl Into<DefId>>,
80+
vis: Visibility<DefId>,
7981
span: Span,
8082
expn_id: LocalExpnId,
8183
) {
82-
let binding = self.arenas.new_res_binding(res, vis.to_def_id(), span, expn_id);
84+
assert!(!parent.is_local());
85+
assert!(!res.opt_def_id().is_some_and(|def_id| def_id.is_local()), "res: {res:?} is local");
86+
let binding = self.arenas.new_res_binding(res, vis, span, expn_id);
8387
let key = self.new_disambiguated_key(ident, ns);
84-
self.check_reserved_macro_name(key.ident, binding.res());
8588
let resolution = &mut *self.resolution(parent, key).borrow_mut();
8689
if resolution.binding.is_some() {
8790
panic!("An external binding was already defined");
8891
}
89-
// FIXME: maybe some handling of glob-importers
9092
resolution.binding = Some(binding);
9193
}
9294

compiler/rustc_resolve/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,10 @@ impl<'ra> Module<'ra> {
702702
}
703703
}
704704

705+
fn is_local(self) -> bool {
706+
self.opt_def_id().is_none_or(|def_id| def_id.is_local())
707+
}
708+
705709
// `self` resolves to the first module ancestor that `is_normal`.
706710
fn is_normal(self) -> bool {
707711
matches!(self.kind, ModuleKind::Def(DefKind::Mod, _, _))

0 commit comments

Comments
 (0)