Skip to content

Parse unsafe in attributes #1013

@Coekjan

Description

@Coekjan

See https://blog.rust-lang.org/2024/10/17/Rust-1.82.0.html#unsafe-attributes

Now attributes can contain unsafe, but cbindgen gives the following error:

ParseSyntaxError { crate_name: "...", src_path: "...", error: Error("expected identifier, found keyword `unsafe`") }

I think this issue could be urgent (should be done before edition 2024), because programmers, like me, may write:

#[unsafe(export_name = "xxx")]
pub fn f() {

}

Current rust stable (1.82.x) introduces this syntax and recommends us to add unsafe, while the old form (without unsafe) is still acceptable. But the old form will be a hard error in edition 2024.


This issue seems actually from upstream: dtolnay/syn#1710

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions