Skip to content

rustc_layout(debug) does not complain about nonsense types #115676

Closed
@RalfJung

Description

@RalfJung

I tried this code:

#![feature(rustc_attrs)]

struct S<T>(T, T);

#[rustc_layout(debug)]
type T = S<str>;

This should complain about using an unsized type in a way that doesn't work. Instead, it prints some layout.

Probably the rustc_layout logic needs to fire of some sort of query to ensure the type is well-formed, or something like that? I know type aliases only get WF-checked "on use", and it seems somehow this attribute doesn't count as a use. How can we make it count as a use?

Cc @oli-obk @lcnr

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-layoutArea: Memory layout of typesC-enhancementCategory: An issue proposing an enhancement or a PR with one.F-rustc_attrsInternal rustc attributes gated on the `#[rustc_attrs]` feature gate.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions