rust-lang / rust-lang/rust

Cannot implement certain built-in traits like `Copy` or `Drop` for free alias types that expand to otherwise legal self type

Open
#157,755 1 comment 0 reactions 1 assignee View on GitHub

@josetorrs is already working on this.

Since Jul 2, 2026.

A-coherence C-bug F-checked_type_aliases T-compiler T-types
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

We just need to call expand_free_alias_tys on the self type in the relevant places in rustc_hir_analysis::coherence::builtin. It's a bit annoying, yh.

Example reproducers:

#![feature(lazy_type_alias)]

#[derive(Clone)]
pub struct Local;

type Alias = Local;
impl Copy for Alias {} //~ ERROR the trait `Copy` cannot be implemented for this type
#![feature(lazy_type_alias)]

pub struct Local;

type Alias = Local;
impl Drop for Alias {} //~ ERROR the `Drop` trait may only be implemented for local structs, enums, and unions

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.