Skip to content

Commit

Permalink
Rollup merge of rust-lang#88211 - petrochenkov:withhilo, r=jyn514
Browse files Browse the repository at this point in the history
cleanup: `Span::new` -> `Span::with_lo`

Extracted from rust-lang#84373 as suggested in rust-lang#84373 (comment).
It turned out less useful then I expected, but anyway.
r? `@cjgillot`
`@bors` rollup
  • Loading branch information
GuillaumeGomez authored Aug 22, 2021
2 parents e5fe462 + cd4bf7f commit 5868e28
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/unit_return_expecting_ord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ fn check_arg<'tcx>(cx: &LateContext<'tcx>, arg: &'tcx Expr<'tcx>) -> Option<(Spa
then {
let data = stmt.span.data();
// 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 {
Some((span, None))
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ impl EarlyLintPass for Write {
let nl_span = match (dest, only_nl) {
// Special case of `write!(buf, "\n")`: Mark everything from the end of
// `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,
};
span_lint_and_then(
Expand Down
2 changes: 1 addition & 1 deletion clippy_utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 line_no = source_map_and_line.line;
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.
Expand Down

0 comments on commit 5868e28

Please sign in to comment.