Repository navigation
Closures in const generics cause ICE #63322
Copy link
Copy link
Closed
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)C-bugCategory: This is a bug.Category: This is a bug.F-const_generics`#![feature(const_generics)]``#![feature(const_generics)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.ICE tracked in rust-lang/glacier.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.This issue requires a nightly compiler in some way. When possible, use a F-* label instead.
Description
Activity
- addedA-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)C-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
on Aug 6, 2019 - addedF-const_generics`#![feature(const_generics)]``#![feature(const_generics)]`requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.This issue requires a nightly compiler in some way. When possible, use a F-* label instead.
on Aug 6, 2019 "smaller":
#![feature(const_generics)] trait A {} struct B; impl A for B {} fn test<const T: &'static dyn A>() { unimplemented!() } fn main() { test::<{ &B }>(); }
Error:
error: internal compiler error: broken MIR in DefId(0:18 ~ playground[af62]::main[0]) (CanonicalUserTypeAnnotation { user_ty: Canonical { max_universe: U0, variables: [], value: TypeOf(DefId(0:16 ~ playground[af62]::test[0]), UserSubsts { substs: [Const { ty: &'static (dyn A + 'static), val: Unevaluated(DefId(0:19 ~ playground[af62]::main[0]::{{constant}}[0]), []) }], user_self_ty: None }) }, span: src/main.rs:12:5: 12:19, inferred_ty: fn() {test::<ByRef { alloc: Allocation { bytes: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [(Size { raw: 0 }, ((), AllocId(1))), (Size { raw: 8 }, ((), AllocId(2)))] }), undef_mask: UndefMask { blocks: [65535], len: Size { raw: 16 } }, align: Align { pow2: 3 }, mutability: Immutable, extra: () }, offset: Size { raw: 0 } } : &dyn A>} }): bad user type AscribeUserType(fn() {test::<ByRef { alloc: Allocation { bytes: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [(Size { raw: 0 }, ((), AllocId(1))), (Size { raw: 8 }, ((), AllocId(2)))] }), undef_mask: UndefMask { blocks: [65535], len: Size { raw: 16 } }, align: Align { pow2: 3 }, mutability: Immutable, extra: () }, offset: Size { raw: 0 } } : &dyn A>}, DefId(0:16 ~ playground[af62]::test[0]) UserSubsts { substs: [Const { ty: &'static (dyn A + 'static), val: Unevaluated(DefId(0:19 ~ playground[af62]::main[0]::{{constant}}[0]), []) }], user_self_ty: None }): NoSolution error: internal compiler error: broken MIR in DefId(0:18 ~ playground[af62]::main[0]) (const test::<ByRef { alloc: Allocation { bytes: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [(Size { raw: 0 }, ((), AllocId(1))), (Size { raw: 8 }, ((), AllocId(2)))] }), undef_mask: UndefMask { blocks: [65535], len: Size { raw: 16 } }, align: Align { pow2: 3 }, mutability: Immutable, extra: () }, offset: Size { raw: 0 } } : &dyn A>): constant const test::<ByRef { alloc: Allocation { bytes: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [(Size { raw: 0 }, ((), AllocId(1))), (Size { raw: 8 }, ((), AllocId(2)))] }), undef_mask: UndefMask { blocks: [65535], len: Size { raw: 16 } }, align: Align { pow2: 3 }, mutability: Immutable, extra: () }, offset: Size { raw: 0 } } : &dyn A> should have type fn() {test::<ByRef { alloc: Allocation { bytes: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [(Size { raw: 0 }, ((), AllocId(1))), (Size { raw: 8 }, ((), AllocId(2)))] }), undef_mask: UndefMask { blocks: [65535], len: Size { raw: 16 } }, align: Align { pow2: 3 }, mutability: Immutable, extra: () }, offset: Size { raw: 0 } } : &dyn A>} but has fn() {test::<ByRef { alloc: Allocation { bytes: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [(Size { raw: 0 }, ((), AllocId(1))), (Size { raw: 8 }, ((), AllocId(2)))] }), undef_mask: UndefMask { blocks: [65535], len: Size { raw: 16 } }, align: Align { pow2: 3 }, mutability: Immutable, extra: () }, offset: Size { raw: 0 } } : &dyn A>} (NoSolution) --> src/main.rs:12:5 | 12 | test::<{ &B }>(); | ^^^^^^^^^^^^^^ error: internal compiler error: broken MIR in DefId(0:18 ~ playground[af62]::main[0]) (const test::<ByRef { alloc: Allocation { bytes: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [(Size { raw: 0 }, ((), AllocId(1))), (Size { raw: 8 }, ((), AllocId(2)))] }), undef_mask: UndefMask { blocks: [65535], len: Size { raw: 16 } }, align: Align { pow2: 3 }, mutability: Immutable, extra: () }, offset: Size { raw: 0 } } : &dyn A>): bad constant user type CanonicalUserTypeAnnotation { user_ty: Canonical { max_universe: U0, variables: [], value: TypeOf(DefId(0:16 ~ playground[af62]::test[0]), UserSubsts { substs: [Const { ty: &'static (dyn A + 'static), val: Unevaluated(DefId(0:19 ~ playground[af62]::main[0]::{{constant}}[0]), []) }], user_self_ty: None }) }, span: src/main.rs:12:5: 12:19, inferred_ty: fn() {test::<ByRef { alloc: Allocation { bytes: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [(Size { raw: 0 }, ((), AllocId(1))), (Size { raw: 8 }, ((), AllocId(2)))] }), undef_mask: UndefMask { blocks: [65535], len: Size { raw: 16 } }, align: Align { pow2: 3 }, mutability: Immutable, extra: () }, offset: Size { raw: 0 } } : &dyn A>} } vs fn() {test::<ByRef { alloc: Allocation { bytes: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [(Size { raw: 0 }, ((), AllocId(1))), (Size { raw: 8 }, ((), AllocId(2)))] }), undef_mask: UndefMask { blocks: [65535], len: Size { raw: 16 } }, align: Align { pow2: 3 }, mutability: Immutable, extra: () }, offset: Size { raw: 0 } } : &dyn A>}: NoSolution --> src/main.rs:12:5 | 12 | test::<{ &B }>(); | ^^^^^^^^^^^^^^ thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:361:17 stack backtrace: 0: backtrace::backtrace::libunwind::trace at /cargo/registry/src/github.life-white.uk-1ecc6299db9ec823/backtrace-0.3.34/src/backtrace/libunwind.rs:88 1: backtrace::backtrace::trace_unsynchronized at /cargo/registry/src/github.life-white.uk-1ecc6299db9ec823/backtrace-0.3.34/src/backtrace/mod.rs:66 2: std::sys_common::backtrace::_print at src/libstd/sys_common/backtrace.rs:47 3: std::sys_common::backtrace::print at src/libstd/sys_common/backtrace.rs:36 4: std::panicking::default_hook::{{closure}} at src/libstd/panicking.rs:200 5: std::panicking::default_hook at src/libstd/panicking.rs:214 6: rustc::util::common::panic_hook 7: std::panicking::rust_panic_with_hook at src/libstd/panicking.rs:481 8: std::panicking::begin_panic 9: <rustc_errors::Handler as core::ops::drop::Drop>::drop 10: core::ptr::real_drop_in_place 11: <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop 12: core::ptr::real_drop_in_place 13: rustc_interface::interface::run_compiler_in_existing_thread_pool 14: std::thread::local::LocalKey<T>::with 15: syntax::with_globals note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. query stack during panic: end of query stack error: internal compiler error: unexpected panicReacted by csmoe, Matthias Fauconneau and lcnr- addedglacierICE tracked in rust-lang/glacier.ICE tracked in rust-lang/glacier.
on Oct 15, 2019 @rustbot claim
&dyn Traitis not structural matchIt shouldn't be, but it currently is.
To fix it you need to change
src/librustc_trait_selection/traits/structural_match.rs, like this.- added 2 commits that reference this issue
on Apr 28, 2020
Metadata
Metadata
Assignees
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)C-bugCategory: This is a bug.Category: This is a bug.F-const_generics`#![feature(const_generics)]``#![feature(const_generics)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.ICE tracked in rust-lang/glacier.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.This issue requires a nightly compiler in some way. When possible, use a F-* label instead.
Pretty straightforward. The idea is to plug logic into a template. This seems like something that should/could work.
Playground link: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=7eefeb472380da1061af1be06967d30a