mozilla / uniffi-rs

a multi-language bindings generator for rust
https://mozilla.github.io/uniffi-rs/
Mozilla Public License 2.0
2.7k stars 224 forks source link

#[doc = ...] fails to parse with uniffi attribute macros #2134

Open notmgsk opened 4 months ago

notmgsk commented 4 months ago

This does not work

#[doc = std::concat!("A", "has a", "B")]
#[derive(uniffi::Enum)]
pub enum A {
    B,
}

but this does (without the derive)

#[doc = std::concat!("C", "has a", "D")]
pub enum C {
    D,
}

and this also works (using only a trivial string for the doc)

#[doc = "A has a B"]
#[derive(uniffi::Enum)]
pub enum A {
    B,
}
BatmanAoD commented 4 months ago

This works in 0.26, but is broken in 0.27.

badboy commented 3 months ago

Note: "does not work" is usually not very helpful. If you can it's always helpful to include the full error message you get.

badboy commented 3 months ago

The test I add in #2154 also fails on 0.26.

Doc string parsing first appeared in 0.26 here:

https://github.com/mozilla/uniffi-rs/blob/cd38ccea8236df7d93aff336c325a3a8e524af5d/uniffi_macros/src/util.rs#L295-L301

So yeah, that never worked since we added that.