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

Failed to build because of mismatched types #2

Closed
senden9 opened this issue Jul 6, 2019 · 3 comments
Closed

Failed to build because of mismatched types #2

senden9 opened this issue Jul 6, 2019 · 3 comments
Labels
bug Something isn't working

Comments

@senden9
Copy link

senden9 commented Jul 6, 2019

Hi!

It seems this crate fails to build. To reproduce just create a new "hello world" project, at this dependency to Cargo.toml, and try to build.

Versions:

rlimit v0.1.0
cargo 1.36.0 (c4fcfb725 2019-05-15)
rustc 1.36.0 (a53f9df32 2019-07-03)
OS: Arch Linux
cargo build
   Compiling libc v0.2.58
   Compiling rlimit v0.1.0
error[E0308]: mismatched types
  --> /home/stefano/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.1.0/src/lib.rs:50:45
   |
50 |         let code = unsafe { libc::setrlimit(resource, &mut limit as *mut libc::rlimit) };
   |                                             ^^^^^^^^ expected u32, found i32
help: you can convert an `i32` to `u32` and panic if the converted value wouldn't fit
   |
50 |         let code = unsafe { libc::setrlimit(resource.try_into().unwrap(), &mut limit as *mut libc::rlimit) };
   |                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
  --> /home/stefano/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.1.0/src/lib.rs:61:45
   |
61 |         let code = unsafe { libc::getrlimit(resource, &mut limit as *mut libc::rlimit) };
   |                                             ^^^^^^^^ expected u32, found i32
help: you can convert an `i32` to `u32` and panic if the converted value wouldn't fit
   |
61 |         let code = unsafe { libc::getrlimit(resource.try_into().unwrap(), &mut limit as *mut libc::rlimit) };
   |                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0308`.
error: Could not compile `rlimit`.

To learn more, run the command again with --verbose.
@Nugine
Copy link
Owner

Nugine commented Jul 28, 2019

Sorry, I didn't notice this issue.
This crate failed to build because libc::setrlimit changed its signature at 0.2.56.

https://docs.rs/libc/0.2.55/libc/fn.setrlimit.html
https://docs.rs/libc/0.2.56/libc/fn.setrlimit.html

I haved released rlimit 0.2.1 to follow this change.
Another break change is using std::io::Error instead of i32 as error type.

Hope you like it!

@Nugine Nugine closed this as completed Jul 28, 2019
@Nugine Nugine reopened this Jul 28, 2019
@Nugine
Copy link
Owner

Nugine commented Jul 28, 2019

libc #1365
libc #1382
libc #1384
libc #1397

libc's rlimit definition is different on different platforms. I will try to fix this.

@Nugine
Copy link
Owner

Nugine commented Jul 30, 2019

rlimit 0.3.0 has been released. It is a brand new version. Hope you like it!

@Nugine Nugine closed this as completed Jul 30, 2019
@Nugine Nugine added the bug Something isn't working label Feb 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants