Skip to content

Make CRUBIT_INTERNAL_RUST_TYPE accept trailing type arguments.#569

Open
copybara-service[bot] wants to merge 1 commit intomainfrom
test_876372938
Open

Make CRUBIT_INTERNAL_RUST_TYPE accept trailing type arguments.#569
copybara-service[bot] wants to merge 1 commit intomainfrom
test_876372938

Conversation

@copybara-service
Copy link

@copybara-service copybara-service bot commented Feb 27, 2026

Make CRUBIT_INTERNAL_RUST_TYPE accept trailing type arguments.

Example:

CRUBIT_INTERNAL_RUST_TYPE("Foo", T)

Right now, this just replaces the default behavior of ExistingRustType.template_args, which used to just be a list with 1:1 correspondence with the order of the template args on the type. After this change, that list now corresponds to the types that are put in the list. A concrete example of this change is that rs_std::SliceRef now uses the new annotation syntax:

// old
CRUBIT_INTERNAL_RUST_TYPE("&[]")

// new
CRUBIT_INTERNAL_RUST_TYPE("&[]", T)

This also begins (but does not complete) supporting const generics. By writing crubit::const_generic<N> instead of a type like so:

CRUBIT_INTERNAL_RUST_TYPE("Foo", crubit::const_generic<123>)

It will go into the template_args list as a TemplateArg::Int instead of a TemplateArg::Type. Boolean literals are also supported.

@google-cla
Copy link

google-cla bot commented Feb 27, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Example:
```cpp
CRUBIT_INTERNAL_RUST_TYPE("Foo", T)
```

Right now, this just replaces the default behavior of `ExistingRustType.template_args`, which used to just be a list with 1:1 correspondence with the order of the template args on the type. After this change, that list now corresponds to the types that are put in the list. A concrete example of this change is that `rs_std::SliceRef` now uses the new annotation syntax:

```cpp
// old
CRUBIT_INTERNAL_RUST_TYPE("&[]")

// new
CRUBIT_INTERNAL_RUST_TYPE("&[]", T)
```

This also begins (but does not complete) supporting const generics. By writing `crubit::const_generic<N>` instead of a type like so:

```cpp
CRUBIT_INTERNAL_RUST_TYPE("Foo", crubit::const_generic<123>)
```

It will go into the `template_args` list as a `TemplateArg::Int` instead of a `TemplateArg::Type`. Boolean literals are also supported.

PiperOrigin-RevId: 876372938
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.

0 participants