slint-ui/slint · error · syn::Error

VTable cannot be mutable

Error message

VTable cannot be mutable

What it means

Error "VTable cannot be mutable" thrown in slint-ui/slint.

Source

Thrown at helper_crates/vtable/macro/macro.rs:313

                sig_extern.inputs.push(typed_arg.clone());

                // check for the vtable
                let ptr_target = match &param.ty {
                    Type::Ptr(TypePtr { mutability, elem, .. }) => {
                        Some((matches!(mutability, PointerMutability::Mut(_)), elem))
                    }
                    Type::Reference(TypeReference { mutability, elem, .. }) => {
                        Some((mutability.is_some(), elem))
                    }
                    _ => None,
                };
                if let Some((is_mut, elem)) = ptr_target
                    && let Type::Path(p) = &**elem
                    && let Some(pointer_to) = p.path.get_ident()
                    && pointer_to == &vtable_name
                {
                    if is_mut {
                        return Error::new(p.span(), "VTable cannot be mutable")
                            .to_compile_error()
                            .into();
                    }
                    if call_code.is_some() || !sig.inputs.is_empty() {
                        return Error::new(p.span(), "VTable pointer need to be the first")
                            .to_compile_error()
                            .into();
                    }
                    call_code = Some(quote!(vtable as _,));
                    continue;
                }

                let (is_pin, self_ty) = match is_pin(&param.ty) {
                    Some(t) => (true, t),
                    None => (false, &param.ty),
                };

                // check for self

View on GitHub (pinned to 3fd8f2ec03)

Solutions

  1. Remove the 'mut' qualifier from the vtable field.
  2. Access the vtable through an immutable reference.

When it happens

Trigger: Thrown at helper_crates/vtable/macro/macro.rs:313 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/a69cf6b31d10a98f. Report an issue: GitHub.