Skip to content

Commit 1df0b73

Browse files
committed
cleanup: Span::new -> Span::with_lo
1 parent db002a0 commit 1df0b73

File tree

5 files changed

+6
-14
lines changed

5 files changed

+6
-14
lines changed

compiler/rustc_middle/src/middle/region.rs

+1-1
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

+2-10
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

+1-1
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

+1-1
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@ fn line_span<T: LintContext>(cx: &T, span: Span) -> Span {
877877
let source_map_and_line = cx.sess().source_map().lookup_line(span.lo()).unwrap();
878878
let line_no = source_map_and_line.line;
879879
let line_start = source_map_and_line.sf.lines[line_no];
880-
Span::new(line_start, span.hi(), span.ctxt())
880+
span.with_lo(line_start)
881881
}
882882

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

0 commit comments

Comments
 (0)