Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dtolnay opened this issue Sep 3, 2020 · 3 comments · Fixed by #76292
Closed

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

dtolnay opened this issue Sep 3, 2020 · 3 comments · Fixed by #76292
Assignees
Labels
A-proc-macros Area: Procedural macros C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-critical Critical priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dtolnay
Copy link
Member

dtolnay commented Sep 3, 2020

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
@dtolnay dtolnay added regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. C-bug Category: This is a bug. labels Sep 3, 2020
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Sep 3, 2020
@jyn514 jyn514 added A-proc-macros Area: Procedural macros I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Sep 3, 2020
@Aaron1011
Copy link
Member

It looks like I misunderstood how BridgeState works. I'll PR a fix tomorrow.

@Aaron1011 Aaron1011 self-assigned this Sep 3, 2020
@spastorino
Copy link
Member

Assigning P-critical as discussed as part of the Prioritization Working Group procedure and removing I-prioritize.

@spastorino spastorino added P-critical Critical priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. P-critical Critical priority labels Sep 3, 2020
@Aaron1011
Copy link
Member

PR is up at #76292

bors added a commit to rust-lang-ci/rust that referenced this issue Sep 4, 2020
…r=petrochenkov

Respect `-Z proc-macro-backtrace` flag for panics inside libproc_macro

Fixes rust-lang#76270

Previously, any panic occuring during a call to a libproc_macro method
(e.g. calling `Ident::new` with an invalid identifier) would always
cause an ICE message to be printed.
@bors bors closed this as completed in 53cce25 Sep 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-proc-macros Area: Procedural macros C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-critical Critical priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants