Skip to content

Conversation

@jonmeow
Copy link
Contributor

@jonmeow jonmeow commented Dec 11, 2025

This is in anticipation of using the same construct for all implementations of Destroy, as well as other similar use-cases with language-defined interfaces.

@jonmeow jonmeow requested a review from a team as a code owner December 11, 2025 21:09
@jonmeow jonmeow requested review from danakj and removed request for a team December 11, 2025 21:09
Copy link
Contributor

@danakj danakj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


// A witness synthesized for an arbitrary construct. For example, a `Destroy`
// witness, or a C++ overloaded operator.
struct CustomWitness {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe BuiltinWitness to explain its meaning and difference from a witness coming from carbon code a little more? And as opposed to "custom" as in user-customized.

Copy link
Contributor Author

@jonmeow jonmeow Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's user-customized similar to CustomLayoutType. That is, both tracking the mapping of user code (references to members of a type) in a particular layout that Carbon expects. Neither instruction is directly modified by users, but both track things in a way distinct from how more standard types/witnesses behave (and could in theory support arbitrary things, including the more standard Carbon equivalent).

Note too, there's not much builtin here:

  • The Destroy interface is user-defined.
  • For C++, it's a thin wrapper around a C++ destructor thunk.
    • Equivalent for other things, like copy, move, +, etc
  • For Carbon, it will eventually become a thin wrapper around a call to a vtable function for destroy.
    • Perhaps only copy, move as equivalents (not sure how far this will go)

@jonmeow jonmeow added this pull request to the merge queue Dec 15, 2025
@jonmeow jonmeow removed this pull request from the merge queue due to a manual request Dec 15, 2025
@jonmeow jonmeow enabled auto-merge December 15, 2025 18:50
@jonmeow jonmeow added this pull request to the merge queue Dec 15, 2025
Merged via the queue into carbon-language:trunk with commit 25f6314 Dec 15, 2025
8 checks passed
@jonmeow jonmeow deleted the custom-witness branch December 15, 2025 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants