Skip to content

Cannot impl auto traits for free alias types that expand to otherwise legal self type #157756

@fmease

Description

@fmease

We just need to call expand_free_alias_tys on the self type in the relevant place in rustc_hir_analysis::coherence::orphan.

#![feature(lazy_type_alias)]

struct Local;
type Alias = Local;

unsafe impl Sync for Alias {} //~ ERROR cross-crate traits with a default impl, like `Sync`, can only be implemented for a struct/enum type, not `Alias`
#![feature(lazy_type_alias, auto_traits)]

auto trait Marker {}

struct Local;
type Alias = Local;

impl Marker for Alias {} //~ ERROR traits with a default impl, like `Marker`, cannot be implemented for type alias `Alias`

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-auto-traitsArea: auto traits (e.g., `auto trait Send {}`)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