Skip to content

rustc_metadata: Remove Span from ModChild #109772

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions compiler/rustc_metadata/src/rmeta/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -998,9 +998,8 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
let ident = self.item_ident(id, sess);
let res = Res::Def(self.def_kind(id), self.local_def_id(id));
let vis = self.get_visibility(id);
let span = self.get_span(id, sess);

ModChild { ident, res, vis, span, reexport_chain: Default::default() }
ModChild { ident, res, vis, reexport_chain: Default::default() }
}

/// Iterates over all named children of the given module,
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_metadata/src/rmeta/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -831,16 +831,16 @@ fn should_encode_span(def_kind: DefKind) -> bool {
| DefKind::AssocFn
| DefKind::AssocConst
| DefKind::Macro(_)
| DefKind::ExternCrate
| DefKind::Use
| DefKind::AnonConst
| DefKind::InlineConst
| DefKind::OpaqueTy
| DefKind::Field
| DefKind::Impl { .. }
| DefKind::Closure
| DefKind::Generator => true,
DefKind::ExternCrate
| DefKind::Use
| DefKind::ForeignMod
DefKind::ForeignMod
| DefKind::ImplTraitPlaceholder
| DefKind::LifetimeParam
| DefKind::GlobalAsm => false,
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_middle/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use rustc_hir::def::Res;
use rustc_macros::HashStable;
use rustc_span::def_id::DefId;
use rustc_span::symbol::Ident;
use rustc_span::Span;
use smallvec::SmallVec;

/// A simplified version of `ImportKind` from resolve.
Expand Down Expand Up @@ -41,8 +40,6 @@ pub struct ModChild {
pub res: Res<!>,
/// Visibility of the item.
pub vis: ty::Visibility<DefId>,
/// Span of the item.
pub span: Span,
/// Reexport chain linking this module child to its original reexported item.
/// Empty if the module child is a proper item.
pub reexport_chain: SmallVec<[Reexport; 2]>,
Expand Down
8 changes: 7 additions & 1 deletion compiler/rustc_resolve/src/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,13 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
/// Builds the reduced graph for a single item in an external crate.
fn build_reduced_graph_for_external_crate_res(&mut self, child: ModChild) {
let parent = self.parent_scope.module;
let ModChild { ident, res, vis, span, .. } = child;
let ModChild { ident, res, vis, reexport_chain } = child;
let span = self.r.def_span(
reexport_chain
.first()
.and_then(|reexport| reexport.id())
.unwrap_or_else(|| res.def_id()),
);
let res = res.expect_non_local();
let expansion = self.parent_scope.expansion;
// Record primary definitions.
Expand Down
8 changes: 1 addition & 7 deletions compiler/rustc_resolve/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1276,13 +1276,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
next_binding = binding;
}

reexports.push(ModChild {
ident,
res,
vis: binding.vis,
span: binding.span,
reexport_chain,
});
reexports.push(ModChild { ident, res, vis: binding.vis, reexport_chain });
}
});

Expand Down