Skip to content

Future Rust change to assert! will cause compile error of one of your tests #106

@estebank

Description

@estebank

In the Rust Project, we are considering changing the desugaring of the assert! macro to provide better diagnostics when using the wrong type for the first argument. This change changes the desugaring from if !cond { panic!() } to match cond { false => panic!(), true => {} }. This change causes a change in the way type inference flows when a condition is negated (assert!(!foo)), which affects your crate:

[INFO] [stderr]     Checking rust_java v0.0.1 (/opt/rustwide/workdir)
[INFO] [stdout] error[E0282]: type annotations needed
[INFO] [stdout]   --> java_runtime/tests/classes/java/util/jar/test_jar_file.rs:63:18
[INFO] [stdout]    |
[INFO] [stdout] 63 |     assert!(!jvm.invoke_virtual(&entries, "hasMoreElements", "()Z", ()).await?);
[INFO] [stdout]    |                  ^^^^^^^^^^^^^^ cannot infer type of the type parameter `U` declared on the method `invoke_virtual`
[INFO] [stdout]    |
[INFO] [stdout] help: consider specifying the generic arguments
[INFO] [stdout]    |
[INFO] [stdout] 63 |     assert!(!jvm.invoke_virtual::<(), U>(&entries, "hasMoreElements", "()Z", ()).await?);
[INFO] [stdout]    |                                +++++++++

I believe all that you'd need to change in your code is make the above

    |
 63 |     assert!(!jvm.invoke_virtual::<(), bool>(&entries, "hasMoreElements", "()Z", ()).await?);
    |                                ++++++++++++

The change upstream hasn't been merged yet, but we're giving you as much of a heads up as possible that this might be happening.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions