Skip to content

Add a bit to pointer types to decide if they should be CRef/CMut.#774

Merged
copybara-service[bot] merged 1 commit intomainfrom
test_890517999
Mar 28, 2026
Merged

Add a bit to pointer types to decide if they should be CRef/CMut.#774
copybara-service[bot] merged 1 commit intomainfrom
test_890517999

Conversation

@copybara-service
Copy link
Copy Markdown

Add a bit to pointer types to decide if they should be CRef/CMut.

This is not a new PointerTypeKind because it's a Rust-side
representation decision. Right now we're aiming to lower
LValueRef in output positions to CRef/CMut, but in the future we
may also want to lower NonNull. (These require us to generate
slightly different code on the C++ side.)

Making this a property of the pointer type reduces the state we
need to carry around later on, as the decision to use CRef vs const&
again depends on the semantic location of the reference.
(It's kind of clear when you think about returns vs parameters, but
this becomes more complicated when we consider function types.)

This is not a new PointerTypeKind because it's a Rust-side
representation decision. Right now we're aiming to lower
LValueRef in output positions to CRef/CMut, but in the future we
may also want to lower NonNull. (These require us to generate
slightly different code on the C++ side.)

Making this a property of the pointer type reduces the state we
need to carry around later on, as the decision to use CRef vs const&
again depends on the semantic location of the reference.
(It's kind of clear when you think about returns vs parameters, but
this becomes more complicated when we consider function types.)

PiperOrigin-RevId: 890766422
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant