Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

UX Improvement: Ensures clause requires type annotation #3304

Closed
celinval opened this issue Jun 28, 2024 · 1 comment · Fixed by #3307
Closed

UX Improvement: Ensures clause requires type annotation #3304

celinval opened this issue Jun 28, 2024 · 1 comment · Fixed by #3307
Assignees
Labels
[C] Feature / Enhancement A new feature request or enhancement to an existing feature.

Comments

@celinval
Copy link
Contributor

Requested feature: Improve UX for ensure clauses.
Use case: Since #3207, ensures are now represented as closures that receive a reference of the return value. However, when using this annotation, we often get an error that requires the type to be specified.
Link to relevant documentation (Rust reference, Nomicon, RFC):

Test case:

#[kani::ensures(|result| *result == Foo::A)]
pub fn foo_a() -> Foo {
    Foo::A
}

I get the following compilation error:

error[E0282]: type annotations needed
  --> promoted_constants_enum.rs:16:18
   |
16 | #[kani::ensures(|result| *result == Foo::A)]
   |                  ^^^^^^  ------- type must be known at this point
   |
help: consider giving this closure parameter an explicit type
   |
16 | #[kani::ensures(|result: /* Type */| *result == Foo::A)]
@celinval celinval added the [C] Feature / Enhancement A new feature request or enhancement to an existing feature. label Jun 28, 2024
@pi314mm
Copy link
Contributor

pi314mm commented Jun 28, 2024

I think this might actually relate to this issue: rust-lang/rust#12679

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
[C] Feature / Enhancement A new feature request or enhancement to an existing feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants