Closed
Description
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
Metadata
Metadata
Assignees
Labels
Area: const generics (parameters and arguments)Area: Lazy normalization (tracking issue: #60471)Category: This is a bug.`#![feature(const_generics)]`Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Relevant to the compiler team, which will review and decide on the PR/issue.ICE tracked in rust-lang/glacier.This issue requires a nightly compiler in some way.