Skip to content

Expansion info is reset for the mark #52363

@dtolnay

Description

@dtolnay
Member
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

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
self-assigned this
on Jul 14, 2018
added
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
P-highHigh priority
on Jul 19, 2018
pnkfelix

pnkfelix commented on Jul 26, 2018

@pnkfelix
Contributor

visiting for triage.

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

petrochenkov

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.

petrochenkov

petrochenkov commented on Jul 26, 2018

@petrochenkov
Contributor

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

pnkfelix

pnkfelix commented on Aug 2, 2018

@pnkfelix
Contributor

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

added and removed
P-highHigh priority
on Aug 2, 2018
nikomatsakis

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 remaining items

petrochenkov

petrochenkov commented on Jul 8, 2019

@petrochenkov
Contributor

Fixed in #62476

added a commit that references this issue on Jul 11, 2019
7697b29
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

    Participants

    @nikomatsakis@pnkfelix@arielb1@dtolnay@pietroalbini

    Issue actions

      Expansion info is reset for the mark · Issue #52363 · rust-lang/rust