-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Ommiting "C" in extern "C" fn
in derive input causes spans to get lost.
#64561
Comments
Thanks! This is one example of a general problem of the compiler losing span information that is being tracked in #43081. |
This one is very easily fixable though, by changing |
pub struct BareFnTy {
pub abi: Abi,
// ...
}
pub struct ForeignMod {
pub abi: Abi,
// ...
}
pub struct FnHeader {
pub abi: Abi,
...
}
pub enum Extern {
None,
Implicit,
Explicit(Abi),
}
pub struct BareFnTy {
pub ext: Extern,
// ...
}
pub struct ForeignMod {
pub abi: Option<Abi>,
// ...
}
pub struct FnHeader {
pub ext: Extern,
...
} |
If no one else is taking this issue, I am up to work on it |
I added the The errors are below: error[E0308]: mismatched types
--> src/libsyntax/feature_gate/check.rs:437:32
|
437 | self.check_abi(bare_fn_ty.abi, ty.span);
| ^^^^^^^^^^^^^^ expected enum `rustc_target::spec::abi::Abi`, found enum `std::option::Option`
|
= note: expected type `rustc_target::spec::abi::Abi`
found type `std::option::Option<rustc_target::spec::abi::Abi>`
error[E0308]: mismatched types
--> src/libsyntax/parse/parser/ty.rs:303:13
|
303 | abi,
| ^^^
| |
| expected enum `std::option::Option`, found enum `rustc_target::spec::abi::Abi`
| help: try using a variant of the expected type: `Some(abi)`
|
= note: expected type `std::option::Option<rustc_target::spec::abi::Abi>`
found type `rustc_target::spec::abi::Abi`
error[E0308]: mismatched types
--> src/libsyntax/print/pprust.rs:1006:34
|
1006 | self.print_ty_fn(f.abi,
| ^^^^^ expected enum `rustc_target::spec::abi::Abi`, found enum `std::option::Option`
|
= note: expected type `rustc_target::spec::abi::Abi`
found type `std::option::Option<rustc_target::spec::abi::Abi>` Is the solution to change code in |
@jaredforth |
Fixed in #66271. |
syntax: Keep string literals in ABIs and `asm!` more precisely As a result we don't lose spans when `extern` functions or blocks are passed to proc macros, and also escape all string literals consistently. Continuation of rust-lang#60679, which did a similar thing with all literals besides those in ABIs and `asm!`. TODO: Add tests. Fixes rust-lang#60493 Fixes rust-lang#64561 r? @Centril
For some reason ommiting the
"C"
inextern "C" fn
causes the spans to get lost in error messages.I've created this repository to demonstrate it,simply git clone it and try to build the
using_proc_macro
crate.The
proc_macro_crate
crate:The
using_proc_macro
crate:The error message
The first error is for
Hello
and the second is forWorld
.The text was updated successfully, but these errors were encountered: