Skip to content

Commit

Permalink
Remove body of methods inside impls in type-only mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
maximebuyse committed Nov 28, 2024
1 parent 77fdfd0 commit 6c474ff
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions engine/lib/import_thir.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1478,11 +1478,14 @@ and c_item_unwrapped ~ident ~type_only (item : Thir.item) : item list =
in
(* If the item is erased in type-only mode we need to add the Erased attribute.
It is already present if the item is erased by user. *)
let attrs =
if erased_by_type_only && not item_erased_by_user then
let attrs_with_erased erased_by_type_only erased_by_user attrs =
if erased_by_type_only && not erased_by_user then
Attr_payloads.to_attr Erased span :: attrs
else attrs
in
let attrs =
attrs_with_erased erased_by_type_only item_erased_by_user attrs
in
let erased = item_erased_by_user || erased_by_type_only in

let mk_one v = { span; v; ident; attrs } in
Expand Down Expand Up @@ -1663,8 +1666,11 @@ and c_item_unwrapped ~ident ~type_only (item : Thir.item) : item list =
List.map
~f:(fun (item : Thir.impl_item) ->
let item_def_id = Concrete_ident.of_def_id Impl item.owner_id in
let sub_item_erased =
erased_by_user (c_item_attrs item.attributes)
let attrs = c_item_attrs item.attributes in
let sub_item_erased_by_user = erased_by_user attrs in
let sub_item_erased = sub_item_erased_by_user || type_only in
let attrs =
attrs_with_erased type_only sub_item_erased_by_user attrs
in
let c_body = if sub_item_erased then c_expr_drop_body else c_body in

Expand Down Expand Up @@ -1702,7 +1708,6 @@ and c_item_unwrapped ~ident ~type_only (item : Thir.item) : item list =
(https://doc.rust-lang.org/reference/items/implementations.html#inherent-implementations)."
in
let ident = Concrete_ident.of_def_id Value item.owner_id in
let attrs = c_item_attrs item.attributes in
{ span = Span.of_thir item.span; v; ident; attrs })
items
| Impl
Expand Down

0 comments on commit 6c474ff

Please sign in to comment.