DioxusLabs/dioxus · error

Unsupported reference type

Error message

Unsupported reference type

What it means

`ForeignType::from_type` errors when a reference type in an FFI signature is not `&str` or a single-segment opaque type reference. Any other `&T` used in a Swift/Kotlin bridge function is rejected at compile time; the unsupported reference type is at fault.

Solutions

  1. Remove the reference and pass the value directly, or use a supported reference type; arbitrary reference types are not supported across the FFI boundary.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/manganis/manganis-macro/src/ffi.rs:119 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of DioxusLabs/dioxus@24f6a829df (2026-08-23). Data as JSON: /api/errors/2003fa0b65c0adf1. Report an issue: GitHub.

Appendix: source

Thrown at packages/manganis/manganis-macro/src/ffi.rs:119

                        _ => {
                            // Assume it's an opaque type reference
                            return Ok(ForeignType::OpaqueRef(segment.ident.clone()));
                        }
                    }
                }
                Err(syn::Error::new(ty.span(), "Unsupported type path"))
            }
            Type::Reference(type_ref) => {
                if let Type::Path(path) = &*type_ref.elem {
                    if path.path.is_ident("str") {
                        return Ok(ForeignType::StrRef);
                    }
                    // Check for &OpaqueType
                    if path.path.segments.len() == 1 {
                        return Ok(ForeignType::OpaqueRef(path.path.segments[0].ident.clone()));
                    }
                }
                Err(syn::Error::new(ty.span(), "Unsupported reference type"))
            }
            Type::Tuple(tuple) if tuple.elems.is_empty() => Ok(ForeignType::Unit),
            _ => Err(syn::Error::new(ty.span(), "Unsupported type")),
        }
    }

    /// Get the JNI signature for this type
    fn jni_signature(&self) -> String {
        match self {
            ForeignType::Bool => "Z".into(),
            ForeignType::I8 => "B".into(),
            ForeignType::I16 => "S".into(),
            ForeignType::I32 => "I".into(),
            ForeignType::I64 => "J".into(),
            ForeignType::U8 => "B".into(), // JNI doesn't have unsigned, use signed
            ForeignType::U16 => "S".into(),
            ForeignType::U32 => "I".into(),
            ForeignType::U64 => "J".into(),

View on GitHub (pinned to 24f6a829df)