Skip to content

Commit 8b172ce

Browse files
chore: add span creation util function
1 parent 6f2624e commit 8b172ce

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/formatting/patterns.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::formatting::{
1818
source_map::SpanUtils,
1919
spanned::Spanned,
2020
types::{rewrite_path, PathContext},
21-
utils::{format_mutability, mk_sp, rewrite_ident},
21+
utils::{format_mutability, mk_sp, mk_sp_lo_plus_one, rewrite_ident},
2222
};
2323

2424
/// Returns `true` if the given pattern is "short".
@@ -459,7 +459,7 @@ fn rewrite_tuple_pat(
459459
let sp = pat_vec[new_item_count - 1].span();
460460
let snippet = context.snippet(sp);
461461
let lo = sp.lo() + BytePos(snippet.find_uncommented("_").unwrap() as u32);
462-
pat_vec[new_item_count - 1] = TuplePatField::Dotdot(mk_sp(lo, lo + BytePos(1)));
462+
pat_vec[new_item_count - 1] = TuplePatField::Dotdot(mk_sp_lo_plus_one(lo));
463463
(
464464
&pat_vec[..new_item_count],
465465
mk_sp(span.lo(), lo + BytePos(1)),

src/formatting/utils.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,10 @@ pub(crate) fn mk_sp(lo: BytePos, hi: BytePos) -> Span {
372372
Span::new(lo, hi, SyntaxContext::root())
373373
}
374374

375+
pub(crate) fn mk_sp_lo_plus_one(lo: BytePos) -> Span {
376+
Span::new(lo, lo + BytePos(1), SyntaxContext::root())
377+
}
378+
375379
// Returns `true` if the given span does not intersect with file lines.
376380
macro_rules! out_of_file_lines_range {
377381
($self:ident, $span:expr) => {

0 commit comments

Comments
 (0)