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

Opaque extensions #1134

Merged
merged 17 commits into from
Dec 12, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Allow to make opaque (and drop body) of selected (non-trait) impl met…
…hods.
  • Loading branch information
maximebuyse committed Dec 5, 2024
commit ef18a4ff2b82b814e7877c65c8b8fc02a930af6e
11 changes: 8 additions & 3 deletions engine/lib/import_thir.ml
Original file line number Diff line number Diff line change
@@ -1456,10 +1456,11 @@ and c_item_unwrapped ~ident ~type_only (item : Thir.item) : item list =
else
let span = Span.of_thir item.span in
let attrs = c_item_attrs item.attributes in
let erased_by_user =
let erased_by_user attrs =
Attr_payloads.payloads attrs
|> List.exists ~f:(fst >> [%matches? (Erased : Types.ha_payload)])
in
let item_erased_by_user = erased_by_user attrs in
let erased_by_type_only =
type_only
&&
@@ -1473,11 +1474,11 @@ and c_item_unwrapped ~ident ~type_only (item : Thir.item) : item list =
| _ -> false
in
let attrs =
if erased_by_type_only && not erased_by_user then
if erased_by_type_only && not item_erased_by_user then
Attr_payloads.to_attr Erased span :: attrs
else attrs
in
let erased = erased_by_user || erased_by_type_only in
let erased = item_erased_by_user || erased_by_type_only in

let mk_one v = { span; v; ident; attrs } in
let mk v = [ mk_one v ] in
@@ -1657,6 +1658,10 @@ 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)
in
let c_body = if sub_item_erased then c_expr_drop_body else c_body in

let v =
match (item.kind : Thir.impl_item_kind) with