Open Soupstraw opened 4 years ago
This seems to be specific to the nightly toolchain, works fine with stable.
I am getting the same error using the stable toolchain (stable-x86_64-pc-windows-msvc (default)).
rustc 1.48.0 (7eac88abb 2020-11-16)
Sorry for the delay in replying! I've been able to reproduce this on Linux with Rust rustc 1.48.0 (7eac88abb 2020-11-16)
as well:
$ cargo run --example samples
thread 'main' panicked at 'attempted to leave type `bindings::ffi::TCOD_key_t` uninitialized, which is invalid', /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/mem/mod.rs:658:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
There's also this warning during compilation:
warning: use of deprecated function `std::mem::uninitialized`: use `mem::MaybeUninit` instead
--> src/input.rs:193:53
|
193 | let mut c_key_state: ffi::TCOD_key_t = unsafe { mem::uninitialized() };
Switching all uses of unitialized!()
will hopefully fix this. MaybeUninit
. Unfortunately, I don't have the time/energy to maintain this project anymore. I've just opened a readme update that makes that explicit: #314.
If you open a fix, I'll merge it, but it may be better to try one of the newer and more powerful libraries instead:
I've raised #315 if anyone's available to merge.
This replaces the deprecated calls with MaybeUninit. Tests all still pass and the examples now all seem to run properly.
While looking at this I noticed there's a couple of other bits that are currently giving deprecated warnings that I'd guess will break in later versions of rust:
...
instead of ..=
lazy_static!
macro that seems to be fixed by updating the dependencyIf wanted I can push fixes for those too.
Hi, switching to mem::MaybeUninit doesn't seem to do much, i get the same error on both stable and nightly toolchain
thread 'main' panicked at 'attempted to leave type `tcod_sys::TCOD_key_t` uninitialized, which is invalid', /home/rob/.cargo/registry/src/github.com-1ecc6299db9ec823/tcod-0.15.0/src/input.rs:193:53
Line 193:
let mut c_key_state: mem::MaybeUninit<ffi::TCOD_key_t> = mem::MaybeUninit::uninit();
Why not just using an Option<ffi::TCOD_key_t>
?
I'm hitting this by following the tutorial about Rogue Like.
https://tomassedovic.github.io/roguelike-tutorial/part-7-gui.html
(I'm putting this in case someone go through the tutorial and reach the same issue)
For anyone that would like to finish the tutorial as exercise, switching to master branch in cargo worked for me (at least, for this specific issue).
[dependencies]
#tcod = "0.15"
tcod = { git= "https://github.com/tomassedovic/tcod-rs.git"}
Switching to master seems to solve the error, but for some odd reason, there is an occasional input stick. It's like something isn't registering a key release...
Switching to master seems to solve the error, but for some odd reason, there is an occasional input stick. It's like something isn't registering a key release...
Getting the same error
As @giulio-Joshi said above, I fixed this by changing my Cargo.toml
to:
[dependencies]
tcod = { git = "https://github.com/tomassedovic/tcod-rs.git", rev = "d4ad074"}
I tried to use the
check_for_event
function, but got this error:I am using the Rust nightly toolchain, if that's somehow related.