Skip to content

Commit cbc0fe1

Browse files
Modify Derive to allow unit structs for RenderResources. (#1089)
1 parent acc29ec commit cbc0fe1

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

crates/bevy_derive/src/render_resources.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ use crate::modules::{get_modules, get_path};
22
use proc_macro::TokenStream;
33
use quote::{format_ident, quote};
44
use syn::{
5-
parse::ParseStream, parse_macro_input, Data, DataStruct, DeriveInput, Field, Fields, Path,
5+
parse::ParseStream, parse_macro_input, punctuated::Punctuated, Data, DataStruct, DeriveInput,
6+
Field, Fields, Path,
67
};
78

89
#[derive(Default)]
@@ -72,11 +73,17 @@ pub fn derive_render_resources(input: TokenStream) -> TokenStream {
7273
}
7374
})
7475
} else {
76+
let empty = Punctuated::new();
77+
7578
let fields = match &ast.data {
7679
Data::Struct(DataStruct {
7780
fields: Fields::Named(fields),
7881
..
7982
}) => &fields.named,
83+
Data::Struct(DataStruct {
84+
fields: Fields::Unit,
85+
..
86+
}) => &empty,
8087
_ => panic!("Expected a struct with named fields."),
8188
};
8289
let field_attributes = fields

examples/shader/mesh_custom_attribute.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn main() {
2121

2222
#[derive(RenderResources, Default, TypeUuid)]
2323
#[uuid = "0320b9b8-b3a3-4baa-8bfa-c94008177b17"]
24-
struct MyMaterialWithVertexColorSupport {}
24+
struct MyMaterialWithVertexColorSupport;
2525

2626
const VERTEX_SHADER: &str = r#"
2727
#version 450

0 commit comments

Comments
 (0)