-
Notifications
You must be signed in to change notification settings - Fork 373
Bug nesting const generics #761
Copy link
Copy link
Closed
Description
The test case below generates broken C code.
// Propagating const arguments through generics that use generics.
#[repr(C)]
struct Inner<N: usize> {
bytes: [u8; N],
}
#[repr(C)]
struct Outer<N: usize> {
inner: Inner<N>, // don't declare two different structs named `Inner_N`
}
#[no_mangle]
pub extern "C" fn one() -> Outer<1> {
Outer { inner: Inner { bytes: [0] } }
}
#[no_mangle]
pub extern "C" fn two() -> Outer<2> {
Outer { inner: Inner { bytes: [0, 0] } }
}cargo run -- --lang c --style tag $FILE produces this:
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
struct Inner_N {
uint8_t bytes[N];
};
struct Outer_1 {
struct Inner_N inner;
};
struct Outer_2 {
struct Inner_N inner;
};
struct Outer_1 one(void);
struct Outer_2 two(void);The corresponding thing works fine with type parameters, so there must be something I failed to hook up in #759, or maybe we aren't modeling the value namespace at all. Filing the bug because I don't have time to look right now. I should have time in the next few days, though.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels