You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before this commit `NamedImplKey` could only represent the inner type as
`rust: &'a Ident`. For example, it could represent `Vec<Foo>` but could
not represent `Vec<Box<Foo>>` where the inner type (`Box<Foo>` in our
example) is not a simple identifier.
After this commit `NamedImplKey` is refactored to support an arbitrary
inner type. Note that (to simplify and to minimize risks associated
with this commit) this new ability is not actually used at this point -
it is planned to be used in follow-up commits to incrementally relax
generic type argument restrictions in `syntax/check.rs`.
This commit is quite big, but it seems difficult to extract some changes
to smaller, separate commits, because all of the changes stem from the
refactoring of the `NamedImplKey`. At a high-level this commit contains
the following changes:
1. `syntax/instantiate.rs`: Changing `pub rust: &'a Ident` field of
`NamedImplKey` to `pub inner: &'a Type`. This is the main/root
change in this commit.
2. `gen/src/write.rs`: supporting arbitrary inner types
when writing C++ thunks exposing instantiations/monomorphizations of
templates/generics supported by `cxx`.
* This depends on `fn stringify_type` introduced in
`gen/src/write.rs` in an earlier commit.
* Handling arbitrary inner types *in general* means that we can
delete `enum UniquePtr` which provided handling of two *specific*
inner types.
3. `macro/src/expand.rs`: supporting arbitrary inner types
when writing Rust thunks exposing instantiations/monomorphizations of
templates/generics supported by `cxx`.
* Using `#inner` instead of `#ident` may now (optionally) cover
generic lifetime arguments. This is why this commit also changes
`macro/src/generics.rs`. And this is why we can no longer need
the `ty_generics` field from `struct Impl`.
* One minor functional change here is changing the error messages
so that references to type names are generated purely in the
generated bindings, without depending on `fn display_namespaced`.
4. `syntax/mangle.rs`: supporting mangling of individual types. This
helps to:
* Support the (long-term, not-yet-realized) high-level goal of
actually allowing and using arbitrary inner types
* Deduplicate mangling code details that were somewhat duplicated
in `macro/src/expand.rs` and `gen/src/write.rs`.
5. `syntax/types.rs`: Supporting arbitrary inner types in
* `fn is_maybe_trivial`
* `fn is_local` (this function supports an earlier refactoring
that changed how `cxx` decides whether to provide an *implicit*
impl of a given generic/template instantiation/monomorphization)
0 commit comments