Skip to content
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

Macro ICE #68058

Closed
olegnn opened this issue Jan 9, 2020 · 2 comments · Fixed by #68072
Closed

Macro ICE #68058

olegnn opened this issue Jan 9, 2020 · 2 comments · Fixed by #68072
Labels
A-HIR Area: The high-level intermediate representation (HIR) A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@olegnn
Copy link
Contributor

olegnn commented Jan 9, 2020

This code

macro_rules! def_target {
    ($target: expr) => {
        #[target_feature(enable=$target)]
        unsafe fn f() {
            #[target_feature(enable=$target)]
            ()
        }
    };
}

def_target!("avx2");

fn main() {}

(Playground)

Produces ICE on any channel:

   Compiling playground v0.0.1 (/playground)
thread 'rustc' panicked at 'src/librustc/ich/impls_syntax.rs:326: interpolated tokens should not be present in the HIR', src/librustc/util/bug.rs:37:26
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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.40.0 (73528e339 2019-12-16) running on x86_64-unknown-linux-gnu

note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type bin

note: some of the compiler flags provided by cargo are hidden

error: could not compile `playground`.
@jonas-schievink jonas-schievink added A-HIR Area: The high-level intermediate representation (HIR) A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ I-nominated T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 9, 2020
@petrochenkov
Copy link
Contributor

The fix is the src/librustc/hir/lowering/expr.rs part of #67121, feel free to apply it and make a PR.

JohnTitor added a commit to JohnTitor/rust that referenced this issue Jan 9, 2020
@petrochenkov
Copy link
Contributor

Fixed in #68072.

JohnTitor added a commit to JohnTitor/rust that referenced this issue Jan 10, 2020
bors added a commit that referenced this issue Jan 11, 2020
Rollup of 9 pull requests

Successful merges:

 - #67000 (Promote references to constants instead of statics)
 - #67756 (Collector tweaks)
 - #67889 (Compile some CGUs in parallel at the start of codegen)
 - #67930 (Rename Result::as_deref_ok to as_deref)
 - #68018 (feature_gate: Remove `GateStrength`)
 - #68070 (clean up E0185 explanation)
 - #68072 (Fix ICE #68058)
 - #68114 (Don't require `allow_internal_unstable` unless `staged_api` is enabled.)
 - #68120 (Ban `...X` pats, harden tests, and improve diagnostics)

Failed merges:

r? @ghost
bors added a commit that referenced this issue Jan 11, 2020
Rollup of 8 pull requests

Successful merges:

 - #67756 (Collector tweaks)
 - #67889 (Compile some CGUs in parallel at the start of codegen)
 - #67930 (Rename Result::as_deref_ok to as_deref)
 - #68018 (feature_gate: Remove `GateStrength`)
 - #68070 (clean up E0185 explanation)
 - #68072 (Fix ICE #68058)
 - #68114 (Don't require `allow_internal_unstable` unless `staged_api` is enabled.)
 - #68120 (Ban `...X` pats, harden tests, and improve diagnostics)

Failed merges:

r? @ghost
@bors bors closed this as completed in f02f338 Jan 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-HIR Area: The high-level intermediate representation (HIR) A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ 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.

3 participants