Closed
Description
Code
#![feature(const_generics_defaults)]
#[repr(C)]
pub struct Loaf<T: Sized, const N: usize = 1usize> {
head: [T; N],
slice: [T],
}
Meta
rustc --version --verbose
:
soveu@localhost /t/rtest> rustc --version --verbose
rustc 1.52.0-nightly (45b3c2851 2021-03-04)
binary: rustc
commit-hash: 45b3c28518e4c45dfd12bc2c4400c0d0e9639927
commit-date: 2021-03-04
host: x86_64-unknown-linux-gnu
release: 1.52.0-nightly
LLVM version: 12.0.0
Error output
soveu@localhost /t/rtest [101]> rustc const.rs
warning: the feature `const_generics_defaults` is incomplete and may not be safe to use and/or cause compiler crashes
--> const.rs:1:12
|
1 | #![feature(const_generics_defaults)]
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
warning: 1 warning emitted
error: internal compiler error: unexpected const parent in type_of_def_id(): Item(Item { ident: Loaf#0, def_id: DefId(0:3 ~ const[317d]::Loaf), attrs: [Attribute { kind: Normal(AttrItem { path: Path { span: const.rs:3:3: 3:7 (#0), segments: [PathSegment { ident: repr#0, id: NodeId(12), args: None }], tokens: None }, args: Delimited(DelimSpan { open: const.rs:3:7: 3:8 (#0), close: const.rs:3:9: 3:10 (#0) }, Parenthesis, TokenStream([(Token(Token { kind: Ident("C", false), span: const.rs:3:8: 3:9 (#0) }), Alone)])), tokens: None }, None), id: AttrId(1), style: Outer, span: const.rs:3:1: 3:11 (#0) }], kind: Struct(Struct([StructField { span: const.rs:5:5: 5:17 (#0), ident: head#0, vis: Spanned { node: Inherited, span: const.rs:5:5: 5:5 (#0) }, hir_id: HirId { owner: DefId(0:3 ~ const[317d]::Loaf), local_id: 7 }, ty: Ty { hir_id: HirId { owner: DefId(0:3 ~ const[317d]::Loaf), local_id: 6 }, kind: Array(Ty { hir_id: HirId { owner: DefId(0:3 ~ const[317d]::Loaf), local_id: 1 }, kind: Path(Resolved(None, Path { span: const.rs:5:12: 5:13 (#0), res: Def(TyParam, DefId(0:4 ~ const[317d]::Loaf::T)), segments: [PathSegment { ident: T#0, hir_id: Some(HirId { owner: DefId(0:3 ~ const[317d]::Loaf), local_id: 2 }), res: Some(Def(TyParam, DefId(0:4 ~ const[317d]::Loaf::T))), args: None, infer_args: false }] })), span: const.rs:5:12: 5:13 (#0) }, AnonConst { hir_id: HirId { owner: DefId(0:3 ~ const[317d]::Loaf), local_id: 3 }, body: BodyId { hir_id: HirId { owner: DefId(0:3 ~ const[317d]::Loaf), local_id: 5 } } }), span: const.rs:5:11: 5:17 (#0) }, attrs: [] }, StructField { span: const.rs:6:5: 6:15 (#0), ident: slice#0, vis: Spanned { node: Inherited, span: const.rs:6:5: 6:5 (#0) }, hir_id: HirId { owner: DefId(0:3 ~ const[317d]::Loaf), local_id: 11 }, ty: Ty { hir_id: HirId { owner: DefId(0:3 ~ const[317d]::Loaf), local_id: 10 }, kind: Slice(Ty { hir_id: HirId { owner: DefId(0:3 ~ const[317d]::Loaf), local_id: 8 }, kind: Path(Resolved(None, Path { span: const.rs:6:13: 6:14 (#0), res: Def(TyParam, DefId(0:4 ~ const[317d]::Loaf::T)), segments: [PathSegment { ident: T#0, hir_id: Some(HirId { owner: DefId(0:3 ~ const[317d]::Loaf), local_id: 9 }), res: Some(Def(TyParam, DefId(0:4 ~ const[317d]::Loaf::T))), args: None, infer_args: false }] })), span: const.rs:6:13: 6:14 (#0) }), span: const.rs:6:12: 6:15 (#0) }, attrs: [] }], false), Generics { params: [GenericParam { hir_id: HirId { owner: DefId(0:3 ~ const[317d]::Loaf), local_id: 14 }, name: Plain(T#0), attrs: [], bounds: [Trait(PolyTraitRef { bound_generic_params: [], trait_ref: TraitRef { path: Path { span: const.rs:4:20: 4:25 (#0), res: Def(Trait, DefId(2:2150 ~ core[3998]::marker::Sized)), segments: [PathSegment { ident: Sized#0, hir_id: Some(HirId { owner: DefId(0:3 ~ const[317d]::Loaf), local_id: 12 }), res: Some(Def(Trait, DefId(2:2150 ~ core[3998]::marker::Sized))), args: None, infer_args: false }] }, hir_ref_id: HirId { owner: DefId(0:3 ~ const[317d]::Loaf), local_id: 13 } }, span: const.rs:4:20: 4:25 (#0) }, None)], span: const.rs:4:17: 4:18 (#0), pure_wrt_drop: false, kind: Type { default: None, synthetic: None } }, GenericParam { hir_id: HirId { owner: DefId(0:3 ~ const[317d]::Loaf), local_id: 19 }, name: Plain(N#0), attrs: [], bounds: [], span: const.rs:4:33: 4:34 (#0), pure_wrt_drop: false, kind: Const { ty: Ty { hir_id: HirId { owner: DefId(0:3 ~ const[317d]::Loaf), local_id: 15 }, kind: Path(Resolved(None, Path { span: const.rs:4:36: 4:41 (#0), res: PrimTy(Uint(Usize)), segments: [PathSegment { ident: usize#0, hir_id: Some(HirId { owner: DefId(0:3 ~ const[317d]::Loaf), local_id: 16 }), res: Some(Err), args: None, infer_args: false }] })), span: const.rs:4:36: 4:41 (#0) }, default: Some(AnonConst { hir_id: HirId { owner: DefId(0:3 ~ const[317d]::Loaf), local_id: 17 }, body: BodyId { hir_id: HirId { owner: DefId(0:3 ~ const[317d]::Loaf), local_id: 18 } } }) } }], where_clause: WhereClause { predicates: [], span: const.rs:4:51: 4:51 (#0) }, span: const.rs:4:16: 4:51 (#0) }), vis: Spanned { node: Public, span: const.rs:4:1: 4:4 (#0) }, span: const.rs:4:1: 7:2 (#0) })
|
= note: delayed at compiler/rustc_typeck/src/collect/type_of.rs:439:26
error: internal compiler error: TyKind::Error constructed but no error reported
|
= note: delayed at compiler/rustc_typeck/src/check/coercion.rs:154:49
error: internal compiler error: TyKind::Error constructed but no error reported
|
= note: delayed at compiler/rustc_mir_build/src/build/mod.rs:690:18
error: internal compiler error: mir_const_qualif: MIR had errors
--> const.rs:4:44
|
4 | pub struct Loaf<T: Sized, const N: usize = 1usize> {
| ^^^^^^
|
= note: delayed at compiler/rustc_mir/src/transform/mod.rs:235:18
error: internal compiler error: PromoteTemps: MIR had errors
--> const.rs:4:44
|
4 | pub struct Loaf<T: Sized, const N: usize = 1usize> {
| ^^^^^^
|
= note: delayed at compiler/rustc_mir/src/transform/promote_consts.rs:55:22
error: internal compiler error: broken MIR in DefId(0:6 ~ const[317d]::Loaf::{constant#0}) ("return type"): bad type [type error]
--> const.rs:4:44
|
4 | pub struct Loaf<T: Sized, const N: usize = 1usize> {
| ^^^^^^
|
= note: delayed at compiler/rustc_mir/src/borrow_check/type_check/mod.rs:252:27
error: internal compiler error: TyKind::Error constructed but no error reported
|
= note: delayed at compiler/rustc_mir/src/borrow_check/type_check/mod.rs:714:20
error: internal compiler error: broken MIR in DefId(0:6 ~ const[317d]::Loaf::{constant#0}) (LocalDecl { mutability: Mut, local_info: None, internal: false, is_block_tail: None, ty: [type error], user_ty: None, source_info: SourceInfo { span: const.rs:4:44: 4:50 (#0), scope: scope[0] } }): bad type [type error]
--> const.rs:4:44
|
4 | pub struct Loaf<T: Sized, const N: usize = 1usize> {
| ^^^^^^
|
= note: delayed at compiler/rustc_mir/src/borrow_check/type_check/mod.rs:252:27
thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1012: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.52.0-nightly (45b3c2851 2021-03-04) running on x86_64-unknown-linux-gnu
query stack during panic:
end of query stack
Backtrace
thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1012:13
stack backtrace:
0: rust_begin_unwind
at /rustc/45b3c28518e4c45dfd12bc2c4400c0d0e9639927/library/std/src/panicking.rs:493:5
1: std::panicking::begin_panic_fmt
at /rustc/45b3c28518e4c45dfd12bc2c4400c0d0e9639927/library/std/src/panicking.rs:435:5
2: rustc_errors::HandlerInner::flush_delayed
3: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
4: core::ptr::drop_in_place<rustc_session::parse::ParseSess>
5: <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop
6: core::ptr::drop_in_place<rustc_interface::interface::Compiler>
7: rustc_span::with_source_map
8: rustc_interface::interface::create_compiler_and_run
9: rustc_span::with_session_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Metadata
Metadata
Assignees
Labels
Area: const generics (parameters and arguments)Category: This is a bug.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.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.