Fix deriving with generic const arguments in GCC Rust
Correctly handles constant generic arguments during derive macro expansion in GCC Rust.
This commit addresses an issue in the GCC Rust compiler related to deriving macros when constant generic arguments are involved. It ensures that a constant generic argument is correctly created from a constant generic parameter, allowing derive macros to function properly in such cases. The change primarily affects the type checking phase, and a new test case is included.
In Details
The DeriveVisitor::setup_impl_generics function now correctly instantiates a constant generic argument from a constant generic parameter in rust-derive.cc. This resolves a compilation issue where derive macros might fail when processing types with constant generics. The provided test case focuses on compilation up to typechecking.
- Derive macro
- A type of Rust macro that automatically generates implementations for traits (like
Debug,Clone, etc.) for a given struct or enum. It's invoked using#[derive(...)]. - Generic const argument
- In Rust, a compile-time constant value that can be used as a parameter for generic types or functions. For example,
[T; N]whereNis a const generic argument. - Type checking
- The process by which a compiler verifies that the types of values used in an expression or statement are compatible and adhere to the language's type rules.