Skip to content

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

@fmease

Description

@fmease

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-coherenceArea: CoherenceC-bugCategory: This is a bug.F-lazy_type_alias`#![feature(lazy_type_alias)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    To Do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions