Skip to content
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

Avoid sending errors for what is inside an opaque type #982

Open
maximebuyse opened this issue Oct 9, 2024 · 0 comments
Open

Avoid sending errors for what is inside an opaque type #982

maximebuyse opened this issue Oct 9, 2024 · 0 comments
Labels
bug Something isn't working engine Issue in the engine

Comments

@maximebuyse
Copy link
Contributor

When an opaque type contains something that is rejected by hax, we produce an error but we could very well keep it as we are supposed to ignore what is inside anyway.

Example:

#[hax_lib::opaque_type]
pub(crate) struct Pimpl< T> {
    p: fn(*mut T),

}

produces:

(* item error backend: (reject_RawOrMutPointer) ExplicitRejection { reason: "a node of kind [Raw_pointer] have been found in the AST" }
Last available AST for this item:

#[_hax::json("\"OpaqueType\"")]
#[feature(register_tool)]
#[register_tool(_hax)]
struct t_Pimpl<T>
where
    _: core::marker::t_Sized<T>,
{
    f_p: arrow!(raw_pointer!() -> tuple0),
}


Last AST:
/** print_rust: pitem: not implemented  (item: { Concrete_ident.T.def_id =
  { Concrete_ident.Imported.krate = "opaque_type";
    path =
    [{ Concrete_ident.Imported.data =
       (Concrete_ident.Imported.TypeNs "Pimpl"); disambiguator = 0 }
      ]
    };
  kind = Concrete_ident.Kind.Value }) */
const _: () = ();
 *)

and could produce instead:

val t_Pimpl (#v_T: Type0) : Type0

Here is a possible design:
When importing THIR to the hax AST, if a type is opaque, replace its list of variants by a single variant (with a dummy name) containing a hax_lib type (that we would be adding). This should be removed anyway by the backend but should make debugging easier in case we see it somewhere.

@franziskuskiefer franziskuskiefer added bug Something isn't working engine Issue in the engine labels Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working engine Issue in the engine
Projects
None yet
Development

No branches or pull requests

2 participants