Skip to content

Regression in proc macro panics being reported as compiler bugs #76270

Closed
@dtolnay

Description

@dtolnay

Between nightly-2020-08-29 and nightly-2020-09-02, the following began printing an ICE message (despite compiling successfully).

The relevant compiler commit range is d006f57...130359c. #75082 appears extremely relevant so mentioning @Aaron1011 @petrochenkov. From the PR description it sounds like the PR was intended to have no effect unless the new -Z flag is passed. Is it possible it could be causing this?


Cargo.toml

[package]
name = "repro"
version = "0.0.0"
edition = "2018"

[lib]
proc-macro = true

src/lib.rs

use proc_macro::{Ident, Span, TokenStream};

#[proc_macro]
pub fn m(_input: TokenStream) -> TokenStream {
    let _ = std::panic::catch_unwind(|| Ident::new("", Span::call_site()));
    TokenStream::new()
}

src/main.rs

repro::m!();

fn main() {}

Before:

$ cargo +nightly-2020-08-29 check
   Compiling repro v0.0.0
    Finished dev [unoptimized + debuginfo] target(s) in 0.28s

After:

$ cargo +nightly-2020-09-02 check
   Compiling repro v0.0.0
thread 'rustc' panicked at '`""` is not a valid identifier', compiler/rustc_expand/src/proc_macro_server.rs:332:13
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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.48.0-nightly (80fc9b0ec 2020-09-02) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden
    Finished dev [unoptimized + debuginfo] target(s) in 0.17s

Metadata

Metadata

Assignees

Labels

A-proc-macrosArea: Procedural macrosC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-criticalCritical priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions