rust-lang / rust-lang/rust

`derive(CoercePointee)` accepts `?Sized + Sized`

Open
#148,399 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug F-derive_coerce_pointee T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue's Rust snippet with the nightly compiler and inspect the derive(CoercePointee) validation that checks ?Sized bounds. Determine whether ?Sized + Sized and bounds such as ?Sized + Clone should be rejected, then add regression coverage showing the intended diagnostic or acceptance behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.