Skip to content

Commit

Permalink
Filter out erased impls for coq.
Browse files Browse the repository at this point in the history
  • Loading branch information
maximebuyse committed Dec 12, 2024
1 parent 001b07b commit a22203a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
21 changes: 13 additions & 8 deletions engine/backends/coq/coq/coq_backend.ml
Original file line number Diff line number Diff line change
Expand Up @@ -407,14 +407,19 @@ struct
method item'_Impl ~super ~generics ~self_ty ~of_trait ~items
~parent_bounds:_ ~safety:_ =
let name, args = of_trait#v in
CoqNotation.instance
(name#p ^^ string "_" ^^ string (Int.to_string ([%hash: item] super)))
generics#p []
(name#p ^^ concat_map (fun x -> space ^^ parens x#p) args)
(braces
(nest 2
(concat_map (fun x -> break 1 ^^ name#p ^^ !^"_" ^^ x#p) items)
^^ break 1))
if Attrs.is_erased super.attrs then empty
else
CoqNotation.instance
(name#p ^^ string "_"
^^ string (Int.to_string ([%hash: item] super)))
generics#p []
(name#p ^^ concat_map (fun x -> space ^^ parens x#p) args)
(braces
(nest 2
(concat_map
(fun x -> break 1 ^^ name#p ^^ !^"_" ^^ x#p)
items)
^^ break 1))

method item'_NotImplementedYet = string "(* NotImplementedYet *)"

Expand Down
6 changes: 1 addition & 5 deletions engine/backends/fstar/fstar_backend.ml
Original file line number Diff line number Diff line change
Expand Up @@ -875,11 +875,7 @@ struct
| `VerbatimIntf of string * [ `NoNewline | `Newline ]
| `Comment of string ]
list =
let is_erased =
Attrs.find_unique_attr e.attrs
~f:([%eq: Types.ha_payload] Erased >> Fn.flip Option.some_if ())
|> Option.is_some
in
let is_erased = Attrs.is_erased e.attrs in
let erased_impl name ty attrs binders =
let name' = F.id_prime name in
let pat = F.AST.PatVar (name, None, []) in
Expand Down
5 changes: 5 additions & 0 deletions engine/lib/attr_payloads.ml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ module MakeBase (Error : Phase_utils.ERROR) = struct
let late_skip : attrs -> bool =
status >> [%matches? Types.Included { late_skip = true }]

let is_erased : attrs -> bool =
find_unique_attr
~f:([%eq: Types.ha_payload] Erased >> Fn.flip Option.some_if ())
>> Option.is_some

let uid : attrs -> UId.t option =
let f = function Types.Uid uid -> Some (UId.of_raw uid) | _ -> None in
find_unique_attr ~f
Expand Down
6 changes: 6 additions & 0 deletions test-harness/src/snapshots/toolchain__literals into-coq.snap
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ Definition patterns (_ : unit) : unit :=
end in
tt.







Definition panic_with_msg (_ : unit) : unit :=
never_to_any (panic_fmt (impl_2__new_const (["with msg"%string]))).

Expand Down

0 comments on commit a22203a

Please sign in to comment.