Skip to content

Commit db26d01

Browse files
committed
resolve: DeclKind::Import::binding -> DeclKind::Import::source_decl
1 parent a0ea3b0 commit db26d01

4 files changed

Lines changed: 30 additions & 30 deletions

File tree

compiler/rustc_resolve/src/diagnostics.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,8 +1357,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
13571357
}
13581358

13591359
// #90113: Do not count an inaccessible reexported item as a candidate.
1360-
if let DeclKind::Import { binding, .. } = name_binding.kind
1361-
&& this.is_accessible_from(binding.vis, parent_scope.module)
1360+
if let DeclKind::Import { source_decl, .. } = name_binding.kind
1361+
&& this.is_accessible_from(source_decl.vis, parent_scope.module)
13621362
&& !this.is_accessible_from(name_binding.vis, parent_scope.module)
13631363
{
13641364
return;
@@ -2210,15 +2210,15 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
22102210
let name = next_ident;
22112211
next_binding = match binding.kind {
22122212
_ if res == Res::Err => None,
2213-
DeclKind::Import { binding, import, .. } => match import.kind {
2214-
_ if binding.span.is_dummy() => None,
2213+
DeclKind::Import { source_decl, import, .. } => match import.kind {
2214+
_ if source_decl.span.is_dummy() => None,
22152215
ImportKind::Single { source, .. } => {
22162216
next_ident = source;
2217-
Some(binding)
2217+
Some(source_decl)
22182218
}
22192219
ImportKind::Glob { .. }
22202220
| ImportKind::MacroUse { .. }
2221-
| ImportKind::MacroExport => Some(binding),
2221+
| ImportKind::MacroExport => Some(source_decl),
22222222
ImportKind::ExternCrate { .. } => None,
22232223
},
22242224
_ => None,

compiler/rustc_resolve/src/effective_visibilities.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl<'a, 'ra, 'tcx> EffectiveVisibilitiesVisitor<'a, 'ra, 'tcx> {
128128
let is_ambiguity = |decl: Decl<'ra>, warn: bool| decl.ambiguity.is_some() && !warn;
129129
let mut parent_id = ParentId::Def(module_id);
130130
let mut warn_ambiguity = decl.warn_ambiguity;
131-
while let DeclKind::Import { binding: nested_binding, .. } = decl.kind {
131+
while let DeclKind::Import { source_decl, .. } = decl.kind {
132132
self.update_import(decl, parent_id);
133133

134134
if is_ambiguity(decl, warn_ambiguity) {
@@ -139,8 +139,8 @@ impl<'a, 'ra, 'tcx> EffectiveVisibilitiesVisitor<'a, 'ra, 'tcx> {
139139
}
140140

141141
parent_id = ParentId::Import(decl);
142-
decl = nested_binding;
143-
warn_ambiguity |= nested_binding.warn_ambiguity;
142+
decl = source_decl;
143+
warn_ambiguity |= source_decl.warn_ambiguity;
144144
}
145145
if !is_ambiguity(decl, warn_ambiguity)
146146
&& let Some(def_id) = decl.res().opt_def_id().and_then(|id| id.as_local())

compiler/rustc_resolve/src/imports.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
316316
}
317317

318318
self.arenas.alloc_decl(DeclData {
319-
kind: DeclKind::Import { binding: decl, import },
319+
kind: DeclKind::Import { source_decl: decl, import },
320320
ambiguity: None,
321321
warn_ambiguity: false,
322322
span: import.span,
@@ -1199,10 +1199,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
11991199
let resolution = resolution.borrow();
12001200
if let Some(name_binding) = resolution.best_decl() {
12011201
match name_binding.kind {
1202-
DeclKind::Import { binding, .. } => {
1203-
match binding.kind {
1204-
// Never suggest the name that has binding error
1205-
// i.e., the name that cannot be previously resolved
1202+
DeclKind::Import { source_decl, .. } => {
1203+
match source_decl.kind {
1204+
// Never suggest names that previously could not
1205+
// be resolved.
12061206
DeclKind::Def(Res::Err) => None,
12071207
_ => Some(i.name),
12081208
}

compiler/rustc_resolve/src/lib.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ enum DeclKind<'ra> {
838838
/// can be provided by source code or built into the language.
839839
Def(Res),
840840
/// The name declaration is a link to another name declaration.
841-
Import { binding: Decl<'ra>, import: Import<'ra> },
841+
Import { source_decl: Decl<'ra>, import: Import<'ra> },
842842
}
843843

844844
impl<'ra> DeclKind<'ra> {
@@ -926,13 +926,13 @@ impl<'ra> DeclData<'ra> {
926926
fn res(&self) -> Res {
927927
match self.kind {
928928
DeclKind::Def(res) => res,
929-
DeclKind::Import { binding, .. } => binding.res(),
929+
DeclKind::Import { source_decl, .. } => source_decl.res(),
930930
}
931931
}
932932

933933
fn import_source(&self) -> Decl<'ra> {
934934
match self.kind {
935-
DeclKind::Import { binding, .. } => binding,
935+
DeclKind::Import { source_decl, .. } => source_decl,
936936
_ => unreachable!(),
937937
}
938938
}
@@ -941,7 +941,7 @@ impl<'ra> DeclData<'ra> {
941941
match self.ambiguity {
942942
Some(ambig_binding) => Some((self, ambig_binding)),
943943
None => match self.kind {
944-
DeclKind::Import { binding, .. } => binding.descent_to_ambiguity(),
944+
DeclKind::Import { source_decl, .. } => source_decl.descent_to_ambiguity(),
945945
_ => None,
946946
},
947947
}
@@ -950,22 +950,22 @@ impl<'ra> DeclData<'ra> {
950950
fn is_ambiguity_recursive(&self) -> bool {
951951
self.ambiguity.is_some()
952952
|| match self.kind {
953-
DeclKind::Import { binding, .. } => binding.is_ambiguity_recursive(),
953+
DeclKind::Import { source_decl, .. } => source_decl.is_ambiguity_recursive(),
954954
_ => false,
955955
}
956956
}
957957

958958
fn warn_ambiguity_recursive(&self) -> bool {
959959
self.warn_ambiguity
960960
|| match self.kind {
961-
DeclKind::Import { binding, .. } => binding.warn_ambiguity_recursive(),
961+
DeclKind::Import { source_decl, .. } => source_decl.warn_ambiguity_recursive(),
962962
_ => false,
963963
}
964964
}
965965

966966
fn is_possibly_imported_variant(&self) -> bool {
967967
match self.kind {
968-
DeclKind::Import { binding, .. } => binding.is_possibly_imported_variant(),
968+
DeclKind::Import { source_decl, .. } => source_decl.is_possibly_imported_variant(),
969969
DeclKind::Def(Res::Def(DefKind::Variant | DefKind::Ctor(CtorOf::Variant, ..), _)) => {
970970
true
971971
}
@@ -1012,9 +1012,9 @@ impl<'ra> DeclData<'ra> {
10121012
fn reexport_chain(self: Decl<'ra>, r: &Resolver<'_, '_>) -> SmallVec<[Reexport; 2]> {
10131013
let mut reexport_chain = SmallVec::new();
10141014
let mut next_binding = self;
1015-
while let DeclKind::Import { binding, import, .. } = next_binding.kind {
1015+
while let DeclKind::Import { source_decl, import, .. } = next_binding.kind {
10161016
reexport_chain.push(import.simplify(r));
1017-
next_binding = binding;
1017+
next_binding = source_decl;
10181018
}
10191019
reexport_chain
10201020
}
@@ -1043,9 +1043,9 @@ impl<'ra> DeclData<'ra> {
10431043
// FIXME: How can we integrate it with the `update_resolution`?
10441044
fn determined(&self) -> bool {
10451045
match &self.kind {
1046-
DeclKind::Import { binding, import, .. } if import.is_glob() => {
1046+
DeclKind::Import { source_decl, import, .. } if import.is_glob() => {
10471047
import.parent_scope.module.unexpanded_invocations.borrow().is_empty()
1048-
&& binding.determined()
1048+
&& source_decl.determined()
10491049
}
10501050
_ => true,
10511051
}
@@ -1985,14 +1985,14 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
19851985
trait_name: Ident,
19861986
) -> SmallVec<[LocalDefId; 1]> {
19871987
let mut import_ids = smallvec![];
1988-
while let DeclKind::Import { import, binding, .. } = kind {
1988+
while let DeclKind::Import { import, source_decl, .. } = kind {
19891989
if let Some(node_id) = import.id() {
19901990
let def_id = self.local_def_id(node_id);
19911991
self.maybe_unused_trait_imports.insert(def_id);
19921992
import_ids.push(def_id);
19931993
}
19941994
self.add_to_glob_map(*import, trait_name);
1995-
kind = &binding.kind;
1995+
kind = &source_decl.kind;
19961996
}
19971997
import_ids
19981998
}
@@ -2066,7 +2066,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
20662066
self.ambiguity_errors.push(ambiguity_error);
20672067
}
20682068
}
2069-
if let DeclKind::Import { import, binding } = used_decl.kind {
2069+
if let DeclKind::Import { import, source_decl } = used_decl.kind {
20702070
if let ImportKind::MacroUse { warn_private: true } = import.kind {
20712071
// Do not report the lint if the macro name resolves in stdlib prelude
20722072
// even without the problematic `macro_use` import.
@@ -2110,9 +2110,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
21102110
self.add_to_glob_map(import, ident);
21112111
self.record_use_inner(
21122112
ident,
2113-
binding,
2113+
source_decl,
21142114
Used::Other,
2115-
warn_ambiguity || binding.warn_ambiguity,
2115+
warn_ambiguity || source_decl.warn_ambiguity,
21162116
);
21172117
}
21182118
}

0 commit comments

Comments
 (0)