Skip to content

rustc panic with inconsistent resolution for a macro for proc macro imported different name for wasm target. #64450

Closed

Description

@gui1117

Context

I compile with cargo check --target=wasm32-unknown-unknown for a project with a proc macro imported with a different name as such:

[dependencies]
curve = { package = "srml-staking-npos-reward-curve", path = "../npos-reward-curve"} // proc macro

and it fails with:

[thiolliere@localhost runtime]$ cargo check --target=wasm32-unknown-unknown --verbose
       Fresh srml-staking-npos-reward-curve v2.0.0 (/home/thiolliere/Developpement/debug-inconsistence/npos-reward-curve)
    Checking node-runtime v2.0.0 (/home/thiolliere/Developpement/debug-inconsistence/runtime)
     Running `rustc --edition=2018 --crate-name node_runtime src/lib.rs --color always --crate-type lib --emit=dep-info,metadata -C debuginfo=2 -C metadata=725a3230f86358ca -C extra-filename=-725a3230f86358ca --out-dir /home/thiolliere/Developpement/debug-inconsistence/runtime/target/wasm32-unknown-unknown/debug/deps --target wasm32-unknown-unknown -C incremental=/home/thiolliere/Developpement/debug-inconsistence/runtime/target/wasm32-unknown-unknown/debug/incremental -L dependency=/home/thiolliere/Developpement/debug-inconsistence/runtime/target/wasm32-unknown-unknown/debug/deps -L dependency=/home/thiolliere/Developpement/debug-inconsistence/runtime/target/debug/deps --extern curve=/home/thiolliere/Developpement/debug-inconsistence/runtime/target/debug/deps/libsrml_staking_npos_reward_curve-d12c78ed288d6d74.so`
thread 'rustc' panicked at 'src/librustc_resolve/macros.rs:928: inconsistent resolution for a macro', src/librustc/util/bug.rs:37:26
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.37.0 (eae3437df 2019-08-13) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 -C incremental --crate-type lib

note: some of the compiler flags provided by cargo are hidden

error: Could not compile `node-runtime`.

Caused by:
  process didn't exit successfully: `rustc --edition=2018 --crate-name node_runtime src/lib.rs --color always --crate-type lib --emit=dep-info,metadata -C debuginfo=2 -C metadata=725a3230f86358ca -C extra-filename=-725a3230f86358ca --out-dir /home/thiolliere/Developpement/debug-inconsistence/runtime/target/wasm32-unknown-unknown/debug/deps --target wasm32-unknown-unknown -C incremental=/home/thiolliere/Developpement/debug-inconsistence/runtime/target/wasm32-unknown-unknown/debug/incremental -L dependency=/home/thiolliere/Developpement/debug-inconsistence/runtime/target/wasm32-unknown-unknown/debug/deps -L dependency=/home/thiolliere/Developpement/debug-inconsistence/runtime/target/debug/deps --extern curve=/home/thiolliere/Developpement/debug-inconsistence/runtime/target/debug/deps/libsrml_staking_npos_reward_curve-d12c78ed288d6d74.so` (exit code: 101)

removing the dependency renames works:

[dependencies]
srml-staking-npos-reward-curve = { path = "../npos-reward-curve"} // proc macro

Reproduce

use this repo: https://github.com/thiolliere/debug-inconsistence
and run cargo check --target=wasm32-unknown-unknown in the runtime crate.

Activity

  1. petrochenkov commented on Sep 14, 2019

    @petrochenkov
    Contributor

    If cross-compilation is involved, then it might be a duplicate of #56935.
    In that case the workaround is to use extern crate explicitly in source code, instead of relying on crate names passed with --extern automatically being in scope.

  2. bkchr commented on Sep 25, 2019

    @bkchr
    Contributor

    @petrochenkov I had the same error with a different crate. It involves cross compilation, but as said by @thiolliere, this can be fixed by not including the proc-macro crate with renaming in the Cargo.toml file. So, I'm not entirely sure if that is that is a duplicate of the linked issue.

    Any chance that this can be fixed in the near future? Could we maybe help you fixing this?

  3. added
    A-crossArea: Cross compilation
    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
    A-resolveArea: Name/path resolution done by `rustc_resolve` specifically
    C-bugCategory: This is a bug.
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Sep 25, 2019
  4. self-assigned this
    on Sep 26, 2019
  5. petrochenkov commented on Sep 26, 2019

    @petrochenkov
    Contributor

    I'll look into fixing it this weekend or the next week.
    A minimized reproduction already exists, so the only helpful thing I can imagine is someone actually writing a fix and submitting a PR instead of me :)

  6. bkchr commented on Sep 26, 2019

    @bkchr
    Contributor

    Nice, ty! :)

  7. petrochenkov commented on Sep 29, 2019

    @petrochenkov
    Contributor

    This may be a slightly different issue from #56935, but the same workaround with adding extern crate to the crate root explicitly is confirmed to work.
    (Like extern crate curve; for the reproduction example.)

  8. petrochenkov commented on Oct 2, 2019

    @petrochenkov
    Contributor

    I started investigating in #65026, but didn't get to ICEs themselves yet.

  9. added 2 commits that reference this issue on Oct 3, 2019
  10. added a commit that references this issue on Dec 10, 2019
  11. petrochenkov commented on May 29, 2020

    @petrochenkov
    Contributor

    Closing as a duplicate of #56935.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-crossArea: Cross compilationA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler 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