slint-ui/slint · error · syn::Error
The type of an #[field_offset] member in the vtable must be
Error message
The type of an #[field_offset] member in the vtable must be 'usize'
What it means
Error "The type of an #[field_offset] member in the vtable must be 'usize'" thrown in slint-ui/slint.
Source
Thrown at helper_crates/vtable/macro/macro.rs:588
items: Vec::new(),
..generated_trait.clone()
});
let const_type = if let Some(o) = field
.attrs
.iter()
.position(|a| a.path().get_ident().map(|a| a == "field_offset").unwrap_or(false))
{
let a = field.attrs.remove(o);
let member_type = match a.parse_args::<Type>() {
Err(e) => return e.to_compile_error().into(),
Ok(ty) => ty,
};
match &field.ty {
Type::Path(p) if p.path.get_ident().map(|i| i == "usize").unwrap_or(false) => {}
ty => {
return Error::new(
ty.span(),
"The type of an #[field_offset] member in the vtable must be 'usize'",
)
.to_compile_error()
.into();
}
}
// add `: Sized` to the trait in case it does not have it
if generated_trait_assoc_const.supertraits.is_empty() {
generated_trait_assoc_const.colon_token = Some(Default::default());
generated_trait_assoc_const.supertraits.push(parse_quote!(Sized));
}
let offset_type: Type = parse_quote!(vtable::FieldOffset<Self, #member_type>);
vtable_ctor.push(quote!(#ident: T::#ident.get_byte_offset(),));
View on GitHub (pinned to 3fd8f2ec03)
Solutions
- Change the #[field_offset] member type to usize.
- Store the offset value as usize.
When it happens
Trigger: Thrown at helper_crates/vtable/macro/macro.rs:588 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/9e8389801bc60756.
Report an issue: GitHub.