Skip emitting a transposed type if the original type is entirely generic (#4838)

* Skip transposed type if the type is generic

* fix clippy
This commit is contained in:
Evan Almloff authored and GitHub committed 2025-10-27 12:37:02 -07:00
1 parent e4297d0e09
commit 9b52aa6607
2 files changed
+192 -31

No files matched your search

+38
View File
@@ -138,6 +138,20 @@ mod macro_tests {
store.check();
}
fn derive_generic_struct_transposed_passthrough() {
#[derive(Store)]
struct Item<const COUNT: usize, T> {
contents: T,
}
let mut store = use_store(|| Item::<0, _> {
contents: "Learn about stores".to_string(),
});
let Item { contents } = store.transpose();
let contents: String = contents();
}
fn derive_tuple() {
#[derive(Store, PartialEq, Clone, Debug)]
struct Item(bool, String);
@@ -342,4 +356,28 @@ mod macro_tests {
}
}
}
fn derive_generic_enum_transpose_passthrough() {
#[derive(Store, PartialEq, Clone, Debug)]
#[non_exhaustive]
enum Enum<const COUNT: usize, T> {
Foo,
Bar(T),
BarFoo { foo: T },
}
let mut store = use_store(|| Enum::<0, _>::Bar("Hello".to_string()));
let transposed = store.transpose();
use Enum::*;
match transposed {
Enum::Foo => {}
Bar(bar) => {
let bar: String = bar();
}
BarFoo { foo } => {
let foo: String = foo();
}
}
}
}