-
Notifications
You must be signed in to change notification settings - Fork 913
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
Allow arbitrary extern ABI #4086
Comments
I cannot reproduce this. Could you tell me the version you use? |
I guess the error message was from the rustfmt that ships with stable 1.42, but after trying it with today's rustfmt master branch (9124dd8) the current behavior is even worse; it silently replaces the ABI with "Rust". $ echo '#[cfg(any())] extern "C++" {}' | rustup run 1.42.0 rustfmt
error[E0703]: invalid ABI: found `C++`
--> <stdin>:1:22
|
1 | #[cfg(any())] extern "C++" {}
| ^^^^^ invalid ABI
|
= help: valid ABIs: cdecl, stdcall, fastcall, vectorcall, thiscall, aapcs, win64, sysv64, ptx-kernel, msp430-interrupt, x86-interrupt, amdgpu-kernel, Rust, C, system, rust-intrinsic, rust-call, platform-intrinsic, unadjusted $ echo '#[cfg(any())] extern "C++" {}' | rustup run nightly-2020-03-19 rustfmt
#[cfg(any())]
extern "Rust" {} $ git rev-parse HEAD
9124dd88d6ef14d0ae77dc52ff5e9598f24a75a0
$ echo '#[cfg(any())] extern "C++" {}' | cargo run --bin rustfmt
#[cfg(any())]
extern "Rust" {} |
rustfmt/rustfmt-core/rustfmt-lib/src/utils.rs Lines 137 to 148 in 9124dd8
Updating that logic to keep the original string should be doable, though I'm not sure if that'd have any other side effects |
I think keeping the original string would be the obvious correct behavior for rustfmt. It's definitely what I would want in https://github.com/dtolnay/cxx. |
Upstream, I believe the validation of the string was moved from parsing to a later stage recently as well so it's plausible a bump of the syntax version used here would be reasonable as well. |
Agreed, just needs some refactoring to support doing so while still honoring the |
Also agreed, though we're going to have some challenges bumping the version of the syntax/ast crate and friends in rustfmt given some of those usptream changes in parsing, especially rust-lang/rust#69838 |
@rchaser53 are you working on this one already? if not i'll take a look in the next day or so |
Yep; the grammar of the language now only cares about string literals, deferring translation actual ABIs (in the sense of (Aside: very nice, and unexpected, to see @dtolnay taking advantage of this =P.) |
@calebcartwright No, I haven't yet. I cannot have the enough time until this Sunday. So I will leave it to you. Thank you. |
We're still a good ways out from being ready to release v2.x of rustfmt, so I've also opened #4089 against the latest 1.x branch in case there's a desire to have the fix available sooner. |
Rustfmt fails to format the following file, even though rustc happily compiles it.
I am using cfg here to repro, but the more important case in practice would be to allow non-standard ABI in the input of procedural macro attributes like https://github.com/dtolnay/cxx.
The text was updated successfully, but these errors were encountered: