Skip to content

Various nonsense error messages with assert_eq on windows #1532

Closed as duplicate of#1567
@tbeckley

Description

@tbeckley

Hi guys,

Apologies if this is a dupe, I searched but couldn't find anything. Big GUI project here and have been playing around with using cranelift to improve compile times. When running my tests on windows, any failing assert_eq!() will trigger nonsensical error messages as opposed to the correct error message about a failing assertion. Minimal example:

fn main() {
    println!("Hello, world!");
}
#[cfg(test)]
mod tests {
    #[test]
    fn test_panics() {
        assert_eq!(4, 5, "not equal");
    }
}

cargo.toml:

cargo-features = ["codegen-backend"]

[package]
name = "panic_test"
version = "0.1.0"
edition = "2021"

[profile.dev]
codegen-backend = "cranelift"

[dependencies]

Error message when using cranelift:

C:\Users\tbeckley...\Documents\code\panic_test>cargo test
Finished test profile [unoptimized + debuginfo] target(s) in 0.05s
Running unittests src/main.rs (target\debug\deps\panic_test-58a397beba7a73c1.exe)

running 1 test
error: test failed, to rerun pass --bin panic_test

Caused by:
process didn't exit successfully: C:\Users\tbeckley\...\Documents\code\panic_test\target\debug\deps\panic_test-58a397beba7a73c1.exe (exit code: 0xe06d7363)
note: test exited abnormally; to see the full output pass --nocapture to the harness.

And without cranelift:

C:\Users\tbeckley...\Documents\code\panic_test>cargo test
Compiling panic_test v0.1.0 (C:\Users\tbeckley...\Documents\code\panic_test)
Finished test profile [unoptimized + debuginfo] target(s) in 0.36s
Running unittests src/main.rs (target\debug\deps\panic_test-36ac1adaeb9d3e34.exe)

running 1 test
test tests::test_panics ... FAILED

failures:

---- tests::test_panics stdout ----
thread 'tests::test_panics' panicked at src/main.rs:9:9:
assertion left == right failed: not equal
left: 4
right: 5
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

failures:
tests::test_panics

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

error: test failed, to rerun pass --bin panic_test

I've also seen errors for memory access violation and stack overflows.

Result of rustup show:

Default host: x86_64-pc-windows-msvc
rustup home:  C:\Users\tbeckley\.rustup

installed toolchains
--------------------

stable-x86_64-pc-windows-msvc (default)
nightly-x86_64-pc-windows-msvc

active toolchain
----------------

nightly-x86_64-pc-windows-msvc (overridden by 'C:\Users\tbeckley\...\Documents\code\panic_test\rust-toolchain.toml')
rustc 1.83.0-nightly (c52c23b6f 2024-09-16)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions