Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c609da5

Browse files
committed
Auto merge of #109772 - petrochenkov:slimchild, r=cjgillot
rustc_metadata: Remove `Span` from `ModChild` It can be decoded on demand from regular `def_span` tables. Partially mitigates perf regressions from #109500.
2 parents 4e46301 + ec8f688 commit c609da5

File tree

5 files changed

+12
-16
lines changed

5 files changed

+12
-16
lines changed

‎compiler/rustc_metadata/src/rmeta/decoder.rs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -998,9 +998,8 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
998998
let ident = self.item_ident(id, sess);
999999
let res = Res::Def(self.def_kind(id), self.local_def_id(id));
10001000
let vis = self.get_visibility(id);
1001-
let span = self.get_span(id, sess);
10021001

1003-
ModChild { ident, res, vis, span,reexport_chain: Default::default() }
1002+
ModChild { ident, res, vis, reexport_chain: Default::default() }
10041003
}
10051004

10061005
/// Iterates over all named children of the given module,

‎compiler/rustc_metadata/src/rmeta/encoder.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -831,16 +831,16 @@ fn should_encode_span(def_kind: DefKind) -> bool {
831831
| DefKind::AssocFn
832832
| DefKind::AssocConst
833833
| DefKind::Macro(_)
834+
| DefKind::ExternCrate
835+
| DefKind::Use
834836
| DefKind::AnonConst
835837
| DefKind::InlineConst
836838
| DefKind::OpaqueTy
837839
| DefKind::Field
838840
| DefKind::Impl { .. }
839841
| DefKind::Closure
840842
| DefKind::Generator => true,
841-
DefKind::ExternCrate
842-
| DefKind::Use
843-
| DefKind::ForeignMod
843+
DefKind::ForeignMod
844844
| DefKind::ImplTraitPlaceholder
845845
| DefKind::LifetimeParam
846846
| DefKind::GlobalAsm => false,

‎compiler/rustc_middle/src/metadata.rs‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use rustc_hir::def::Res;
44
use rustc_macros::HashStable;
55
use rustc_span::def_id::DefId;
66
use rustc_span::symbol::Ident;
7-
use rustc_span::Span;
87
use smallvec::SmallVec;
98

109
/// A simplified version of `ImportKind` from resolve.
@@ -41,8 +40,6 @@ pub struct ModChild {
4140
pub res: Res<!>,
4241
/// Visibility of the item.
4342
pub vis: ty::Visibility<DefId>,
44-
/// Span of the item.
45-
pub span: Span,
4643
/// Reexport chain linking this module child to its original reexported item.
4744
/// Empty if the module child is a proper item.
4845
pub reexport_chain: SmallVec<[Reexport; 2]>,

‎compiler/rustc_resolve/src/build_reduced_graph.rs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,13 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
931931
/// Builds the reduced graph for a single item in an external crate.
932932
fn build_reduced_graph_for_external_crate_res(&mut self, child: ModChild) {
933933
let parent = self.parent_scope.module;
934-
let ModChild { ident, res, vis, span, .. } = child;
934+
let ModChild { ident, res, vis, reexport_chain } = child;
935+
let span = self.r.def_span(
936+
reexport_chain
937+
.first()
938+
.and_then(|reexport| reexport.id())
939+
.unwrap_or_else(|| res.def_id()),
940+
);
935941
let res = res.expect_non_local();
936942
let expansion = self.parent_scope.expansion;
937943
// Record primary definitions.

‎compiler/rustc_resolve/src/imports.rs‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,13 +1276,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
12761276
next_binding = binding;
12771277
}
12781278

1279-
reexports.push(ModChild {
1280-
ident,
1281-
res,
1282-
vis: binding.vis,
1283-
span: binding.span,
1284-
reexport_chain,
1285-
});
1279+
reexports.push(ModChild { ident, res, vis: binding.vis, reexport_chain });
12861280
}
12871281
});
12881282

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /