-
Notifications
You must be signed in to change notification settings - Fork 14k
Remove 'static bound on contract ensures closure
#148595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Remove 'static bound on contract ensures closure
#148595
Conversation
|
r? @davidtwco rustbot has assigned @davidtwco. Use |
This comment has been minimized.
This comment has been minimized.
The `'static` bound on the closure of `build_check_ensures` prevented some patterns of contracts from type checking, without a clear reason for doing so. As such, this change removes the `'static` bound.
857b066 to
75caeab
Compare
| | ^^^^^^^^^ | ||
| | | ||
| = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information | ||
| = note: `#[warn(incomplete_features)]` on by default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you may add #![allow(incomplete_features)] to suppress this warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing this out! So far all the other contract UI tests have included this warning in the stderr, so I followed that pattern.
|
Brilliant, this will enable adding a lot more contracts that #147148 currently has commented out. |
|
@dawidl022, I don't recall why the build ensures had 'static. I can see if I can find my notes when @pnkfelix handed contacts over to me. |
|
✌️ @celinval, you can now approve this pull request! If @davidtwco told you to " |
The
'staticbound on the closure ofbuild_check_ensuresprevented some patterns of contracts from type checking, without a clear reason for doing so. As such, this change removes the'staticbound.While working on the proposal for
ownedandblockfor contracts, I came across a pattern that was rejected by type checker while attempting to specifystd::ptr::write:Eventually, I was able to track down the issue to a trait bound in
core::contracts::build_check_ensures, which puts a'staticbound on theensuresclosure. Remvoing the'staticbound allows the above contract to type-check, and additionally removes the need for themovein theensuresclosure.I have reduced the problem down to some minimal reproducible examples, which I included as part of this change as regression tests. The error messages for the regression tests before the change were as follows:
@celinval are you aware of any reason why the
'staticbound was put onbuild_check_ensuresin the first place?I have checked that the contracts in #136578 and #147148 still type check with this change.
Contracts tracking issue: #128044