Skip to content

derive(CoercePointee) accepts ?Sized + Sized #148399

@theemathas

Description

@theemathas

derive(CoercePointee) checks whether the generic type is ?Sized, and rejects the code if it is not marked as ?Sized. However, making it ?Sized + Sized is still accepted by the macro. That is, the following code compiles:

#![feature(derive_coerce_pointee)]

use std::marker::CoercePointee;

#[derive(CoercePointee)]
#[repr(transparent)]
struct Foo<T: ?Sized + Sized>(*const T);

Is the fact that ?Sized is required effectively just a lint, or is it important for some other reason? Currently, the check doesn't actually enforce anything, and it's possible to accidentally require Sized with something like T: ?Sized + Clone.

Meta

Reproducible on the playground with version 1.93.0-nightly (2025-11-01 bd3ac0330018c23b111b)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-derive_coerce_pointeeFeature: RFC 3621's oft-renamed implementationneeds-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions