Rollup merge of #88211 - petrochenkov:withhilo, r=jyn514
cleanup: `Span::new` -> `Span::with_lo` Extracted from https://github.com/rust-lang/rust/pull/84373 as suggested in https://github.com/rust-lang/rust/pull/84373#issuecomment-857773867. It turned out less useful then I expected, but anyway. r? `@cjgillot` `@bors` rollup
This commit is contained in:
commit
167ae26a88
5 changed files with 6 additions and 14 deletions
|
@ -189,7 +189,7 @@ impl Scope {
|
||||||
// To avoid issues with macro-generated spans, the span
|
// To avoid issues with macro-generated spans, the span
|
||||||
// of the statement must be nested in that of the block.
|
// of the statement must be nested in that of the block.
|
||||||
if span.lo() <= stmt_span.lo() && stmt_span.lo() <= span.hi() {
|
if span.lo() <= stmt_span.lo() && stmt_span.lo() <= span.hi() {
|
||||||
return Span::new(stmt_span.lo(), span.hi(), span.ctxt());
|
return span.with_lo(stmt_span.lo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -708,11 +708,7 @@ fn compare_number_of_method_arguments<'tcx>(
|
||||||
Some(if pos == 0 {
|
Some(if pos == 0 {
|
||||||
arg.span
|
arg.span
|
||||||
} else {
|
} else {
|
||||||
Span::new(
|
arg.span.with_lo(trait_m_sig.decl.inputs[0].span.lo())
|
||||||
trait_m_sig.decl.inputs[0].span.lo(),
|
|
||||||
arg.span.hi(),
|
|
||||||
arg.span.ctxt(),
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
trait_item_span
|
trait_item_span
|
||||||
|
@ -731,11 +727,7 @@ fn compare_number_of_method_arguments<'tcx>(
|
||||||
if pos == 0 {
|
if pos == 0 {
|
||||||
arg.span
|
arg.span
|
||||||
} else {
|
} else {
|
||||||
Span::new(
|
arg.span.with_lo(impl_m_sig.decl.inputs[0].span.lo())
|
||||||
impl_m_sig.decl.inputs[0].span.lo(),
|
|
||||||
arg.span.hi(),
|
|
||||||
arg.span.ctxt(),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
impl_m_span
|
impl_m_span
|
||||||
|
|
|
@ -127,7 +127,7 @@ fn check_arg<'tcx>(cx: &LateContext<'tcx>, arg: &'tcx Expr<'tcx>) -> Option<(Spa
|
||||||
then {
|
then {
|
||||||
let data = stmt.span.data();
|
let data = stmt.span.data();
|
||||||
// Make a span out of the semicolon for the help message
|
// Make a span out of the semicolon for the help message
|
||||||
Some((span, Some(Span::new(data.hi-BytePos(1), data.hi, data.ctxt))))
|
Some((span, Some(data.with_lo(data.hi-BytePos(1)))))
|
||||||
} else {
|
} else {
|
||||||
Some((span, None))
|
Some((span, None))
|
||||||
}
|
}
|
||||||
|
|
|
@ -299,7 +299,7 @@ impl EarlyLintPass for Write {
|
||||||
let nl_span = match (dest, only_nl) {
|
let nl_span = match (dest, only_nl) {
|
||||||
// Special case of `write!(buf, "\n")`: Mark everything from the end of
|
// Special case of `write!(buf, "\n")`: Mark everything from the end of
|
||||||
// `buf` for removal so no trailing comma [`writeln!(buf, )`] remains.
|
// `buf` for removal so no trailing comma [`writeln!(buf, )`] remains.
|
||||||
(Some(dest_expr), true) => Span::new(dest_expr.span.hi(), nl_span.hi(), nl_span.ctxt()),
|
(Some(dest_expr), true) => nl_span.with_lo(dest_expr.span.hi()),
|
||||||
_ => nl_span,
|
_ => nl_span,
|
||||||
};
|
};
|
||||||
span_lint_and_then(
|
span_lint_and_then(
|
||||||
|
|
|
@ -881,7 +881,7 @@ fn line_span<T: LintContext>(cx: &T, span: Span) -> Span {
|
||||||
let source_map_and_line = cx.sess().source_map().lookup_line(span.lo()).unwrap();
|
let source_map_and_line = cx.sess().source_map().lookup_line(span.lo()).unwrap();
|
||||||
let line_no = source_map_and_line.line;
|
let line_no = source_map_and_line.line;
|
||||||
let line_start = source_map_and_line.sf.lines[line_no];
|
let line_start = source_map_and_line.sf.lines[line_no];
|
||||||
Span::new(line_start, span.hi(), span.ctxt())
|
span.with_lo(line_start)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the parent node, if any.
|
/// Gets the parent node, if any.
|
||||||
|
|
Loading…
Reference in a new issue