Skip to content

Commit

Permalink
Improve inference of Ghost when erased
Browse files Browse the repository at this point in the history
  • Loading branch information
xldenis committed Nov 1, 2023
1 parent 338c7e7 commit ce248c7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion creusot-contracts-dummy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub fn proof_assert(_: TS1) -> TS1 {

#[proc_macro]
pub fn gh(_: TS1) -> TS1 {
quote::quote! { creusot_contracts::ghost::Ghost::dummy() }.into()
quote::quote! { creusot_contracts::ghost::Ghost::from_fn(|| unsafe { std::hint::unreachable_unchecked() }) }.into()
}

#[proc_macro_attribute]
Expand Down
4 changes: 2 additions & 2 deletions creusot-contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,14 @@ pub mod ghost {
T: ?Sized;

impl<T: ?Sized> Ghost<T> {
pub fn dummy() -> Ghost<T> {
pub fn from_fn(_: fn() -> T) -> Self {
Ghost(std::marker::PhantomData)
}
}

impl<T: ?Sized> Clone for Ghost<T> {
fn clone(&self) -> Self {
Self::dummy()
Ghost(std::marker::PhantomData)
}
}

Expand Down

0 comments on commit ce248c7

Please sign in to comment.