Skip to content

Commit 167ae26

Browse files
Rollup merge of rust-lang#88211 - petrochenkov:withhilo, r=jyn514
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
2 parents 2638d27 + 1df0b73 commit 167ae26

File tree

5 files changed

+6
-14
lines changed

5 files changed

+6
-14
lines changed

compiler/rustc_middle/src/middle/region.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl Scope {
189189
// To avoid issues with macro-generated spans, the span
190190
// of the statement must be nested in that of the block.
191191
if span.lo() <= stmt_span.lo() && stmt_span.lo() <= span.hi() {
192-
return Span::new(stmt_span.lo(), span.hi(), span.ctxt());
192+
return span.with_lo(stmt_span.lo());
193193
}
194194
}
195195
}

compiler/rustc_typeck/src/check/compare_method.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -708,11 +708,7 @@ fn compare_number_of_method_arguments<'tcx>(
708708
Some(if pos == 0 {
709709
arg.span
710710
} else {
711-
Span::new(
712-
trait_m_sig.decl.inputs[0].span.lo(),
713-
arg.span.hi(),
714-
arg.span.ctxt(),
715-
)
711+
arg.span.with_lo(trait_m_sig.decl.inputs[0].span.lo())
716712
})
717713
} else {
718714
trait_item_span
@@ -731,11 +727,7 @@ fn compare_number_of_method_arguments<'tcx>(
731727
if pos == 0 {
732728
arg.span
733729
} else {
734-
Span::new(
735-
impl_m_sig.decl.inputs[0].span.lo(),
736-
arg.span.hi(),
737-
arg.span.ctxt(),
738-
)
730+
arg.span.with_lo(impl_m_sig.decl.inputs[0].span.lo())
739731
}
740732
} else {
741733
impl_m_span

src/tools/clippy/clippy_lints/src/unit_return_expecting_ord.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ fn check_arg<'tcx>(cx: &LateContext<'tcx>, arg: &'tcx Expr<'tcx>) -> Option<(Spa
127127
then {
128128
let data = stmt.span.data();
129129
// Make a span out of the semicolon for the help message
130-
Some((span, Some(Span::new(data.hi-BytePos(1), data.hi, data.ctxt))))
130+
Some((span, Some(data.with_lo(data.hi-BytePos(1)))))
131131
} else {
132132
Some((span, None))
133133
}

src/tools/clippy/clippy_lints/src/write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ impl EarlyLintPass for Write {
299299
let nl_span = match (dest, only_nl) {
300300
// Special case of `write!(buf, "\n")`: Mark everything from the end of
301301
// `buf` for removal so no trailing comma [`writeln!(buf, )`] remains.
302-
(Some(dest_expr), true) => Span::new(dest_expr.span.hi(), nl_span.hi(), nl_span.ctxt()),
302+
(Some(dest_expr), true) => nl_span.with_lo(dest_expr.span.hi()),
303303
_ => nl_span,
304304
};
305305
span_lint_and_then(

src/tools/clippy/clippy_utils/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ fn line_span<T: LintContext>(cx: &T, span: Span) -> Span {
881881
let source_map_and_line = cx.sess().source_map().lookup_line(span.lo()).unwrap();
882882
let line_no = source_map_and_line.line;
883883
let line_start = source_map_and_line.sf.lines[line_no];
884-
Span::new(line_start, span.hi(), span.ctxt())
884+
span.with_lo(line_start)
885885
}
886886

887887
/// Gets the parent node, if any.

0 commit comments

Comments
 (0)