slint-ui/slint · error · syn::Error
Only `struct` with named field are supported
Error message
Only `struct` with named field are supported
What it means
Error "Only `struct` with named field are supported" thrown in slint-ui/slint.
Source
Thrown at internal/core-macros/lib.rs:29
use proc_macro::TokenStream;
use quote::quote;
mod slint_doc;
/// This derive macro is used with structures in the run-time library that are meant
/// to be exposed to the language. The structure is introspected for properties and fields
/// marked with the `rtti_field` attribute and generates run-time type information for use
/// with the interpreter.
/// In addition all `Property<T> foo` fields get a convenient getter function generated
/// that works on a `Pin<&Self>` receiver.
#[proc_macro_derive(SlintElement, attributes(rtti_field))]
pub fn slint_element(input: TokenStream) -> TokenStream {
let input = syn::parse_macro_input!(input as syn::DeriveInput);
let fields = match &input.data {
syn::Data::Struct(syn::DataStruct { fields: f @ syn::Fields::Named(..), .. }) => f,
_ => {
return syn::Error::new(
input.ident.span(),
"Only `struct` with named field are supported",
)
.to_compile_error()
.into();
}
};
let mut pub_prop_field_names = Vec::new();
let mut pub_prop_field_names_normalized = Vec::new();
let mut pub_prop_field_types = Vec::new();
let mut property_names = Vec::new();
let mut property_visibility = Vec::new();
let mut property_types = Vec::new();
for field in fields {
if let Some(property_type) = property_type(&field.ty) {
let name = field.ident.as_ref().unwrap();View on GitHub (pinned to 3fd8f2ec03)
Solutions
- Use a struct with named fields with this macro.
- Convert tuple structs into named-field structs.
When it happens
Trigger: Thrown at internal/core-macros/lib.rs:29 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of slint-ui/slint@3fd8f2ec03 (2026-08-19).
Data as JSON: /api/errors/62268eda2a7ed337.
Report an issue: GitHub.