microsoft / windows-rs

Rust for Windows
https://kennykerr.ca/rust-getting-started/
Apache License 2.0
10.13k stars 473 forks source link

Unable to compile #3063

Closed michalmoc closed 1 month ago

michalmoc commented 1 month ago

Summary

I'm unable to install crate windows-sys. I'm using Windows 11 and Rust from rustup, both nightly and stable.

On stable "cargo 1.78.0 (54d8815d0 2024-03-26)" I get compile error:

error[E0080]: evaluation of constant value failed
    --> C:\Users\dekak\.cargo\registry\src\index.crates.io-6f17d22bba15001f\windows-sys-0.52.0\src\core\literals.rs:111:9
     |
111  |         len += if code_point <= 0xffff { 1 } else { 2 };
     |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ scalar size mismatch: expected 8 bytes but got 0 bytes instead
     |
note: inside `literals::utf16_len`
    --> C:\Users\dekak\.cargo\registry\src\index.crates.io-6f17d22bba15001f\windows-sys-0.52.0\src\core\literals.rs:111:9
     |
111  |         len += if code_point <= 0xffff { 1 } else { 2 };
     |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `NCRYPT_ECDH_P384_ALGORITHM::OUTPUT_LEN`
    --> C:\Users\dekak\.cargo\registry\src\index.crates.io-6f17d22bba15001f\windows-sys-0.52.0\src\core\literals.rs:14:35
     |
14   |         const OUTPUT_LEN: usize = $crate::core::utf16_len(INPUT) + 1;
     |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
    ::: C:\Users\dekak\.cargo\registry\src\index.crates.io-6f17d22bba15001f\windows-sys-0.52.0\src\Windows\Win32\Security\Cryptography\mod.rs:3060:69
     |
3060 | pub const NCRYPT_ECDH_P384_ALGORITHM: ::windows_sys::core::PCWSTR = ::windows_sys::core::w!("ECDH_P384");
     |                                                                     ------------------------------------ in this macro invocation
     = note: this error originates in the macro `::windows_sys::core::w` (in Nightly builds, run with -Z macro-backtrace for more info)

note: erroneous constant encountered
    --> C:\Users\dekak\.cargo\registry\src\index.crates.io-6f17d22bba15001f\windows-sys-0.52.0\src\core\literals.rs:15:30
     |
