Skip to content

Regression: uniffi_foreign_handle method is needed in user code for UDL defined traits. #2829

Closed

Description

@jhugman

UDL-defined interfaces [Trait] / [Trait, WithForeign] require a manual uniffi_foreign_handle default method, but #[uniffi::export(with_foreign)] adds it automatically.

They should behave the same way.

This is adding:

    #[doc(hidden)]
    fn uniffi_foreign_handle(&self) -> Option<uniffi::Handle> {
        None
    }

for each UDL trait.

I don't think this is affecting the mozilla/application-services repo as all UDL files where these annotations are being used seem to also using #[uniffi::trait_interface].

Activity

  1. bendk commented on Feb 24, 2026

    @bendk
    Contributor

    Wrapping the traits with #[uniffi::trait_interface] is the official new way (https://mozilla.github.io/uniffi-rs/latest/types/interfaces.html#udl). We should probably update the UDL section of the docs to explain this as well.

    I don't love that you need to also use a macro when you're using UDL, but I couldn't figure any other way to do what we needed. Would adding #[uniffi::trait_interface] work for you or is there a bigger issue here?

  2. jhugman commented on Feb 25, 2026

    @jhugman
    ContributorAuthor

    It's right there on the first llne of the CHANGELOG. Apologies.

    Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions