Skip to content

Commit deec340

Browse files
committed
Remove span from hir::MacroDef.
1 parent 8197821 commit deec340

File tree

9 files changed

+13
-15
lines changed

9 files changed

+13
-15
lines changed

src/librustc_ast_lowering/item.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
213213
vis,
214214
attrs,
215215
hir_id,
216-
span: i.span,
217216
ast: MacroDef { body, macro_rules },
218217
});
219218
} else {

src/librustc_hir/hir.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,6 @@ pub struct MacroDef<'hir> {
725725
pub vis: Visibility<'hir>,
726726
pub attrs: &'hir [Attribute],
727727
pub hir_id: HirId,
728-
pub span: Span,
729728
pub ast: ast::MacroDef,
730729
}
731730

src/librustc_lint/builtin.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
412412
for macro_def in krate.exported_macros {
413413
let has_doc = macro_def.attrs.iter().any(|a| has_doc(a));
414414
if !has_doc {
415+
let span = cx.tcx.hir().span(macro_def.hir_id);
415416
cx.struct_span_lint(
416417
MISSING_DOCS,
417-
cx.tcx.sess.source_map().guess_head_span(macro_def.span),
418+
cx.tcx.sess.source_map().guess_head_span(span),
418419
|lint| lint.build("missing documentation for macro").emit(),
419420
);
420421
}

src/librustc_metadata/rmeta/encoder.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1304,9 +1304,10 @@ impl EncodeContext<'tcx> {
13041304
/// Serialize the text of exported macros
13051305
fn encode_info_for_macro_def(&mut self, macro_def: &hir::MacroDef<'_>) {
13061306
let def_id = self.tcx.hir().local_def_id(macro_def.hir_id).to_def_id();
1307+
let span = self.tcx.hir().span(macro_def.hir_id);
13071308
record!(self.tables.kind[def_id] <- EntryKind::MacroDef(self.lazy(macro_def.ast.clone())));
13081309
record!(self.tables.visibility[def_id] <- ty::Visibility::Public);
1309-
record!(self.tables.span[def_id] <- macro_def.span);
1310+
record!(self.tables.span[def_id] <- span);
13101311
record!(self.tables.attributes[def_id] <- macro_def.attrs);
13111312
self.encode_ident_span(def_id, macro_def.ident);
13121313
self.encode_stability(def_id);

src/librustc_middle/hir/map/collector.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -515,12 +515,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
515515

516516
fn visit_macro_def(&mut self, macro_def: &'hir MacroDef<'hir>) {
517517
self.with_dep_node_owner(macro_def.hir_id.owner, macro_def, |this, hash| {
518-
this.insert_with_hash(
519-
macro_def.span,
520-
macro_def.hir_id,
521-
Node::MacroDef(macro_def),
522-
hash,
523-
);
518+
this.insert_with_hash(DUMMY_SP, macro_def.hir_id, Node::MacroDef(macro_def), hash);
524519
});
525520
}
526521

src/librustc_passes/stability.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,8 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
329329
}
330330

331331
fn visit_macro_def(&mut self, md: &'tcx hir::MacroDef<'tcx>) {
332-
self.annotate(md.hir_id, &md.attrs, md.span, AnnotationKind::Required, |_| {});
332+
let span = self.tcx.hir().span(md.hir_id);
333+
self.annotate(md.hir_id, &md.attrs, span, AnnotationKind::Required, |_| {});
333334
}
334335
}
335336

@@ -403,7 +404,8 @@ impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> {
403404
}
404405

405406
fn visit_macro_def(&mut self, md: &'tcx hir::MacroDef<'tcx>) {
406-
self.check_missing_stability(md.hir_id, md.span);
407+
let span = self.tcx.hir().span(md.hir_id);
408+
self.check_missing_stability(md.hir_id, span);
407409
}
408410
}
409411

src/librustc_privacy/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,8 @@ fn def_id_visibility<'tcx>(
242242
Node::ForeignItem(foreign_item) => &foreign_item.vis,
243243
Node::MacroDef(macro_def) => {
244244
if attr::contains_name(&macro_def.attrs, sym::macro_export) {
245-
return (ty::Visibility::Public, macro_def.span, "public");
245+
let span = tcx.hir().span(macro_def.hir_id);
246+
return (ty::Visibility::Public, span, "public");
246247
} else {
247248
&macro_def.vis
248249
}

src/librustdoc/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ impl<'a, 'hir, 'tcx> intravisit::Visitor<'hir> for HirCollector<'a, 'hir, 'tcx>
10311031
macro_def.ident.to_string(),
10321032
&macro_def.attrs,
10331033
macro_def.hir_id,
1034-
macro_def.span,
1034+
self.map.span(macro_def.hir_id),
10351035
|_| (),
10361036
);
10371037
}

src/librustdoc/visit_ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
618618
def_id: self.cx.tcx.hir().local_def_id(def.hir_id).to_def_id(),
619619
attrs: &def.attrs,
620620
name: renamed.unwrap_or(def.ident.name),
621-
whence: def.span,
621+
whence: self.cx.tcx.hir().span(def.hir_id),
622622
matchers,
623623
imported_from: None,
624624
}

0 commit comments

Comments
 (0)