Skip to content

Order of extern and unsafe is backwards in trait definitions and impls #19398

@ftxqxd

Description

@ftxqxd
trait Foo {
    extern "Rust" unsafe fn foo();
}

impl Foo for () {
    extern "Rust" unsafe fn foo() {}
}

unsafe extern "Rust" fn foo() {}

fn main() {}

Here unsafe comes after extern in the Foo’s definition and implementation, but it comes before in the extern in the top-level function foo. I think foo’s order seems the most natural (and would be the most common use anyway), so I would assume that it has the intended order.

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