Skip to content

Expansion info is reset for the mark #52363

Closed

Description

@dtolnay
format_args!({ #[derive(repro)] struct ProcMacroHack; });

Correct behavior on all compilers 1.15.0 through 1.28.0-beta.10:

error: format argument must be a string literal.
 --> src/main.rs:5:18
  |
5 |     format_args!({ #[derive(repro)] struct ProcMacroHack; });
  |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

But on nightly:
(UPDATE: The ICE is now suppressed, but the issue still needs investigation.)

thread 'main' panicked at 'expansion info is reset for the mark 2
old: ExpnInfo {
    call_site: Span {
        lo: BytePos(
            56
        ),
        hi: BytePos(
            113
        ),
        ctxt: #0
    },
    def_site: None,
    format: MacroBang(
        format_args
    ),
    allow_internal_unstable: true,
    allow_internal_unsafe: false,
    local_inner_macros: false,
    edition: Edition2015
}
new: ExpnInfo {
    call_site: Span {
        lo: BytePos(
            88
        ),
        hi: BytePos(
            109
        ),
        ctxt: #0
    },
    def_site: None,
    format: MacroAttribute(
        derive(repro)
    ),
    allow_internal_unstable: true,
    allow_internal_unsafe: false,
    local_inner_macros: false,
    edition: Edition2015
}', libsyntax_pos/hygiene.rs:114:17
note: Run with `RUST_BACKTRACE=1` for a backtrace.

error: internal compiler error: unexpected panic

Repro script

#!/bin/sh

cargo new repro
cargo new --lib repro_macro

cat >repro/src/main.rs <<'REPRO'
#[macro_use]
extern crate repro_macro;

fn main() {
    format_args!({ #[derive(repro)] struct ProcMacroHack; });
}
REPRO

cat >>repro/Cargo.toml <<'REPRO'
repro_macro = { path = "../repro_macro" }
REPRO

cat >repro_macro/src/lib.rs <<'REPRO'
extern crate proc_macro;
use proc_macro::TokenStream;

#[proc_macro_derive(repro)]
pub fn repro(_input: TokenStream) -> TokenStream {
    "".parse().unwrap()
}
REPRO

cat >>repro_macro/Cargo.toml <<'REPRO'
[lib]
proc-macro = true
REPRO

cargo build --manifest-path repro/Cargo.toml

Mentioning @petrochenkov because this bug was exposed by #51726.

Activity

  1. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
    on Jul 14, 2018
  2. self-assigned this
    on Jul 14, 2018
  3. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    P-highHigh priority
    on Jul 19, 2018
  4. pnkfelix commented on Jul 26, 2018

    @pnkfelix
    Contributor

    visiting for triage.

    @petrochenkov do you have any status update to report here?

  5. petrochenkov commented on Jul 26, 2018

    @petrochenkov
    Contributor

    No updates, low priority.
    I'll look into this after edition-related macro modularization work is complete.

  6. petrochenkov commented on Jul 26, 2018

    @petrochenkov
    Contributor

    In the worst case, the issue can be masked by turning the assert into debug assert.

  7. added and removed on Jul 31, 2018
  8. pnkfelix commented on Aug 2, 2018

    @pnkfelix
    Contributor

    downgrading to P-medium to reflect lower-priority status.

  9. added and removed
    P-highHigh priority
    on Aug 2, 2018
  10. nikomatsakis commented on Aug 23, 2018

    @nikomatsakis
    Contributor

    @petrochenkov

    In the worst case, the issue can be masked by turning the assert into debug assert.

    So do we want to remove the assertion and file a follow-up issue to resurrect it? Seems like we should "close the issue" by doing that?

    Some discussion here

  11. 8 remaining items

  12. petrochenkov commented on Jul 8, 2019

    @petrochenkov
    Contributor

    Fixed in #62476

  13. added a commit that references this issue on Jul 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)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