15   |         const OUTPUT: &[u16; OUTPUT_LEN] = {
     |                              ^^^^^^^^^^
     |
    ::: C:\Users\dekak\.cargo\registry\src\index.crates.io-6f17d22bba15001f\windows-sys-0.52.0\src\Windows\Win32\Security\Cryptography\mod.rs:3060:69
     |
3060 | pub const NCRYPT_ECDH_P384_ALGORITHM: ::windows_sys::core::PCWSTR = ::windows_sys::core::w!("ECDH_P384");
     |                                                                     ------------------------------------ in this macro invocation
     |
     = note: this note originates in the macro `::windows_sys::core::w` (in Nightly builds, run with -Z macro-backtrace for more info)

note: erroneous constant encountered
    --> C:\Users\dekak\.cargo\registry\src\index.crates.io-6f17d22bba15001f\windows-sys-0.52.0\src\core\literals.rs:16:34
     |
16   |             let mut buffer = [0; OUTPUT_LEN];
     |                                  ^^^^^^^^^^
     |
    ::: C:\Users\dekak\.cargo\registry\src\index.crates.io-6f17d22bba15001f\windows-sys-0.52.0\src\Windows\Win32\Security\Cryptography\mod.rs:3060:69
     |
3060 | pub const NCRYPT_ECDH_P384_ALGORITHM: ::windows_sys::core::PCWSTR = ::windows_sys::core::w!("ECDH_P384");
     |                                                                     ------------------------------------ in this macro invocation
     |
     = note: this note originates in the macro `::windows_sys::core::w` (in Nightly builds, run with -Z macro-backtrace for more info)

and

error[E0080]: evaluation of constant value failed
    --> C:\Users\dekak\.cargo\registry\src\index.crates.io-6f17d22bba15001f\windows-sys-0.52.0\src\core\literals.rs:46:14
     |
46   |     let ch = bytes[pos] as u32;
     |              ^^^^^^^^^^ scalar size mismatch: expected 8 bytes but got 0 bytes instead
     |
note: inside `literals::decode_utf8_char`
    --> C:\Users\dekak\.cargo\registry\src\index.crates.io-6f17d22bba15001f\windows-sys-0.52.0\src\core\literals.rs:46:14
     |
46   |     let ch = bytes[pos] as u32;
     |              ^^^^^^^^^^
note: inside `SL_PROP_LAST_ACT_ATTEMPT_HRESULT::OUTPUT`
    --> C:\Users\dekak\.cargo\registry\src\index.crates.io-6f17d22bba15001f\windows-sys-0.52.0\src\core\literals.rs:19:57
     |
19   |             while let Some((mut code_point, new_pos)) = $crate::core::decode_utf8_char(INPUT, input_pos) {
     |                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
    ::: C:\Users\dekak\.cargo\registry\src\index.crates.io-6f17d22bba15001f\windows-sys-0.52.0\src\Windows\Win32\Security\Authentication\Identity\mod.rs:1901:75
     |
1901 | pub const SL_PROP_LAST_ACT_ATTEMPT_HRESULT: ::windows_sys::core::PCWSTR = ::windows_sys::core::w!("SL_LAST_ACT_ATTEMPT_HRESULT");
     |                                                                           ------------------------------------------------------ in this macro invocation
     = note: this error originates in the macro `::windows_sys::core::w` (in Nightly builds, run with -Z macro-backtrace for more info)

note: erroneous constant encountered
    --> C:\Users\dekak\.cargo\registry\src\index.crates.io-6f17d22bba15001f\windows-sys-0.52.0\src\core\literals.rs:34:9
     |
34   |         OUTPUT.as_ptr()
     |         ^^^^^^
     |
    ::: C:\Users\dekak\.cargo\registry\src\index.crates.io-6f17d22bba15001f\windows-sys-0.52.0\src\Windows\Win32\Security\Authentication\Identity\mod.rs:1901:75
     |
1901 | pub const SL_PROP_LAST_ACT_ATTEMPT_HRESULT: ::windows_sys::core::PCWSTR = ::windows_sys::core::w!("SL_LAST_ACT_ATTEMPT_HRESULT");
     |                                                                           ------------------------------------------------------ in this macro invocation
     |
     = note: this note originates in the macro `::windows_sys::core::w` (in Nightly builds, run with -Z macro-backtrace for more info)

On nightly "cargo 1.80.0-nightly (431db31d0 2024-05-28)" compiler crashes:

thread 'rustc' panicked at compiler\rustc_mir_transform\src\lib.rs:270:36:
attempted to read from stolen value: rustc_middle::mir::Body
stack backtrace:
   0:     0x7ffec25c3b9d - std::backtrace_rs::backtrace::dbghelp64::trace
                               at /rustc/ada5e2c7b5427a591e30baeeee2698a5eb6db0bd/library\std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:91
   1:     0x7ffec25c3b9d - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/ada5e2c7b5427a591e30baeeee2698a5eb6db0bd/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ffec25c3b9d - std::sys_common::backtrace::_print_fmt
                               at /rustc/ada5e2c7b5427a591e30baeeee2698a5eb6db0bd/library\std\src\sys_common\backtrace.rs:68
   3:     0x7ffec25c3b9d - std::sys_common::backtrace::_print::impl$0::fmt
                               at /rustc/ada5e2c7b5427a591e30baeeee2698a5eb6db0bd/library\std\src\sys_common\backtrace.rs:44
   4:     0x7ffec25f47c9 - core::fmt::rt::Argument::fmt
                               at /rustc/ada5e2c7b5427a591e30baeeee2698a5eb6db0bd/library\core\src\fmt\rt.rs:165
   5:     0x7ffec25f47c9 - core::fmt::write
                               at /rustc/ada5e2c7b5427a591e30baeeee2698a5eb6db0bd/library\core\src\fmt\mod.rs:1168
   6:     0x7ffec25ba3f1 - std::io::Write::write_fmt<std::sys::pal::windows::stdio::Stderr>
                               at /rustc/ada5e2c7b5427a591e30baeeee2698a5eb6db0bd/library\std\src\io\mod.rs:1835
   7:     0x7ffec25c3976 - std::sys_common::backtrace::print
                               at /rustc/ada5e2c7b5427a591e30baeeee2698a5eb6db0bd/library\std\src\sys_common\backtrace.rs:34
   8:     0x7ffec25c6b58 - std::panicking::default_hook::closure$1
                               at /rustc/ada5e2c7b5427a591e30baeeee2698a5eb6db0bd/library\std\src\panicking.rs:271
   9:     0x7ffec25c6806 - std::panicking::default_hook
                               at /rustc/ada5e2c7b5427a591e30baeeee2698a5eb6db0bd/library\std\src\panicking.rs:298
   Compiling heck v0.4.1
  10:     0x7ffe74d38f5c - memchr
  11:     0x7ffec25c7187 - alloc::boxed::impl$50::call
                               at /rustc/ada5e2c7b5427a591e30baeeee2698a5eb6db0bd/library\alloc\src\boxed.rs:2077
  12:     0x7ffec25c7187 - std::panicking::rust_panic_with_hook
                               at /rustc/ada5e2c7b5427a591e30baeeee2698a5eb6db0bd/library\std\src\panicking.rs:799
  13:     0x7ffec25c7017 - std::panicking::begin_panic_handler::closure$0
                               at /rustc/ada5e2c7b5427a591e30baeeee2698a5eb6db0bd/library\std\src\panicking.rs:664
  14:     0x7ffec25c450f - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/ada5e2c7b5427a591e30baeeee2698a5eb6db0bd/library\std\src\sys_common\backtrace.rs:171
  15:     0x7ffec25c6cc8 - std::panicking::begin_panic_handler
                               at /rustc/ada5e2c7b5427a591e30baeeee2698a5eb6db0bd/library\std\src\panicking.rs:652
  16:     0x7ffec261e044 - core::panicking::panic_fmt
                               at /rustc/ada5e2c7b5427a591e30baeeee2698a5eb6db0bd/library\core\src\panicking.rs:72
  17:     0x7ffe73d67ba2 - rustc_mir_transform[13543b7e85fb979e]::mir_const_qualif
  18:     0x7ffe743d9d2f - rustc_query_impl[a9af4b4351cf17df]::plumbing::query_key_hash_verify_all
  19:     0x7ffe742cdc4a - rustc_ty_utils[8d4d8bc766452e30]::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
  20:     0x7ffe743de8d2 - rustc_query_impl[a9af4b4351cf17df]::plumbing::query_key_hash_verify_all
  21:     0x7ffe748d81cb - <rustc_metadata[be929f57b5661006]::rmeta::encoder::EncodeContext as rustc_span[8981518cc2cc525e]::SpanEncoder>::encode_symbol
  22:     0x7ffe737576ba - rustc_metadata[be929f57b5661006]::rmeta::encoder::encode_metadata
   Compiling unicode-properties v0.1.1
  23:     0x7ffe7375f678 - rustc_metadata[be929f57b5661006]::fs::encode_and_write_metadata
  24:     0x7ffe70bbc825 - rustc_interface[21cb2c8cfab351a0]::passes::start_codegen
  25:     0x7ffe70bc5ac0 - <rustc_interface[21cb2c8cfab351a0]::queries::Queries>::codegen_and_build_linker
  26:     0x7ffe70b74dde - _Nan_C
  27:     0x7ffe70b71f9f - _Nan_C
  28:     0x7ffe70b79df9 - _Nan_C
  29:     0x7ffec25d838d - alloc::boxed::impl$48::call_once
                               at /rustc/ada5e2c7b5427a591e30baeeee2698a5eb6db0bd/library\alloc\src\boxed.rs:2063
  30:     0x7ffec25d838d - alloc::boxed::impl$48::call_once
                               at /rustc/ada5e2c7b5427a591e30baeeee2698a5eb6db0bd/library\alloc\src\boxed.rs:2063
  31:     0x7ffec25d838d - std::sys::pal::windows::thread::impl$0::new::thread_start
                               at /rustc/ada5e2c7b5427a591e30baeeee2698a5eb6db0bd/library\std\src\sys\pal\windows\thread.rs:52
  32:     0x7fff43c7257d - BaseThreadInitThunk
  33:     0x7fff4552aa48 - RtlUserThreadStart

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please make sure that you have updated to the latest nightly

note: please attach the file at `C:\Users\dekak\.cargo\registry\src\index.crates.io-6f17d22bba15001f\windows-sys-0.48.0\rustc-ice-2024-06-01T10_31_22-52640.txt` to your bug report

note: compiler flags: --crate-type lib -C opt-level=3 -C embed-bitcode=no

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [mir_const_qualif] const checking `Windows::Win32::Storage::FileSystem::FILE_ATTRIBUTE_INTEGRITY_STREAM`
end of query stack

Other crates seem to install normally.

Crate manifest

No response

Crate code

No response

michalmoc commented 1 month ago

And it seems that sometimes (rarely) it passes. This is the most common error, but on random occasions I get errors from other crates, (with no explanation), and sometimes everythin works. No idea what is happening.

ChrisDenton commented 1 month ago

Can you report the nightly internal compiler error (ICE) to the rust repo, if you haven't already?

Also can you show some code that reproduces this? I've not been able to find a way to trigger the error.

michalmoc commented 1 month ago

I was just running cargo install sea-orm-cli, windows-sys is some dependency of it.

ChrisDenton commented 1 month ago

Ah, you should definitely report that to them. They'd be best placed to figure out the root cause.

riverar commented 1 month ago

Going to close this for now, but please do paste a link to your ICE report here so we can track it. And we can re-open this issue if the investigation points to the windows crate here doing something wrong.