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

rust no longer accepts comparison between byte and i8 in event.rs, expects u8 #469

Closed
makoConstruct opened this issue Nov 18, 2015 · 19 comments

Comments

@makoConstruct
Copy link

just here and a couple lines down in the case for TextInput as well. thx.

(hopefully irrelevant but I'll mention it just in case: I'm compiling for arm, with a very recently compiled rustc)

@makoConstruct
Copy link
Author

o_o Uhh.. apparently it was relevant. When I compile for x86_64 it refuses to accept a u8 and expects an i8. I guess I'll file a bug upstream, then?

@MagaTailor
Copy link
Contributor

rust-lang/rust#29867

@makoConstruct
Copy link
Author

true

@MagaTailor
Copy link
Contributor

The solution is still missing though.

@makoConstruct
Copy link
Author

Is updating your rustc to the most recent version not an adequate solution? Another workaround is simply adding a conversion on the left side in the expression on the two offending lines:

                            .take_while(|&b| (*b) as u8 != 0u8)

@MagaTailor
Copy link
Contributor

No, it's actually the problem (coupled with the libc crate update). The way it's looking right now crate authors will have been forced to fix this breakage at crate level.

I wanted to open an issue for sdl2 but found it'd already been done (more or less). Until a new crate gets published it should definitely stay open.

@MagaTailor
Copy link
Contributor

We're talking about this kind of problem in general:

 >     Compiling sdl2 v0.8.0

+---- 0.8.0/src/sdl2/clipboard.rs : 34 ----+
      =====>  error: mismatched types:

           >   expected `*const i8`,
           >      found `*const u8`
           >  (expected i8,
           >      found u8) [E0308]
 34 |>              let result = ll::SDL_SetClipboardText(text.as_ptr());
                                                                                                                        ^~~~~~~~~~~~~


+---- 0.8.0/src/sdl2/clipboard.rs : 34 ----+
      =====>  help: run `rustc --explain E0308` to see a detailed
           >        explanation


+---- 0.8.0/src/sdl2/clipboard.rs : 51 ----+
      =====>  error: mismatched types:

           >   expected `*const u8`,
           >      found `*const i8`
           >  (expected u8,
           >      found i8) [E0308]
 51 |>                  Ok(String::from_utf8_lossy(CStr::from_ptr(buf).to_bytes()).into_owned())
                                                                                                                                ^~~


+---- 0.8.0/src/sdl2/clipboard.rs : 51 ----+
      =====>  help: run `rustc --explain E0308` to see a detailed
           >        explanation


+---- 0.8.0/src/sdl2/event.rs : 940 ----+
      =====>  error: mismatched types:

           >   expected `*const u8`,
           >      found `*const i8`
           >  (expected u8,
           >      found i8) [E0308]
 940 |>                  let buf = CStr::from_ptr(event.file).to_bytes();
                                                                                                                ^~~~~~~~~~


+---- 0.8.0/src/sdl2/event.rs : 940 ----+
      =====>  help: run `rustc --explain E0308` to see a detailed
           >        explanation


+---- 0.8.0/src/sdl2/filesystem.rs : 11 ----+
      =====>  error: mismatched types:

           >   expected `*const u8`,
           >      found `*const i8`
           >  (expected u8,
           >      found i8) [E0308]
 11 |>          String::from_utf8_lossy(CStr::from_ptr(buf).to_bytes()).to_string()
                                                                                                                     ^~~

and so on.

@makoConstruct
Copy link
Author

Ah, apologies for closing it. It's difficult to imagine why this particular aspect of the problem should be left as it is.

@makoConstruct makoConstruct reopened this Nov 21, 2015
@AngryLawyer
Copy link
Member

I'm a touch confused - is this problem still extant?

@MagaTailor
Copy link
Contributor

The big breakage affecting arm linux and android is still there - have a look at the list of affected crates (found so far) at the bottom of rust-lang/rust#29867

The OP's issue may have been fixed by updating libstd but not the sdl2 crate itself.

@AngryLawyer
Copy link
Member

Cool. I'll take a pop at fixing this at lunch.

@AngryLawyer
Copy link
Member

Okay @petevine and @makoConstruct, I've had a crack at fixing it. It compiles fine on my cross-compiler, but I've not got anything to test it beyond that point.

#472

Does this work for you?

@MagaTailor
Copy link
Contributor

Nope, still not compiling:

Compiling sdl2 v0.12.0 (file:///tmp/rust-sdl2-arm-friendly)
src/sdl2/clipboard.rs:52:59: 52:75 error: mismatched types:
 expected `*const u8`,
    found `*const i8`
(expected u8,
    found i8) [E0308]
src/sdl2/clipboard.rs:52                 Ok(String::from_utf8_lossy(CStr::from_ptr(buf as *const i8).to_bytes()).into_owned())

and so on (the errors are coming exlusively from as *const i8 statements` now)

@AngryLawyer
Copy link
Member

Huh.
What cross-compiler you using? I'm not getting the same errors.
Also, version of Rust?

@MagaTailor
Copy link
Contributor

Native nightly 1.6 on armv7 linux.

@AngryLawyer
Copy link
Member

This is now fixed for ARM with Rust 1.6.0 onwards.

@MagaTailor
Copy link
Contributor

What's the solution (if any) for older versions of sdl2?

For example, sokoban-rs uses 0.8.0 and it's not possible to just bump the version in Cargo.toml :

Downloading sdl2 v0.12.0
native library `SDL2` is being linked to by more than one package, and can only be linked to by one package

  sdl2-sys v0.6.2
  sdl2-sys v0.7.0

After forcing sdl2_image and sdl2_ttf to use sdl2-sys v0.7.0 in their respective Cargo.toml's I'm still getting the same error. What gives?

@AngryLawyer
Copy link
Member

Not entirely sure what's going on, but you'll need to encourage the package maintainers to update I think.

You might be able to override it here:
http://doc.crates.io/guide.html#overriding-dependencies

@MagaTailor
Copy link
Contributor

Thanks for the suggestion - I concluded it was mostly caused by * dependencies leading to incompatibilities.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants