Skip to content

DST example fails to codegen #566

Closed

Description

@adpaco

The following example from The Rustonomicon/Data Layout/Exotically Sized Types/47.rs shown below

// compile-flags: --edition 2018
#![allow(unused)]
struct MySuperSliceable<T: ?Sized> {
    info: u32,
    data: T,
}

pub fn main() {
    let sized: MySuperSliceable<[u8; 8]> = MySuperSliceable {
        info: 17,
        data: [0; 8],
    };

    let dynamic: &MySuperSliceable<[u8]> = &sized;

    // prints: "17 [0, 0, 0, 0, 0, 0, 0, 0]"
    println!("{} {:?}", dynamic.info, &dynamic.data);
}

fails to codegen with

thread 'rustc' panicked at 'Only an array can be cast to a slice.  Found types Adt(MySuperSliceable, [[u8; 8]]) and Adt(MySuperSliceable, [[u8]])', compiler/rustc_codegen_rmc/src/codegen/rvalue.rs:1076:37
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Activity

  1. added
    [C] Bug
    [F] Crash
    on Oct 19, 2021
  2. zhassan-aws commented on Mar 16, 2022

    @zhassan-aws
    Contributor

    Still crashes with the same signature as of af11d38d93a.

  3. self-assigned this
    on Mar 22, 2022
  4. moved this to In Progress in Kani v0.3on May 19, 2022
  5. 4 remaining items

  6. moved this to In Progress in Kani 0.15on Nov 2, 2022
  7. added this to the Maintenance milestone on Nov 2, 2022
  8. Repository owner moved this from In Progress to Done in Kani v0.3on Nov 14, 2022
  9. moved this to Done in Kani v0.8on Nov 14, 2022
  10. Repository owner moved this from In Progress to Done in Kani 0.15on Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

[C] Bug[F] Crash

Type

No type

Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions