Skip to content

ABIs are validated before cfg-ing #27873

Closed
@huonw

Description

@huonw

The ABI string for extern "..." is validated while being parsed, meaning one can get errors about in cfg'd off modules:

#[cfg(foo)]
mod foo {
    extern "foo" {}
}
<anon>:3:12: 3:17 error: illegal ABI: expected one of [cdecl, stdcall, fastcall, aapcs, win64, Rust, C, system, rust-intrinsic, rust-call], found `foo`
<anon>:3     extern "foo" {}
                    ^~~~~

(Compiled without --cfg foo.)

This isn't necessarily wrong, but it is weird and somewhat annoying if one needs it. (It can be worked-around by hiding the extern block behind a macro: macro_rules! annoying ( () => { extern "foo" {} }); annoying!().)

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-langRelevant to the language team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions