Skip to content

ICE: translating unsupported cast: *const str (cast_other) -> *const Slice<u8> (cast_pointer) #22554

Closed
@JinShil

Description

@JinShil

Code to reproduce.

#[repr(C)]
#[allow(dead_code)]
struct Slice<T> {
    data: *const T,
    len: usize,
}

fn main() {
    let text = "Hello World!\n";
    let t1 = text as *const str;
    let t2 = t1 as *const Slice<u8>;
}

Rust Playpen: http://is.gd/jfBLrG

Output

error: internal compiler error: translating unsupported cast: *const str (cast_other) -> *const Slice<u8> (cast_pointer)
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:189

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions