Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,8 @@ impl Struct {
) -> TokenStream {
// TODO (@Techassi): A bunch this stuff is duplicated in self.generate_tracking_from_impl.
// Ideally we remove that duplication.
let (impl_generics, type_generics, where_clause) = self.generics.split_for_impl();

let from_struct_ident = &self.common.idents.parameter;
let struct_ident = &self.common.idents.original;

Expand Down Expand Up @@ -521,8 +523,12 @@ impl Struct {
quote! {
#automatically_derived
#allow_attribute
impl ::core::convert::From<#from_module_ident::#struct_ident> for #for_module_ident::#struct_ident {
fn from(#from_struct_ident: #from_module_ident::#struct_ident) -> Self {
impl #impl_generics
::core::convert::From<#from_module_ident::#struct_ident #type_generics>
for #for_module_ident::#struct_ident #type_generics
#where_clause
{
fn from(#from_struct_ident: #from_module_ident::#struct_ident #type_generics) -> Self {
Self {
#fields
}
Expand Down
16 changes: 16 additions & 0 deletions crates/stackable-versioned-macros/tests/inputs/pass/generics.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use stackable_versioned::versioned;
// ---
#[versioned(version(name = "v1alpha1"), version(name = "v1alpha2"))]
// ---
pub(crate) mod versioned {
struct FooSpec<Bar, Baz>
where
Bar: Default,
Baz: Clone,
{
bar: Bar,
baz: Baz,
}
}
// ---
fn main() {}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/stackable-versioned-macros/tests/trybuild.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ mod inputs {
// mod docs;
// mod downgrade_with;
// mod enum_fields;
// mod generics;
// mod module;
// mod module_preserve;
// mod renamed_field;
Expand Down
Loading