Skip to content

decl_macro incremental compilation bug: missing field #112680

@whispersofthedawn

Description

@whispersofthedawn

Note: This may be a duplicate, but I couldn't find one, so I'm going ahead and reporting it.

When using decl_macro, I'm encountering a strange incremental compilation bug. I have a struct, declared as follows:

use a::entity_impl;
entity_impl!(TestId, Test); // entity_impl! is the `decl_macro`

struct Test(u32);
// now uncomment the following, and comment the above
// struct Test;

To reproduce this, do the following:

  1. Run cargo clean, then cargo check.
  2. Comment line 3, and uncomment line 5.
  3. Run cargo check again. The error below is emitted.
  4. If cargo clean && cargo check is run again with either version, it compiles fine.

I don't understand why this would happen, but I do have the code, all of which can be found in this repository. a/src/lib.rs has the entity_impl macros 2.0 macro, while b/src/lib.rs has the struct & macro invocation shown above. I've minimized the example as best I can, but a normal (non-decl_macro) does not work, and I can't seem to reproduce in a single crate. If there's anything else needed, or anything I should try, please let me know.

Error message:

error[E0609]: no field `inner` on type `TestId`
 --> b/src/lib.rs:2:1
  |
2 | entity_impl!(TestId, Test);
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: a field with a similar name exists: `inner`
  |
  = note: this error originates in the macro `entity_impl` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0609`.
error: could not compile `b` (lib) due to previous error

Meta

rustc --version --verbose:

rustc 1.72.0-nightly (8c74a5d27 2023-06-14)
binary: rustc
commit-hash: 8c74a5d27c644a0f7a22bb2fa8dd3ff8257bc220
commit-date: 2023-06-14
host: x86_64-unknown-linux-gnu // also reproduces on x86_64-pc-windows-msvc
release: 1.72.0-nightly
LLVM version: 16.0.5

@rustbot label +A-incr-comp +A-macros-2.0
(I'm just guessing on these labels.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-decl-macros-2-0Area: Declarative macros 2.0 (#39412)A-incr-compArea: Incremental compilationA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.F-decl_macro`#![feature(decl_macro)]`S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issue

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions