Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
notmgsk opened this issue May 29, 2024 · 3 comments
Open

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

notmgsk opened this issue May 29, 2024 · 3 comments

Comments

@notmgsk
Copy link

notmgsk commented May 29, 2024

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
Copy link

This works in 0.26, but is broken in 0.27.

@badboy
Copy link
Member

badboy commented Jun 17, 2024

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
Copy link
Member

badboy commented Jun 17, 2024

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

Doc string parsing first appeared in 0.26 here:

let name_value = attr.meta.require_name_value()?;
if let Expr::Lit(expr) = &name_value.value {
if let Lit::Str(lit_str) = &expr.lit {
return Ok(lit_str.value().trim().to_owned());
}
}
Err(syn::Error::new_spanned(attr, "Cannot parse doc attribute"))

So yeah, that never worked since we added that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants