seanmonstar / httparse

A push parser for the HTTP 1.x protocol in Rust.
https://docs.rs/httparse
Apache License 2.0
593 stars 115 forks source link

httparse 1.9.1 unit tests fail to compile on 32-bit architectures #169

Closed decathorpe closed 5 months ago

decathorpe commented 5 months ago

I tried to rebase the Fedora Linux package for the httparse crate to the latest version, but got test failures on i686-unknown-linux-gnu. Looks like some file types might have an unexpectedly-architecture-dependent size:

error[E0308]: mismatched types
   --> src/simd/swar.rs:194:36
    |
194 |     assert!(!is_header_value_block(*b"foo.com\n"));
    |              --------------------- ^^^^^^^^^^^^^ expected an array with a fixed size of 4 elements, found one with 8 elements
    |              |
    |              arguments to this function are incorrect
    |
note: expected because the closure was earlier called with an argument of type `[u8; 4]`
   --> src/simd/swar.rs:182:40
    |
182 |         assert!(!is_header_value_block([b; BLOCK_SIZE]), "b={}", b);
    |                  --------------------- ^^^^^^^^^^^^^^^ expected because this argument is of type `[u8; 4]`
    |                  |
    |                  in this closure call
note: closure parameter defined here
   --> src/simd/swar.rs:178:34
    |
178 |     let is_header_value_block = |b| match_header_value_char_8_swar(b) == BLOCK_SIZE;
    |                                  ^
error[E0308]: mismatched types
   --> src/simd/swar.rs:195:36
    |
195 |     assert!(!is_header_value_block(*b"o.com\r\nU"));
    |              --------------------- ^^^^^^^^^^^^^^ expected an array with a fixed size of 4 elements, found one with 8 elements
    |              |
    |              arguments to this function are incorrect
    |
note: expected because the closure was earlier called with an argument of type `[u8; 4]`
   --> src/simd/swar.rs:182:40
    |
182 |         assert!(!is_header_value_block([b; BLOCK_SIZE]), "b={}", b);
    |                  --------------------- ^^^^^^^^^^^^^^^ expected because this argument is of type `[u8; 4]`
    |                  |
    |                  in this closure call
note: closure parameter defined here
   --> src/simd/swar.rs:178:34
    |
178 |     let is_header_value_block = |b| match_header_value_char_8_swar(b) == BLOCK_SIZE;
    |                                  ^
For more information about this error, try `rustc --explain E0308`.
error: could not compile `httparse` (lib test) due to 2 previous errors
seanmonstar commented 5 months ago

Hm, seems like our CI matrix has several holes. I added an x86 target this morning, but perhaps we need another one with SIMD disabled?

seanmonstar commented 5 months ago

v1.9.2 published with this fixed.

decathorpe commented 5 months ago

Awesome, thank you for the quick fix!