if and else Have Incompatible Types in polars-arrow 0.37.0
Asked Answered
N

2

6

I've encountered an issue while using Polars version 0.37.0 and running cargo clippy for code checking. The error arises in the polars-arrow-0.37.0 crate, specifically in the utf8_to.rs file. Below is the detailed error message:

error[E0308]: `if` and `else` have incompatible types
   --> /Users/me/.cargo/registry/src/index.crates.io-6f17d22bba15001f/polars-arrow-0.37.0/src/compute/cast/utf8_to.rs:101:9
    |
98  |       let buffers = if uses_buffer {
    |  ___________________-
99  | |         Arc::from([arr.values().clone()])
    | |         --------------------------------- expected because of this
100 | |     } else {
101 | |         Arc::from([])
    | |         ^^^^^^^^^^^^^ expected an array with a fixed size of 1 element, found one with 0 elements
102 | |     };
    | |_____- `if` and `else` have incompatible types
    |
    = note: expected struct `Arc<[buffer::immutable::Buffer<u8>; 1]>`
               found struct `Arc<[_; 0]>`

Any guidance or suggestions on how to address this issue would be greatly appreciated. If further information is needed, I am happy to provide it.

[I added minimal reproducible example!]

minimal reproducible example:

main.rs:

fn main() {}

Cargo.toml:

[package] 
name = "polars-test-me" 
version = "0.1.0" 
edition = "2021"

[dependencies]
polars = "0.37.0"

cargo command:

$ cargo clippy

Rust version information:

$ rustc -V
rustc 1.72.0 (5680fa18f 2023-08-23)
$ cargo --version
cargo 1.72.0 (103a7ff2e 2023-08-15)
$ cargo clippy -V
clippy 0.1.72 (5680fa18 2023-08-23)
Nikethamide answered 28/1 at 11:53 Comment(10)
Please create an minimal reproducible example; how are you even calling the polars-arrow code; what is the data type involved, etc?Collazo
Did you search e.g. the polars issue tracker to see if this is a known issue?Collazo
@Collazo I created a minimal reproducible example. Actually, I did not call polars-arrow but just checked the dependency using "cargo clippy". And I searched on polars issue and stackoverflow.Nikethamide
It looks like a library bug. But to remove doubt, what version of Rust are you using? And if its old can you try updating it to see if its reproducible?Blinking
@Blinking (Is this mentation working well?) Thank you for your suggestion. I checked the version: rustc 1.72.0 (5680fa18f 2023-08-23), cargo 1.72.0 (103a7ff2e 2023-08-15). I don't think they are that old.Nikethamide
I'm new to asking about bugs in programmes, could you tell me the right place to report these kinds of bugs?Nikethamide
You'll need a GitHub account, then submit an issue at github.com/pola-rs/polars/issues . Your mcve here can be put on there as well; and you can link to this SO question.Collazo
Note that I tried your mcve, with rust and cargo version 1.75.0, and clippy 0.1.75 (not sure if that's a coincidence, or that clippy's version always follows Rust's version that way), and I can't reproduce your issue.Collazo
I asusme you are running Rust edition 2021? Since your Cargo.toml example leaves out that part.Collazo
@Collazo I use Rust edition 2021 ([package] name = "polars-test-me" version = "0.1.0" edition = "2021")Nikethamide
M
2

I just encountered this exact same issue and fixed it by simply doing rustup update.

Meiosis answered 28/2 at 14:24 Comment(1)
This also fixed the error for mePartee
H
0

Updating your compiler with rustup update will likely fix this for you.

Rust crates have a minimum supported Rust version, or MSRV, which is the Rust toolchain version required to build them.

The documented MSRV of this crate is 1.71, but apparently the project doesn't have testing in place to check this, and as you've discovered, the crate doesn't compile in Rust 1.72 or earlier. The actual MSRV is 1.73. This issue has been reported here.

Hoggard answered 28/2 at 14:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.