slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.

Home Page:https://slint.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Struct field of type `easing` causes Slint compiler panic

Enyium opened this issue · comments

I followed your tutorial to create the Memory game with Rust backend. When I add the field easing-value: easing, to the struct TileData in the .slint file, VS Code on Windows 10 shows me "⚠️ rust-analyzer" with yellow background in the status bar. When I click it, the following output is shown:

2024-08-01T09:42:20.964688Z ERROR Flycheck failed to run the following command: CommandHandle { program: "C:\\Users\\redacted\\.cargo\\bin\\cargo.exe", arguments: ["check", "--workspace", "--message-format=json-diagnostic-rendered-ansi", "--manifest-path", "C:\\redacted\\memory\\Cargo.toml", "--keep-going", "--all-targets"], current_dir: Some("C:\\redacted\\memory") }, error=Cargo watcher failed, the command produced no valid metadata (exit code: ExitStatus(ExitStatus(101))):
   Compiling memory v0.1.0 (C:\redacted\memory)
error: failed to run custom build command for `memory v0.1.0 (C:\redacted\memory)`
note: To improve backtraces for build dependencies, set the CARGO_PROFILE_DEV_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.

Caused by:
  process didn't exit successfully: `C:\redacted\memory\target\debug\build\memory-4de4583e8d58460d\build-script-build` (exit code: 101)
  --- stderr
  thread 'main' panicked at C:\Users\redacted\.cargo\registry\src\index.crates.io-6f17d22bba15001f\i-slint-compiler-1.7.1\generator\rust.rs:376:78:
  called `Option::unwrap()` on a `None` value
  stack backtrace:
     0: std::panicking::begin_panic_handler
               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\panicking.rs:647
     1: core::panicking::panic_fmt
               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\core\src\panicking.rs:72
     2: core::panicking::panic
               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\core\src\panicking.rs:144
     3: core::option::unwrap_failed
               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\core\src\option.rs:1978
     4: i_slint_compiler::generator::rust::generate_struct::{{closure}}
     5: core::iter::adapters::map::map_fold::{{closure}}
     6: core::iter::traits::iterator::Iterator::fold
     7: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
     8: <(ExtendA,ExtendB) as core::iter::traits::collect::Extend<(A,B)>>::extend
     9: core::iter::traits::iterator::Iterator::unzip
    10: i_slint_compiler::generator::rust::generate::{{closure}}
    11: i_slint_compiler::generator::rust::generate
    12: core::iter::adapters::filter_map::filter_map_fold::{{closure}}
    13: <core::slice::iter::Iter<T> as core::iter::traits::iterator::Iterator>::fold
    14: <core::iter::adapters::filter_map::FilterMap<I,F> as core::iter::traits::iterator::Iterator>::fold
    15: <(ExtendA,ExtendB) as core::iter::traits::collect::Extend<(A,B)>>::extend
    16: core::iter::traits::iterator::Iterator::unzip
    17: i_slint_compiler::generator::rust::generate
    18: hashbrown::raw::inner::RawTable<T,A>::is_empty
    19: slint_build::compile
    20: core::slice::<impl [T]>::reverse::revswap
    21: core::ops::function::FnOnce::call_once
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

I added fields with many of the Slint language's types to the struct to see what Rust types are used in the generated code. Only a field of type easing made problems.

Thanks for filling an issue.
Indeed easing is not really a public type in Rust and cannot be easily represented in struct.
At least the panic should be fixed.
But there are other problems such as #3943