Closed
Description
#![feature(const_generics)]
pub fn function_with_str<const STRING: &'static str>() {
}
pub fn use_it() {
function_with_str::<"Hello, world!">()
}
Results in
Compiling playground v0.0.1 (/playground)
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
--> src/lib.rs:1:12
|
1 | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
error: internal compiler error: broken MIR in DefId(0:14 ~ playground[d52b]::use_it[0]) (CanonicalUserTypeAnnotation { user_ty: Canonical { max_universe: U0, variables: [], value: TypeOf(DefId(0:12 ~ playground[d52b]::function_with_str[0]), UserSubsts { substs: [Const { ty: &'static str, val: Unevaluated(DefId(0:15 ~ playground[d52b]::use_it[0]::{{constant}}[0]), []) }], user_self_ty: None }) }, span: src/lib.rs:7:5: 7:41, inferred_ty: fn() {function_with_str::<Const { ty: &str, val: Slice(Ptr(Pointer { alloc_id: AllocId(0), offset: Size { raw: 0 }, tag: () }), 13) }>} }): bad user type AscribeUserType(fn() {function_with_str::<Const { ty: &str, val: Slice(Ptr(Pointer { alloc_id: AllocId(0), offset: Size { raw: 0 }, tag: () }), 13) }>}, DefId(0:12 ~ playground[d52b]::function_with_str[0]) UserSubsts { substs: [Const { ty: &'static str, val: Unevaluated(DefId(0:15 ~ playground[d52b]::use_it[0]::{{constant}}[0]), []) }], user_self_ty: None }): NoSolution
error: internal compiler error: broken MIR in DefId(0:14 ~ playground[d52b]::use_it[0]) (const function_with_str): constant const function_with_str should have type fn() {function_with_str::<Const { ty: &str, val: Slice(Ptr(Pointer { alloc_id: AllocId(0), offset: Size { raw: 0 }, tag: () }), 13) }>} but has fn() {function_with_str::<Const { ty: &str, val: Slice(Ptr(Pointer { alloc_id: AllocId(0), offset: Size { raw: 0 }, tag: () }), 13) }>} (NoSolution)
--> src/lib.rs:7:5
|
7 | function_with_str::<"Hello, world!">()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: internal compiler error: broken MIR in DefId(0:14 ~ playground[d52b]::use_it[0]) (const function_with_str): bad constant user type CanonicalUserTypeAnnotation { user_ty: Canonical { max_universe: U0, variables: [], value: TypeOf(DefId(0:12 ~ playground[d52b]::function_with_str[0]), UserSubsts { substs: [Const { ty: &'static str, val: Unevaluated(DefId(0:15 ~ playground[d52b]::use_it[0]::{{constant}}[0]), []) }], user_self_ty: None }) }, span: src/lib.rs:7:5: 7:41, inferred_ty: fn() {function_with_str::<Const { ty: &str, val: Slice(Ptr(Pointer { alloc_id: AllocId(0), offset: Size { raw: 0 }, tag: () }), 13) }>} } vs fn() {function_with_str::<Const { ty: &str, val: Slice(Ptr(Pointer { alloc_id: AllocId(0), offset: Size { raw: 0 }, tag: () }), 13) }>}: NoSolution
--> src/lib.rs:7:5
|
7 | function_with_str::<"Hello, world!">()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:356:17
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
1: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:71
2: std::panicking::default_hook::{{closure}}
at src/libstd/sys_common/backtrace.rs:59
at src/libstd/panicking.rs:197
3: std::panicking::default_hook
at src/libstd/panicking.rs:211
4: rustc::util::common::panic_hook
5: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:478
6: std::panicking::begin_panic
7: <rustc_errors::Handler as core::ops::drop::Drop>::drop
8: core::ptr::real_drop_in_place
9: core::ptr::real_drop_in_place
10: <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop
11: core::ptr::real_drop_in_place
12: rustc_interface::interface::run_compiler_in_existing_thread_pool
13: std::thread::local::LocalKey<T>::with
14: scoped_tls::ScopedKey<T>::set
15: syntax::with_globals
query stack during panic:
end of query stack
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/blob/master/CONTRIBUTING.md#bug-reports
note: rustc 1.36.0-nightly (a9ec99f42 2019-05-13) running on x86_64-unknown-linux-gnu
note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type lib
note: some of the compiler flags provided by cargo are hidden
error: Could not compile `playground`.
To learn more, run the command again with --verbose.
cc @Serentty
Metadata
Metadata
Assignees
Labels
Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlArea: const generics (parameters and arguments)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.This issue requires a nightly compiler in some way.
Activity