Open
Description
Code
#![feature(coerce_unsized)]
use std::ops;
trait Trait3<A> {}
impl<A> ops::CoerceUnsized<A> for A where A: ?Sized {}
fn main() {
println!("Hello, world!");
}
Command: rustc ./03FC8.rs
Meta
rustc --version --verbose
:
rustc 1.83.0-nightly (7608018cb 2024-09-29)
binary: rustc
commit-hash: 7608018cbdac9e55d0d13529cf43adc33d53efcf
commit-date: 2024-09-29
host: x86_64-apple-darwin
release: 1.83.0-nightly
LLVM version: 19.1.0
Error output
error[E0210]: type parameter `A` must be used as the type parameter for some local type (e.g., `MyStruct<A>`)
--> ./03FC8.rs:9:6
|
9 | impl<A> ops::CoerceUnsized<A> for A where A: ?Sized {}
| ^ type parameter `A` must be used as the type parameter for some local type
|
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
= note: only traits defined in the current crate can be implemented for a type parameter
error[E0376]: the trait `CoerceUnsized` may only be implemented for a coercion between structures
--> ./03FC8.rs:9:1
|
9 | impl<A> ops::CoerceUnsized<A> for A where A: ?Sized {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: internal compiler error: compiler/rustc_const_eval/src/interpret/cast.rs:465:17: invalid pointer unsizing &str -> str
--> ./03FC8.rs:14:14
|
14 | println!("Hello, world!");
| ^^^^^^^^^^^^^^^
Backtrace
thread 'rustc' panicked at compiler/rustc_const_eval/src/interpret/cast.rs:465:17:
Box<dyn Any>
stack backtrace:
0: 0x113f193e7 - std::backtrace::Backtrace::create::h697070a74b47c5a1
1: 0x113f19335 - std::backtrace::Backtrace::force_capture::hd4e20dc44637c239
2: 0x111d3a7ce - std[a533c313b02b6cfe]::panicking::update_hook::<alloc[3194a7a73d70d243]::boxed::Box<rustc_driver_impl[e0e0c21a20d76ec4]::install_ice_hook::{closure#0}>>::{closure#0}
3: 0x113f34af8 - std::panicking::rust_panic_with_hook::h9b093984c0b2ae3e
4: 0x111dbb617 - std[a533c313b02b6cfe]::panicking::begin_panic::<rustc_errors[e7c766416e916d12]::ExplicitBug>::{closure#0}
5: 0x111da7139 - std[a533c313b02b6cfe]::sys::backtrace::__rust_end_short_backtrace::<std[a533c313b02b6cfe]::panicking::begin_panic<rustc_errors[e7c766416e916d12]::ExplicitBug>::{closure#0}, !>
6: 0x116bf2f08 - std[a533c313b02b6cfe]::panicking::begin_panic::<rustc_errors[e7c766416e916d12]::ExplicitBug>
7: 0x111dd0806 - <rustc_errors[e7c766416e916d12]::diagnostic::BugAbort as rustc_errors[e7c766416e916d12]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
8: 0x111baecb1 - <rustc_errors[e7c766416e916d12]::DiagCtxtHandle>::span_bug::<rustc_span[51e7cf5b04f4660f]::span_encoding::Span, alloc[3194a7a73d70d243]::string::String>
9: 0x111be2a98 - rustc_middle[3d266d78c9b198e4]::util::bug::opt_span_bug_fmt::<rustc_span[51e7cf5b04f4660f]::span_encoding::Span>::{closure#0}
10: 0x111be2ad7 - rustc_middle[3d266d78c9b198e4]::ty::context::tls::with_opt::<rustc_middle[3d266d78c9b198e4]::util::bug::opt_span_bug_fmt<rustc_span[51e7cf5b04f4660f]::span_encoding::Span>::{closure#0}, !>::{closure#0}
11: 0x111bc9975 - rustc_middle[3d266d78c9b198e4]::ty::context::tls::with_context_opt::<rustc_middle[3d266d78c9b198e4]::ty::context::tls::with_opt<rustc_middle[3d266d78c9b198e4]::util::bug::opt_span_bug_fmt<rustc_span[51e7cf5b04f4660f]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
12: 0x116be1932 - rustc_middle[3d266d78c9b198e4]::util::bug::span_bug_fmt::<rustc_span[51e7cf5b04f4660f]::span_encoding::Span>
13: 0x111c6eba7 - <rustc_const_eval[298ced3d0b3bd135]::interpret::eval_context::InterpCx<rustc_const_eval[298ced3d0b3bd135]::const_eval::machine::CompileTimeMachine>>::unsize_into_ptr
14: 0x111c9d0bd - <rustc_const_eval[298ced3d0b3bd135]::interpret::eval_context::InterpCx<rustc_const_eval[298ced3d0b3bd135]::const_eval::machine::CompileTimeMachine>>::eval_statement
15: 0x111cb9c6c - rustc_const_eval[298ced3d0b3bd135]::const_eval::eval_queries::eval_to_allocation_raw_provider
16: 0x113580cfc - rustc_query_impl[75f1704df0e38289]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[75f1704df0e38289]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3d266d78c9b198e4]::query::erase::Erased<[u8; 24usize]>>
17: 0x11353173e - <rustc_query_impl[75f1704df0e38289]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2} as core[907a20686bf8bf7a]::ops::function::FnOnce<(rustc_middle[3d266d78c9b198e4]::ty::context::TyCtxt, rustc_middle[3d266d78c9b198e4]::ty::ParamEnvAnd<rustc_middle[3d266d78c9b198e4]::mir::interpret::GlobalId>)>>::call_once
18: 0x113348579 - rustc_query_system[13e780f7d1d88911]::query::plumbing::try_execute_query::<rustc_query_impl[75f1704df0e38289]::DynamicConfig<rustc_query_system[13e780f7d1d88911]::query::caches::DefaultCache<rustc_middle[3d266d78c9b198e4]::ty::ParamEnvAnd<rustc_middle[3d266d78c9b198e4]::mir::interpret::GlobalId>, rustc_middle[3d266d78c9b198e4]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[75f1704df0e38289]::plumbing::QueryCtxt, false>
19: 0x1135b823c - rustc_query_impl[75f1704df0e38289]::query_impl::eval_to_allocation_raw::get_query_non_incr::__rust_end_short_backtrace
20: 0x111bc62a2 - rustc_middle[3d266d78c9b198e4]::query::plumbing::query_get_at::<rustc_query_system[13e780f7d1d88911]::query::caches::DefaultCache<rustc_middle[3d266d78c9b198e4]::ty::ParamEnvAnd<rustc_middle[3d266d78c9b198e4]::mir::interpret::GlobalId>, rustc_middle[3d266d78c9b198e4]::query::erase::Erased<[u8; 24usize]>>>
21: 0x111cb6763 - rustc_const_eval[298ced3d0b3bd135]::const_eval::eval_queries::eval_to_const_value_raw_provider
22: 0x11358141c - rustc_query_impl[75f1704df0e38289]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[75f1704df0e38289]::query_impl::eval_to_const_value_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3d266d78c9b198e4]::query::erase::Erased<[u8; 24usize]>>
23: 0x11353704e - <rustc_query_impl[75f1704df0e38289]::query_impl::eval_to_const_value_raw::dynamic_query::{closure#2} as core[907a20686bf8bf7a]::ops::function::FnOnce<(rustc_middle[3d266d78c9b198e4]::ty::context::TyCtxt, rustc_middle[3d266d78c9b198e4]::ty::ParamEnvAnd<rustc_middle[3d266d78c9b198e4]::mir::interpret::GlobalId>)>>::call_once
24: 0x113348579 - rustc_query_system[13e780f7d1d88911]::query::plumbing::try_execute_query::<rustc_query_impl[75f1704df0e38289]::DynamicConfig<rustc_query_system[13e780f7d1d88911]::query::caches::DefaultCache<rustc_middle[3d266d78c9b198e4]::ty::ParamEnvAnd<rustc_middle[3d266d78c9b198e4]::mir::interpret::GlobalId>, rustc_middle[3d266d78c9b198e4]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[75f1704df0e38289]::plumbing::QueryCtxt, false>
25: 0x1135b8e2c - rustc_query_impl[75f1704df0e38289]::query_impl::eval_to_const_value_raw::get_query_non_incr::__rust_end_short_backtrace
26: 0x112b74b88 - rustc_middle[3d266d78c9b198e4]::query::plumbing::query_get_at::<rustc_query_system[13e780f7d1d88911]::query::caches::DefaultCache<rustc_middle[3d266d78c9b198e4]::ty::ParamEnvAnd<rustc_middle[3d266d78c9b198e4]::mir::interpret::GlobalId>, rustc_middle[3d266d78c9b198e4]::query::erase::Erased<[u8; 24usize]>>>
27: 0x112b79563 - <rustc_middle[3d266d78c9b198e4]::ty::context::TyCtxt>::const_eval_global_id
28: 0x112b78e50 - <rustc_middle[3d266d78c9b198e4]::ty::context::TyCtxt>::const_eval_resolve
29: 0x112dbf811 - <rustc_const_eval[298ced3d0b3bd135]::interpret::eval_context::InterpCx<rustc_const_eval[298ced3d0b3bd135]::const_eval::dummy_machine::DummyMachine>>::eval_mir_constant::{closure#0}
30: 0x112ec3849 - <rustc_mir_transform[f683d3911b24b415]::known_panics_lint::ConstPropagator>::eval_constant
31: 0x112ec47e6 - <rustc_mir_transform[f683d3911b24b415]::known_panics_lint::ConstPropagator as rustc_middle[3d266d78c9b198e4]::mir::visit::Visitor>::visit_assign
32: 0x112ec9df2 - <rustc_mir_transform[f683d3911b24b415]::known_panics_lint::ConstPropagator as rustc_middle[3d266d78c9b198e4]::mir::visit::Visitor>::visit_basic_block_data
33: 0x112ec41bc - <rustc_mir_transform[f683d3911b24b415]::known_panics_lint::ConstPropagator as rustc_middle[3d266d78c9b198e4]::mir::visit::Visitor>::visit_body
34: 0x112ec0b70 - <rustc_mir_transform[f683d3911b24b415]::known_panics_lint::KnownPanicsLint as rustc_mir_transform[f683d3911b24b415]::pass_manager::MirLint>::run_lint
35: 0x112e652fa - rustc_mir_transform[f683d3911b24b415]::pass_manager::run_passes_inner
36: 0x112f155c9 - rustc_mir_transform[f683d3911b24b415]::run_analysis_to_runtime_passes
37: 0x112f1517a - rustc_mir_transform[f683d3911b24b415]::mir_drops_elaborated_and_const_checked
38: 0x11358265a - rustc_query_impl[75f1704df0e38289]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[75f1704df0e38289]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3d266d78c9b198e4]::query::erase::Erased<[u8; 8usize]>>
39: 0x1133d8f4e - rustc_query_system[13e780f7d1d88911]::query::plumbing::try_execute_query::<rustc_query_impl[75f1704df0e38289]::DynamicConfig<rustc_query_system[13e780f7d1d88911]::query::caches::VecCache<rustc_span[51e7cf5b04f4660f]::def_id::LocalDefId, rustc_middle[3d266d78c9b198e4]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[75f1704df0e38289]::plumbing::QueryCtxt, false>
40: 0x1135982ea - rustc_query_impl[75f1704df0e38289]::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace
41: 0x11270ae48 - rustc_interface[ee26b89eef7e70ed]::passes::run_required_analyses
42: 0x11270d170 - rustc_interface[ee26b89eef7e70ed]::passes::analysis
43: 0x113582aca - rustc_query_impl[75f1704df0e38289]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[75f1704df0e38289]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3d266d78c9b198e4]::query::erase::Erased<[u8; 1usize]>>
44: 0x1133388ee - rustc_query_system[13e780f7d1d88911]::query::plumbing::try_execute_query::<rustc_query_impl[75f1704df0e38289]::DynamicConfig<rustc_query_system[13e780f7d1d88911]::query::caches::SingleCache<rustc_middle[3d266d78c9b198e4]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[75f1704df0e38289]::plumbing::QueryCtxt, false>
45: 0x11358f177 - rustc_query_impl[75f1704df0e38289]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
46: 0x111ce3e77 - <rustc_interface[ee26b89eef7e70ed]::queries::QueryResult<&rustc_middle[3d266d78c9b198e4]::ty::context::GlobalCtxt>>::enter::<core[907a20686bf8bf7a]::result::Result<(), rustc_span[51e7cf5b04f4660f]::ErrorGuaranteed>, rustc_driver_impl[e0e0c21a20d76ec4]::run_compiler::{closure#0}::{closure#1}::{closure#5}>
47: 0x111d4195d - rustc_interface[ee26b89eef7e70ed]::interface::run_compiler::<core[907a20686bf8bf7a]::result::Result<(), rustc_span[51e7cf5b04f4660f]::ErrorGuaranteed>, rustc_driver_impl[e0e0c21a20d76ec4]::run_compiler::{closure#0}>::{closure#1}
48: 0x111d2d59c - std[a533c313b02b6cfe]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[ee26b89eef7e70ed]::util::run_in_thread_with_globals<rustc_interface[ee26b89eef7e70ed]::util::run_in_thread_pool_with_globals<rustc_interface[ee26b89eef7e70ed]::interface::run_compiler<core[907a20686bf8bf7a]::result::Result<(), rustc_span[51e7cf5b04f4660f]::ErrorGuaranteed>, rustc_driver_impl[e0e0c21a20d76ec4]::run_compiler::{closure#0}>::{closure#1}, core[907a20686bf8bf7a]::result::Result<(), rustc_span[51e7cf5b04f4660f]::ErrorGuaranteed>>::{closure#0}, core[907a20686bf8bf7a]::result::Result<(), rustc_span[51e7cf5b04f4660f]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[907a20686bf8bf7a]::result::Result<(), rustc_span[51e7cf5b04f4660f]::ErrorGuaranteed>>
49: 0x111d43f1a - <<std[a533c313b02b6cfe]::thread::Builder>::spawn_unchecked_<rustc_interface[ee26b89eef7e70ed]::util::run_in_thread_with_globals<rustc_interface[ee26b89eef7e70ed]::util::run_in_thread_pool_with_globals<rustc_interface[ee26b89eef7e70ed]::interface::run_compiler<core[907a20686bf8bf7a]::result::Result<(), rustc_span[51e7cf5b04f4660f]::ErrorGuaranteed>, rustc_driver_impl[e0e0c21a20d76ec4]::run_compiler::{closure#0}>::{closure#1}, core[907a20686bf8bf7a]::result::Result<(), rustc_span[51e7cf5b04f4660f]::ErrorGuaranteed>>::{closure#0}, core[907a20686bf8bf7a]::result::Result<(), rustc_span[51e7cf5b04f4660f]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[907a20686bf8bf7a]::result::Result<(), rustc_span[51e7cf5b04f4660f]::ErrorGuaranteed>>::{closure#1} as core[907a20686bf8bf7a]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
50: 0x113f3f95b - std::sys::pal::unix::thread::Thread::new::thread_start::hc5e64771570de417
51: 0x7ff801f5318b - __pthread_start
rustc version: 1.83.0-nightly (7608018cb 2024-09-29)
platform: x86_64-apple-darwin
query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `main::promoted[0]`
#1 [eval_to_const_value_raw] simplifying constant for the type system `main::promoted[0]`
#2 [mir_drops_elaborated_and_const_checked] elaborating drops for `main`
#3 [analysis] running analysis passes on this crate
end of query stack
Note
Ice location:
rust/compiler/rustc_const_eval/src/interpret/cast.rs
Lines 460 to 471 in 7608018
@rustbot label +F-coerce_unsized
Metadata
Metadata
Assignees
Labels
Category: This is a bug.The `CoerceUnsized` traitIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Status: This bug is tracked inside the repo by a `known-bug` test.Status: A Minimal Complete and Verifiable Example has been found for this issueRelevant to the compiler team, which will review and decide on the PR/issue.
Type
Projects
Status
Todo