Skip to content

Commit 60dc57f

Browse files
committed
fix: Make SIMD newline count match non-SIMD
1 parent 256d67f commit 60dc57f

File tree

2 files changed

+1
-34
lines changed

2 files changed

+1
-34
lines changed

src/renderer/mod.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3009,9 +3009,7 @@ fn max_line_number(groups: &[Group<'_>]) -> usize {
30093009
fn newline_count(body: &str) -> usize {
30103010
#[cfg(feature = "simd")]
30113011
{
3012-
memchr::memchr_iter(b'\n', body.as_bytes())
3013-
.count()
3014-
.saturating_sub(1)
3012+
memchr::memchr_iter(b'\n', body.as_bytes()).count()
30153013
}
30163014
#[cfg(not(feature = "simd"))]
30173015
{
@@ -3058,9 +3056,6 @@ mod test {
30583056
bar = { base = '^^not-valid^^', path = 'bar' }
30593057
"#;
30603058
let actual_count = newline_count(source);
3061-
#[cfg(feature = "simd")]
3062-
let expected_count = 9;
3063-
#[cfg(not(feature = "simd"))]
30643059
let expected_count = 10;
30653060

30663061
assert_eq!(expected_count, actual_count);

tests/formatter.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3253,33 +3253,6 @@ fn multiple_line_num_widths() {
32533253
),
32543254
];
32553255

3256-
#[cfg(feature = "simd")]
3257-
{
3258-
let expected_ascii = str![[r#"
3259-
error: invalid character `^` in path base name: `^^not-valid^^`, the first character must be a Unicode XID start character (most letters or `_`)
3260-
--> Cargo.toml:10:24
3261-
|
3262-
9 | [dependencies]
3263-
10| bar = { base = '^^not-valid^^', path = 'bar' }
3264-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3265-
"#]];
3266-
let renderer = Renderer::plain();
3267-
assert_data_eq!(renderer.render(input), expected_ascii);
3268-
3269-
let expected_unicode = str![[r#"
3270-
error: invalid character `^` in path base name: `^^not-valid^^`, the first character must be a Unicode XID start character (most letters or `_`)
3271-
╭▸ Cargo.toml:10:24
3272-
3273-
9 │ [dependencies]
3274-
10│ bar = { base = '^^not-valid^^', path = 'bar' }
3275-
╰╴ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
3276-
"#]];
3277-
let renderer = renderer.decor_style(DecorStyle::Unicode);
3278-
assert_data_eq!(renderer.render(input), expected_unicode);
3279-
}
3280-
3281-
#[cfg(not(feature = "simd"))]
3282-
{
32833256
let expected_ascii = str![[r#"
32843257
error: invalid character `^` in path base name: `^^not-valid^^`, the first character must be a Unicode XID start character (most letters or `_`)
32853258
--> Cargo.toml:10:24
@@ -3301,5 +3274,4 @@ error: invalid character `^` in path base name: `^^not-valid^^`, the first chara
33013274
"#]];
33023275
let renderer = renderer.decor_style(DecorStyle::Unicode);
33033276
assert_data_eq!(renderer.render(input), expected_unicode);
3304-
}
33053277
}

0 commit comments

Comments
 (0)