-
-
Notifications
You must be signed in to change notification settings - Fork 1
Labels
bugSomething isn't workingSomething isn't working
Description
The below function does not compile.
fn foo(f: impl Fn(i32) -> i32) {
// no-op
}
#[requires(true)]
fn bar() {
foo(|x: i32| {
if x < 0 {
return 0;
}
x
})
}Macro is expanded into the following code.
fn foo(f: impl Fn(i32) -> i32) {}
///# Contracts
///Pre-condition: `true`
///
fn bar() {
#[allow(clippy::nonminimal_bool)]
{
if !true {
{
::std::rt::panic_display(&"Pre-condition of bar violated: true");
}
}
}
let ret = 'run: {
foo(|x: i32| {
if x < 0 {
break 'run 0;
}
x
})
};
ret
}
}The reason is that, the return statement inside closure should not be replaced to break 'run.
I will post a fix soon.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working