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

Const generics ICE ("unexpected const parent in type_of_def_id") on const param of method #68596

Closed
qwerty19106 opened this issue Jan 28, 2020 · 2 comments · Fixed by #74392
Closed
Labels
A-const-generics Area: const generics (parameters and arguments) A-lazy-normalization Area: lazy normalization (tracking issue: #60471) C-bug Category: This is a bug. F-const_generics `#![feature(const_generics)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@qwerty19106
Copy link

The code:

#![feature(const_generics)]
#![feature(const_fn)]

pub struct S(u8);

impl S {
    pub fn get<const A: u8>(&self) -> &u8 {
        &self.0
    }
}

fn main() {
    const A: u8 = 5;
    let s = S(0);
    
    s.get::<A>();
}

cause ICE:

error: internal compiler error: unexpected const parent in type_of_def_id(): Expr(expr(HirId { owner: DefIndex(9), local_id: 15 }: s.get::<>()))

error: internal compiler error: mir_const_qualif: MIR had errors
  --> a.rs:16:13
   |
16 |     s.get::<A>();
   |             ^

error: internal compiler error: PromoteTemps: MIR had errors
  --> a.rs:16:13
   |
16 |     s.get::<A>();
   |             ^

error: internal compiler error: broken MIR in DefId(0:11 ~ a[317d]::main[0]::{{constant}}[0]) ("return type"): bad type [type error]
  --> a.rs:16:13
   |
16 |     s.get::<A>();
   |             ^

error: internal compiler error: broken MIR in DefId(0:11 ~ a[317d]::main[0]::{{constant}}[0]) (LocalDecl { mutability: Mut, local_info: Other, internal: false, is_block_tail: None, ty: [type error], user_ty: UserTypeProjections { contents: [] }, source_info: SourceInfo { span: a.rs:16:13: 16:14, scope: scope[0] } }): bad type [type error]
  --> a.rs:16:13
   |
16 |     s.get::<A>();
   |             ^

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:357:17

And this code variant also gives ICE:

s.get::<A>();

error: internal compiler error: broken MIR in DefId(0:9 ~ a[317d]::main[0]) (const S::get::<Scalar(<ZST>): [type error]>): bad type for<'r> fn(&'r S) -> &'r u8 {S::get::<Scalar(<ZST>): [type error]>}
  --> a.rs:16:7
   |
16 |     s.get();
   |       ^^^

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:357:17

Complied by:

note: rustc 1.42.0-nightly (8a79d08fa 2020-01-27) running on x86_64-unknown-linux-gnu

playground

@jonas-schievink jonas-schievink added A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. F-const_generics `#![feature(const_generics)]` 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. labels Jan 28, 2020
@varkor
Copy link
Member

varkor commented Jan 28, 2020

This is likely #64537.

@Centril Centril added the requires-nightly This issue requires a nightly compiler in some way. label Jan 28, 2020
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Jan 29, 2020
@DutchGhost
Copy link
Contributor

@varkor varkor added the A-lazy-normalization Area: lazy normalization (tracking issue: #60471) label Apr 8, 2020
lcnr added a commit to lcnr/rust that referenced this issue Jul 16, 2020
Manishearth added a commit to Manishearth/rust that referenced this issue Jul 16, 2020
const generics triage

I went through all const generics issues and closed all issues which are already fixed.

Some issues already have a regression test but were not closed. Also doing this as part of this PR.

uff r? @eddyb @varkor

closes rust-lang#61936
closes rust-lang#62878
closes rust-lang#63695
closes rust-lang#67144
closes rust-lang#68596
closes rust-lang#69816
closes rust-lang#70217
closes rust-lang#70507
closes rust-lang#70586
closes rust-lang#71348
closes rust-lang#71805
closes rust-lang#73120
closes rust-lang#73508
closes rust-lang#73730
closes rust-lang#74255
@bors bors closed this as completed in c354524 Jul 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) A-lazy-normalization Area: lazy normalization (tracking issue: #60471) C-bug Category: This is a bug. F-const_generics `#![feature(const_generics)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. 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.

6 participants