You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
trait Foo {
fn get(&self) -> u32;
}
struct Bar {
something: u32
}
impl Foo for Bar {
fn get(&self) -> u32 {
self.something
}
}
fn main() {
let x = Bar { something: 4 };
let y = &x;
let z: *const Foo = y as *const _ as *const _;
let value = unsafe { (*z).get() };
println!("Hello, world! {}", value);
}
Outputs:
error: internal compiler error: translating unsupported cast: *const Bar (cast_pointer) -> *const Foo (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>', /home/rustbuild/src/rust-buildbot/slave/beta-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:209
The text was updated successfully, but these errors were encountered:
Probably addressed in #24333 or should be if it isn't.
But as a quick fix, you don't need that last as *const _ cast. The first one will take you to *const Bar and then since you have z: *const Foo it'll get coerced to a fat pointer there.
luqmana
added
the
I-ICE
Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
label
May 15, 2015
Playpen: http://is.gd/BpXFCU
Outputs:
The text was updated successfully, but these errors were encountered: