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

internal compiler error: missing type for const item #69396

Closed
dwrensha opened this issue Feb 23, 2020 · 4 comments · Fixed by #69623
Closed

internal compiler error: missing type for const item #69396

dwrensha opened this issue Feb 23, 2020 · 4 comments · Fixed by #69623
Assignees
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-parser Area: The parsing of Rust source code to an AST A-type-system Area: Type system C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dwrensha
Copy link
Contributor

I'm seeing an internal compiler error on the following input (found by fuzz-rustc):

macro_rules! suite {
    ( $( $fn:ident; )* ) => {
        $(
            const A = "A".$fn();
        )*
    }
}

suite! {
    len;
    is_empty;
}

fn main() {}
$ rustc src/main.rs
error: internal compiler error: missing type for `const` item
  --> src/main.rs:4:19
   |
4  |               const A = "A".$fn();
   |                     ^ help: provide a type for the item: `A: <type>`
...
9  | / suite! {
10 | |     len;
11 | |     is_empty;
12 | | }
   | |_- in this macro invocation
   |
   = note: src/librustc_errors/lib.rs:456: already existing stashed diagnostic with (span = Span { lo: BytePos(80), hi: BytePos(81), ctxt: #3 }, key = ItemNoType)
   = note: this error: internal compiler error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:461:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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.43.0-nightly (7760cd0fb 2020-02-19) running on x86_64-unknown-linux-gnu

error: missing type for `const` item
  --> src/main.rs:4:19
   |
4  |               const A = "A".$fn();
   |                     ^ help: provide a type for the item: `A: <type>`
...
9  | / suite! {
10 | |     len;
11 | |     is_empty;
12 | | }
   | |_- in this macro invocation
   |
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 2 previous errors

@dwrensha
Copy link
Contributor Author

dwrensha commented Feb 23, 2020

I ran cargo-bisect-rustc:

searched nightlies: from nightly-2019-07-30 to nightly-2020-02-15
regressed nightly: nightly-2019-09-26
searched commits: from 6ef275e to 37538aa
regressed commit: dcd473d

That's a rollup commit. Of the components of the rollup, #64698 looks to me to be most likely to be related. (cc @Centril)

@jonas-schievink jonas-schievink added 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. I-nominated labels Feb 23, 2020
@Centril Centril added A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-parser Area: The parsing of Rust source code to an AST A-type-system Area: Type system labels Feb 23, 2020
@Centril
Copy link
Contributor

Centril commented Feb 23, 2020

Hmm, bummer. It looks like they are getting the same span and so the stashed error is overwritten. We might need to insert a Vec<_> there to handle the possibility of span reuse from different things.

@pnkfelix
Copy link
Member

triage: P-high. Removing nomination. Added regression stable-to-stable tag.

@pnkfelix pnkfelix added P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. and removed I-nominated labels Feb 27, 2020
@Centril
Copy link
Contributor

Centril commented Feb 28, 2020

Fixed in #69537.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-parser Area: The parsing of Rust source code to an AST A-type-system Area: Type system C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
5 participants