Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions tools/hermes/tests/cases/success/repro_box_anyhow.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

///@ lean spec foo(x : U32)
///@ ensures |ret| ret.val = x.val
///@ proof
///@ simp [foo]
pub fn foo(x: u32) -> u32 {
x
Comment on lines +2 to +7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The foo function and its associated Lean annotations are duplicated across repro_box_anyhow.rs, repro_box_branch.rs, and repro_dyn_trait.rs. To improve maintainability and reduce redundancy, consider extracting this common helper into a shared test utility module if this pattern is expected to be used in more test cases.

}

pub fn trigger_box_error(fail: bool) -> Result<(), Box<dyn std::fmt::Debug>> {
let e = if fail {
Box::new("failed")
} else {
Box::new("succeeded")
};
if fail {
return Err(e);
}
Ok(())
}

fn main() {
let _ = foo(42);
let _ = trigger_box_error(true);
}
20 changes: 20 additions & 0 deletions tools/hermes/tests/cases/success/repro_box_branch.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
///@ lean spec foo(x : U32)
///@ ensures |ret| ret.val = x.val
///@ proof
///@ simp [foo]
pub fn foo(x: u32) -> u32 {
x
}

pub fn trigger_branch_box(cond: bool) -> Box<u32> {
if cond {
Box::new(1)
} else {
Box::new(2)
}
}

fn main() {
foo(42);
trigger_branch_box(true);
}
16 changes: 16 additions & 0 deletions tools/hermes/tests/cases/success/repro_dyn_trait.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
///@ lean spec foo(x : U32)
///@ ensures |ret| ret.val = x.val
///@ proof
///@ simp [foo]
pub fn foo(x: u32) -> u32 {
x
}

pub fn trigger_dyn_trait() {
let _x: Box<dyn std::fmt::Debug> = Box::new(42);
}

fn main() {
foo(42);
trigger_dyn_trait();
}
Loading