Skip to content

Commit 125796b

Browse files
committed
Remove Span from hir::CrateItem.
1 parent e6d9d4b commit 125796b

File tree

8 files changed

+11
-10
lines changed

8 files changed

+11
-10
lines changed

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
612612
self.spans.push_owner(Idx::new(self.resolver.definitions().def_index_count() - 1));
613613

614614
hir::Crate {
615-
item: hir::CrateItem { module, span: c.span },
615+
item: hir::CrateItem { module },
616616
exported_macros: self.arena.alloc_from_iter(self.exported_macros),
617617
non_exported_macro_attrs: self.arena.alloc_from_iter(self.non_exported_macro_attrs),
618618
items: self.items,

compiler/rustc_hir/src/hir.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,6 @@ pub struct ModuleItems {
612612
#[derive(Encodable, Debug, HashStable_Generic)]
613613
pub struct CrateItem<'hir> {
614614
pub module: Mod<'hir>,
615-
pub span: Span,
616615
}
617616

618617
/// The top-level data structure that stores the entire contents of

compiler/rustc_lint/src/builtin.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,8 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
567567
}
568568

569569
fn check_crate(&mut self, cx: &LateContext<'_>, krate: &hir::Crate<'_>) {
570-
self.check_missing_docs_attrs(cx, hir::CRATE_HIR_ID, krate.item.span, "the", "crate");
570+
let span = cx.tcx.hir().span(hir::CRATE_HIR_ID);
571+
self.check_missing_docs_attrs(cx, hir::CRATE_HIR_ID, span, "the", "crate");
571572

572573
for macro_def in krate.exported_macros {
573574
let attrs = cx.tcx.hir().attrs(macro_def.hir_id());

compiler/rustc_passes/src/entry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ fn configure_main(
171171
}
172172

173173
fn no_main_err(tcx: TyCtxt<'_>, visitor: &EntryContext<'_, '_>) {
174-
let sp = tcx.hir().krate().item.span;
174+
let sp = tcx.hir().span(CRATE_HIR_ID);
175175
if *tcx.sess.parse_sess.reached_eof.borrow() {
176176
// There's an unclosed brace that made the parser reach `Eof`, we shouldn't complain about
177177
// the missing `fn main()` then as it might have been hidden inside an unclosed block.

compiler/rustc_passes/src/stability.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ fn new_index(tcx: TyCtxt<'tcx>) -> Index<'tcx> {
693693

694694
annotator.annotate(
695695
hir::CRATE_HIR_ID,
696-
krate.item.span,
696+
tcx.hir().span(hir::CRATE_HIR_ID),
697697
AnnotationKind::Required,
698698
InheritDeprecation::Yes,
699699
InheritConstStability::No,
@@ -892,7 +892,7 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
892892
if tcx.stability().staged_api[&LOCAL_CRATE] {
893893
let krate = tcx.hir().krate();
894894
let mut missing = MissingStabilityAnnotations { tcx, access_levels };
895-
missing.check_missing_stability(hir::CRATE_HIR_ID, krate.item.span);
895+
missing.check_missing_stability(hir::CRATE_HIR_ID, tcx.hir().span(hir::CRATE_HIR_ID));
896896
intravisit::walk_crate(&mut missing, krate);
897897
krate.visit_all_item_likes(&mut missing.as_deep_visitor());
898898
}

src/librustdoc/doctest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ crate fn run(options: Options) -> Result<(), ErrorReported> {
140140
hir_collector.visit_testable(
141141
"".to_string(),
142142
CRATE_HIR_ID,
143-
krate.item.span,
143+
tcx.hir().span(CRATE_HIR_ID),
144144
|this| {
145145
intravisit::walk_crate(this, krate);
146146
},

src/librustdoc/visit_ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
7272

7373
crate fn visit(mut self, krate: &'tcx hir::Crate<'_>) -> Module<'tcx> {
7474
let mut top_level_module = self.visit_mod_contents(
75-
krate.item.span,
75+
self.cx.tcx.hir().span(hir::CRATE_HIR_ID),
7676
&Spanned { span: rustc_span::DUMMY_SP, node: hir::VisibilityKind::Public },
7777
hir::CRATE_HIR_ID,
7878
&krate.item.module,

src/tools/clippy/clippy_lints/src/missing_doc.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,10 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
126126
self.doc_hidden_stack.pop().expect("empty doc_hidden_stack");
127127
}
128128

129-
fn check_crate(&mut self, cx: &LateContext<'tcx>, krate: &'tcx hir::Crate<'_>) {
129+
fn check_crate(&mut self, cx: &LateContext<'tcx>, _: &'tcx hir::Crate<'_>) {
130130
let attrs = cx.tcx.hir().attrs(hir::CRATE_HIR_ID);
131-
self.check_missing_docs_attrs(cx, attrs, krate.item.span, "the", "crate");
131+
let span = cx.tcx.hir().span(hir::CRATE_HIR_ID);
132+
self.check_missing_docs_attrs(cx, attrs, span, "the", "crate");
132133
}
133134

134135
fn check_item(&mut self, cx: &LateContext<'tcx>, it: &'tcx hir::Item<'_>) {

0 commit comments

Comments
 (0)