Skip to content

dyn-star: "needs to be a pointer-sized type" but the type is pointer-sized #107696

Closed
@RalfJung

Description

@RalfJung

Consider this code:

#![feature(dyn_star)]
#![allow(incomplete_features)]

use std::fmt::Debug;

fn main() {
    let _dyn_i: dyn* Debug = [0u8; std::mem::size_of::<usize>()];
}

This raises an error:

error[E0277]: `[u8; 8]` needs to be a pointer-sized type

However, it is a pointer-sized type. Looks like somehow that's still not good enough?

On a related note, I am surprised that this PointerSize marker trait (according to its documentation) cares only about size and not alignment. I think things would go very wrong if we had a type that had ptr size but larger alignment than a ptr, and then turned that into a dyn*...

Metadata

Metadata

Assignees

No one assigned

    Labels

    F-dyn_star`#![feature(dyn_star)]`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions