Skip to content

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

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`

Activity

  1. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    A-auto-traitsArea: auto traits (e.g., `auto trait Send {}`)
    T-typesRelevant to the types team, which will review and decide on the PR/issue.
    F-checked_type_aliases`#![feature(checked_type_aliases)]` (formerly: `lazy_type_alias`)
    on Jun 11, 2026
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jun 11, 2026
  3. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jun 11, 2026
  4. added a commit that references this issue on Jul 3, 2026
    94b423d
  5. added 2 commits that reference this issue on Jul 5, 2026
    25cd62b
    09300b8
  6. added a commit that references this issue on Jul 5, 2026
    f7a3657
  7. added a commit that references this issue on Jul 6, 2026
    c42ea48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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-checked_type_aliases`#![feature(checked_type_aliases)]` (formerly: `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

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions