Cannot implement certain built-in traits like `Copy` or `Drop` for free alias types that expand to otherwise legal self type
Open
@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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.