Closed
Description
Example code:
let mem: &[u8] = &[48, 49];
let ptr = mem.as_ptr() as *const str;
let s = unsafe { &*ptr };
Error message:
error: internal compiler error: translating unsupported cast: *const u8 (cast_pointer) -> *const str (cast_other)
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: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', /Users/swizard/distr/rust/src/libsyntax/diagnostic.rs:190
stack backtrace:
1: 0x105f01957 - sys::backtrace::write::h49bc1af3bff4a6e3DJC
2: 0x105f2f873 - panicking::on_panic::h22918d2e20ddf008PxI
3: 0x105e53cbe - rt::unwind::begin_unwind_inner::hb0f5c720a6629d10qfI
4: 0x10563b19e - rt::unwind::begin_unwind::h13792904101880946349
5: 0x10563b9e9 - diagnostic::Handler::bug::h8d018cb8efa3e647EsB
6: 0x102f32627 - session::Session::bug::he24b74119a1174bbFPq
7: 0x1029c1358 - trans::expr::trans_imm_cast::h0dc669e5f6c002d8nKj
8: 0x1029a82e6 - trans::expr::trans_unadjusted::h86976c6745580e14TXh
9: 0x10295a53c - trans::expr::trans_into::hefe6c24c6801eb34gfh
10: 0x102a7ad1a - trans::_match::mk_binding_alloca::h16979327121447448331
11: 0x10295977f - trans::base::init_local::h45ac8135c05a5146NMs
12: 0x10295b342 - trans::controlflow::trans_block::h8c650fbe27085d2cH6d
13: 0x102a3b4f5 - trans::base::trans_closure::h46864fd94aa01bc0Qtt
14: 0x102942c83 - trans::base::trans_fn::h2ca708b7c163d918zEt
15: 0x10294463e - trans::monomorphize::monomorphic_fn::h95fbd095b702f0baYtd
16: 0x102989b81 - trans::callee::trans_fn_ref_with_substs::h1994bdb61afbe636Zbg
17: 0x102988a2e - trans::meth::trans_static_method_callee::hf8b89488d2117b8dNAy
18: 0x1029859ca - trans::callee::trans::hbb34a5eec289d1c9jPf
19: 0x10299c33b - trans::callee::trans_call_inner::h8192340426532286712
20: 0x1029aa770 - trans::expr::trans_rvalue_dps_unadjusted::h27b9d0cd52a394f1mti
21: 0x10295a51c - trans::expr::trans_into::hefe6c24c6801eb34gfh
22: 0x102a7ad1a - trans::_match::mk_binding_alloca::h16979327121447448331
23: 0x10295977f - trans::base::init_local::h45ac8135c05a5146NMs
24: 0x10295b342 - trans::controlflow::trans_block::h8c650fbe27085d2cH6d
25: 0x102a3b4f5 - trans::base::trans_closure::h46864fd94aa01bc0Qtt
26: 0x102942c83 - trans::base::trans_fn::h2ca708b7c163d918zEt
27: 0x102944592 - trans::monomorphize::monomorphic_fn::h95fbd095b702f0baYtd
28: 0x102989b81 - trans::callee::trans_fn_ref_with_substs::h1994bdb61afbe636Zbg
29: 0x102987f57 - trans::callee::trans_fn_ref::h63f04e40db0908572Zf
30: 0x102985bd0 - trans::callee::trans::hbb34a5eec289d1c9jPf
31: 0x10299c33b - trans::callee::trans_call_inner::h8192340426532286712
32: 0x1029aa770 - trans::expr::trans_rvalue_dps_unadjusted::h27b9d0cd52a394f1mti
33: 0x10295a51c - trans::expr::trans_into::hefe6c24c6801eb34gfh
34: 0x102959492 - trans::controlflow::trans_stmt_semi::he0a71a03e8e22f97L5d
35: 0x10295b317 - trans::controlflow::trans_block::h8c650fbe27085d2cH6d
36: 0x1029a9bad - trans::expr::trans_rvalue_dps_unadjusted::h27b9d0cd52a394f1mti
37: 0x10295a51c - trans::expr::trans_into::hefe6c24c6801eb34gfh
38: 0x10295b6a0 - trans::controlflow::trans_block::h8c650fbe27085d2cH6d
39: 0x102a3b4f5 - trans::base::trans_closure::h46864fd94aa01bc0Qtt
40: 0x102942c83 - trans::base::trans_fn::h2ca708b7c163d918zEt
41: 0x10293d4bd - trans::base::trans_item::h46b9d96ec061ef10P2t
42: 0x102a43fc7 - trans::base::trans_crate::h2a7f765e28da6987lZu
43: 0x10236a82c - driver::phase_4_translate_to_llvm::hb12845c52d9d2a39aOa
44: 0x10234217e - driver::compile_input::hf700a572a1239378Qba
45: 0x1023ffd35 - run_compiler::h2254195776d5d4d5S4b
46: 0x1023fd502 - boxed::F.FnBox<A>::call_box::h6405845031818806926
47: 0x1023fc9f7 - rt::unwind::try::try_fn::h692286709647191617
48: 0x105fbc4b8 - rust_try_inner
49: 0x105fbc4a5 - rust_try
50: 0x1023fccea - boxed::F.FnBox<A>::call_box::h15513867904557068020
51: 0x105f18d5d - sys::thread::create::thread_start::h320d70da47133ff2weH
52: 0x7fff8f86f267 - _pthread_body
53: 0x7fff8f86f1e4 - _pthread_start
Rust:
rustc 1.0.0-dev (b3c5507f3 2015-04-05) (built 2015-04-05)
OS:
Darwin pair 14.1.0 Darwin Kernel Version 14.1.0: Thu Feb 26 19:26:47 PST 2015; root:xnu-2782.10.73~1/RELEASE_X86_64 x86_64