Skip to content
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

Can't parse macro-processed extern "C" block #36

Open
joshtriplett opened this issue May 27, 2022 · 1 comment
Open

Can't parse macro-processed extern "C" block #36

joshtriplett opened this issue May 27, 2022 · 1 comment
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@joshtriplett
Copy link
Contributor

Given a macro which processes extern C functions:

macro_rules! some_macro {
    (extern "C" { $($i:item)* }) => ( extern "C" { $($i)* });
}

And code invoking it:

some_macro! {
    extern "C" {
        pub fn func(arg: c_int) -> c_int;
    }
}

systest will fail to parse this, emitting an error like this:

  error: expected one of `!`, `(`, `::`, `<`, `where`, or `{`, found `;`
     --> ../src/lib.rs:120:82
      |
  118 | / some_macro! {
  119 | |     extern "C" {
  120 | |         pub fn func(arg: c_int) -> c_int;
      | |                                         ^ expected one of `!`, `(`, `::`, `<`, `where`, or `{` here

If I modify the macro and invocation to go inside the extern "C" block rather than outside it, I instead get an internal compiler error:

  error: internal compiler error: Error constructed but not emitted

  thread 'main' panicked at 'explicit panic', /path/to/.cargo/registry/src/github.com-1ecc6299db9ec823/garando_errors-0.1.0/src/diagnostic_builder.rs:190:13
@JohnTitor
Copy link
Owner

I think this has the same root cause as #6, i.e. our parsing libraries are too old. We have to migrate to a newer crate (e.g. syn?) but it'd be hard work and I cannot promise I will work on it soon.

@JohnTitor JohnTitor added bug Something isn't working help wanted Extra attention is needed labels May 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants