Skip to content

Change opaque types to not be structural match. #72156

Closed
@lcnr

Description

@lcnr

The following currently passes the structural match check and causes an ICE later on:
(now that #72153 has landed, this emits an error)

#![feature(const_fn, type_alias_impl_trait)]

type F = impl Send;

// This does not implement structural match
struct A;

const fn value(a: A) -> F {
    a
}

const V: F = value(A);

fn main() {
    
    match value(A) {
        V => println!("hey"),
    }
}

I believe we have to either leak the structural match property of opaque types,
(similar to Send and Sync afaict) or forbid this entirely.

I am in favor of the second option for now. It should not be a breaking change to go from the
second to the first later on.

This issue concerns the implementation in #72153

@eddyb @pnkfelix @RalfJung

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions