Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

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

Closed

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".

Activity

  1. arielb1 commented on Apr 21, 2016

    @arielb1
    ContributorAuthor

    I think this should be fixed to not compiling, right?

  2. durka commented on Apr 22, 2016

    @durka
    Contributor

    Why should they be different?

  3. arielb1 commented on Apr 22, 2016

    @arielb1
    ContributorAuthor

    They should be the same type (rather, this code should not compile) The bug is that they are different.

  4. durka commented on Apr 22, 2016

    @durka
    Contributor

    I still don't understand, sorry... what compile error do you expect? If they were the same type, it would print "types are equal"? Are you saying that neither of them should be accepted as a type?

  5. arielb1 commented on Apr 22, 2016

    @arielb1
    ContributorAuthor

    @durka

    I am going to write a PR that will make neither of them be accepted as a type.

  6. self-assigned this
    on Apr 22, 2016
  7. durka commented on Apr 22, 2016

    @durka
    Contributor

    Okay... maybe in the PR you can explain why, as I keep asking? FWIW, Any + Send + Sync and Any + Sync + Send are equal using your code above.

  8. arielb1 commented on Apr 22, 2016

    @arielb1
    ContributorAuthor

    The problem type is Sync + Send without any additional trait. Any + Sync + Send is a perfectly good type, and will not be removed.

  9. durka commented on Apr 22, 2016

    @durka
    Contributor

    Is it because they are both marker traits? Or both auto traits?

  10. cyplo commented on Apr 14, 2017

    @cyplo
    Contributor

    Hello ! Any changes on this one ?

  11. RalfJung commented on Jun 14, 2017

    @RalfJung
    Member

    The two types differing it at least consistent with this being rejected due to a type mismatch:

    fn foo(x: Box<Send+Sync>) -> Box<Sync+Send> { x }
  12. added
    A-type-system
    and removed on Jun 23, 2017
  13. added
    C-bug
    on Jul 25, 2017
  14. 8 remaining items

  15. added a commit that references this issue on Dec 18, 2018
  16. added a commit that references this issue on Jan 5, 2019
    2fba17f
  17. added a commit that references this issue on Feb 1, 2021
  18. added a commit that references this issue on Feb 1, 2021
  19. added a commit that references this issue on Mar 6, 2021
  20. added a commit that references this issue on Mar 6, 2021
  21. added a commit that references this issue on Mar 7, 2021
  22. added
    A-dyn-trait
    T-types
    F-specialization
    on Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-dyn-traitA-type-systemC-bugF-specializationT-types

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions