Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

building: incompatible types error in compute/cast/utf8_to.rs #14134

Closed
2 tasks done
fdncred opened this issue Jan 31, 2024 · 7 comments
Closed
2 tasks done

building: incompatible types error in compute/cast/utf8_to.rs #14134

fdncred opened this issue Jan 31, 2024 · 7 comments
Labels
bug Something isn't working needs triage Awaiting prioritization by a maintainer rust Related to Rust Polars

Comments

@fdncred
Copy link

fdncred commented Jan 31, 2024

Checks

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of Polars.

Reproducible example

Just building the crate, these lines produce the error.

    let buffers = if uses_buffer {
        Arc::from([arr.values().clone()])
    } else {
        Arc::from([])
    };

Log output

error[E0308]: `if` and `else` have incompatible types
   --> C:\Users\dschroeder\.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]>`

Issue description

I'm trying to update nushell to the latest polars 0.37.0 crates and cannot build because of this error.

Expected behavior

clean build without warnings or errors.

Installed versions

polars-io = { version = "0.37", features = ["avro"], optional = true }
polars-arrow = { version = "0.37", optional = true }
polars-ops = { version = "0.37", optional = true }
polars-plan = { version = "0.37", optional = true }
polars-utils = { version = "0.37", optional = true }

[dependencies.polars]
features = [
"arg_where",
"checked_arithmetic",
"concat_str",
"cross_join",
"csv",
"cum_agg",
"default",
"dtype-categorical",
"dtype-datetime",
"dtype-struct",
"dtype-i8",
"dtype-i16",
"dtype-u8",
"dtype-u16",
"dynamic_group_by",
"ipc",
"is_in",
"json",
"lazy",
"object",
"parquet",
"random",
"rolling_window",
"rows",
"serde",
"serde-lazy",
"strings",
"to_dummies",
]
optional = true
version = "0.37"

@fdncred fdncred added bug Something isn't working needs triage Awaiting prioritization by a maintainer rust Related to Rust Polars labels Jan 31, 2024
@ritchie46
Copy link
Member

That's strange, what is your compiler version?

@fdncred
Copy link
Author

fdncred commented Jan 31, 2024

We have a rust-toolchain.toml file that forces the compiler to this version currently. We try to stay 2 versions behind rust's latest so distros can keep up to date easier.

[toolchain]
profile = "default"
channel = "1.73.0"

@BGR360
Copy link
Contributor

BGR360 commented Feb 1, 2024

I have a minimal repro below. Looks like the problem only occurs when a local variable is introduced.

arc-slice.rs:

use std::sync::Arc;

fn takes_arc_slice(_: Arc<[u8]>) {}

fn works() {
    takes_arc_slice(if true {
        Arc::from([255])
    } else {
        Arc::from([])
    });
}

fn doesnt_work() {
    let buffers = if true {
        Arc::from([255])
    } else {
        Arc::from([])
    };
    takes_arc_slice(buffers);
}

fn main() {
    works();
    doesnt_work();
}

It fails to compile on 1.73.0 with the same error. It compiles successfully on 1.74.0 and stable (1.75.0). I'll file an issue on the Rust repo so they can at least put a regression test in there.

$ rustc +1.73.0 arc-slice.rs
error[E0308]: `if` and `else` have incompatible types
  --> arc-slice.rs:17:9
   |
14 |       let buffers = if true {
   |  ___________________-
15 | |         Arc::from([255])
   | |         ---------------- expected because of this
16 | |     } else {
17 | |         Arc::from([])
   | |         ^^^^^^^^^^^^^ expected an array with a fixed size of 1 element, found one with 0 elements
18 | |     };
   | |_____- `if` and `else` have incompatible types
   |
   = note: expected struct `Arc<[{integer}; 1]>`
              found struct `Arc<[_; 0]>`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
$ rustc +1.74.0 arc-slice.rs
$ rustc +stable arc-slice.rs
$

@fdncred
Copy link
Author

fdncred commented Feb 1, 2024

Thanks for the research @BGR360! Since a new rust release will be out in about a week (Feb-8th I think), and the compile works in 1.74, we can just wait to bump nushell to the next version of polars until then. I'm happy to have this issue closed if the powers that be wish it so. Much love to the team and contributors here ❤️!

@jmcnamara
Copy link

+1

I also came across this issue with rustc 1.72.0 when trying to upgrade the Polars version used by rust_xlsxwriter.

@LCrossman
Copy link

I encountered this error when running rust-matplotlib on Macbook M2 under Rosetta2 with rustc v 1.71. However, there was no error when running the same library under arm64 in rustc v 1.78.
I use anaconda package manager to switch between environments for the M2 to run as arm64 or through Rosetta2 run as x86_64.
I then updated rustc from 1.71 to 1.77 in x86_64 environment and the error was solved and now no polars arrow error in either environment.

@fdncred
Copy link
Author

fdncred commented Apr 19, 2024

Closing this since nushell has upgraded to 1.77.2 now.

@fdncred fdncred closed this as completed Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage Awaiting prioritization by a maintainer rust Related to Rust Polars
Projects
None yet
Development

No branches or pull requests

5 participants