Skip to content

Commit 11e2966

Browse files
committed
Keep a parent LocalDefId in SpanData.
1 parent 261e34d commit 11e2966

File tree

8 files changed

+10
-7
lines changed

8 files changed

+10
-7
lines changed

clippy_lints/src/attrs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,8 +527,8 @@ fn check_empty_line_after_outer_attr(cx: &EarlyContext<'_>, item: &rustc_ast::It
527527
return;
528528
}
529529

530-
let begin_of_attr_to_item = Span::new(attr.span.lo(), item.span.lo(), item.span.ctxt());
531-
let end_of_attr_to_item = Span::new(attr.span.hi(), item.span.lo(), item.span.ctxt());
530+
let begin_of_attr_to_item = Span::new(attr.span.lo(), item.span.lo(), item.span.ctxt(), item.span.parent());
531+
let end_of_attr_to_item = Span::new(attr.span.hi(), item.span.lo(), item.span.ctxt(), item.span.parent());
532532

533533
if let Some(snippet) = snippet_opt(cx, end_of_attr_to_item) {
534534
let lines = snippet.split('\n').collect::<Vec<_>>();

clippy_lints/src/cognitive_complexity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl CognitiveComplexity {
9595
});
9696

9797
if let Some((low, high)) = pos {
98-
Span::new(low, high, header_span.ctxt())
98+
Span::new(low, high, header_span.ctxt(), header_span.parent())
9999
} else {
100100
return;
101101
}

clippy_lints/src/copies.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ fn emit_branches_sharing_code_lint(
472472

473473
let mut span = moved_start.to(span_end);
474474
// Improve formatting if the inner block has indention (i.e. normal Rust formatting)
475-
let test_span = Span::new(span.lo() - BytePos(4), span.lo(), span.ctxt());
475+
let test_span = Span::new(span.lo() - BytePos(4), span.lo(), span.ctxt(), span.parent());
476476
if snippet_opt(cx, test_span)
477477
.map(|snip| snip == " ")
478478
.unwrap_or_default()

clippy_lints/src/doc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,7 @@ fn check_text(cx: &LateContext<'_>, valid_idents: &FxHashSet<String>, text: &str
665665
span.lo() + BytePos::from_usize(offset),
666666
span.lo() + BytePos::from_usize(offset + word.len()),
667667
span.ctxt(),
668+
span.parent(),
668669
);
669670

670671
check_word(cx, word, span);

clippy_lints/src/implicit_hasher.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitHasher {
130130
let pos = snippet_opt(cx, item.span.until(target.span()))
131131
.and_then(|snip| Some(item.span.lo() + BytePos(snip.find("impl")? as u32 + 4)));
132132
if let Some(pos) = pos {
133-
Span::new(pos, pos, item.span.data().ctxt)
133+
Span::new(pos, pos, item.span.ctxt(), item.span.parent())
134134
} else {
135135
return;
136136
}
@@ -173,7 +173,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitHasher {
173173
Some(item.span.lo() + BytePos((i + (&snip[i..]).find('(')?) as u32))
174174
})
175175
.expect("failed to create span for type parameters");
176-
Span::new(pos, pos, item.span.data().ctxt)
176+
Span::new(pos, pos, item.span.ctxt(), item.span.parent())
177177
});
178178

179179
let mut ctr_vis = ImplicitHasherConstructorVisitor::new(cx, target);

clippy_lints/src/large_const_arrays.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ impl<'tcx> LateLintPass<'tcx> for LargeConstArrays {
6363
hi_pos - BytePos::from_usize("const".len()),
6464
hi_pos,
6565
item.span.ctxt(),
66+
item.span.parent(),
6667
);
6768
span_lint_and_then(
6869
cx,

clippy_lints/src/regex.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fn str_span(base: Span, c: regex_syntax::ast::Span, offset: u16) -> Span {
9191
let end = base.lo() + BytePos(u32::try_from(c.end.offset).expect("offset too large") + offset);
9292
let start = base.lo() + BytePos(u32::try_from(c.start.offset).expect("offset too large") + offset);
9393
assert!(start <= end);
94-
Span::new(start, end, base.ctxt())
94+
Span::new(start, end, base.ctxt(), base.parent())
9595
}
9696

9797
fn const_str<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> Option<String> {

clippy_lints/src/tabs_in_doc_comments.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ impl TabsInDocComments {
6969
attr.span.lo() + BytePos(3 + lo),
7070
attr.span.lo() + BytePos(3 + hi),
7171
attr.span.ctxt(),
72+
attr.span.parent(),
7273
);
7374
span_lint_and_sugg(
7475
cx,

0 commit comments

Comments
 (0)