Skip to content

Send + Sync and Sync + Send are distinct valid types #33140

Closed
@arielb1

Description

@arielb1

STR

#![feature(specialization)]

trait Teq<U:?Sized> {
    fn types_eq() -> &'static str;
}

impl<U:?Sized> Teq<U> for U {
    fn types_eq() -> &'static str { "types are equal" }
}

impl<U:?Sized, V:?Sized> Teq<U> for V {
    default fn types_eq() -> &'static str { "types differ" }
}

fn main() {
    println!("{}", <Send+Sync as Teq<Sync+Send>>::types_eq());
}

Expected Result

This should not compile, or should print "types are equal"

Actual Result

This prints "types differ".

Metadata

Metadata

Assignees

Labels

A-dyn-traitArea: trait objects, vtable layoutA-type-systemArea: Type systemC-bugCategory: This is a bug.F-specialization`#![feature(specialization)]`T-typesRelevant to the types team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions