Skip to content

Auto traits do not get de-duplicated properly when principal trait is auto trait #57057

Closed

Description

@alexreg

This was an issue that came up during work on #55994.

Basically, a bug in the de-duplication code means that dyn Send is a different type from dyn Send + Send, and likewise dyn Sync + Send is different from dyn Sync + Send + Sync. However, this clearly should not be the case, and indeed dyn Send + Send is the same type as dyn Send + Send + Send. (Note, this is only tangentially related to the lint #56522.)

Apart from potentially surprising behaviour, the issue with the above lies with trait impls and coherence. I am unaware of a specific ICE that can arise because of it, but it is probably UB in general.

trait Foo {}

impl Foo for dyn Send {}

impl Foo for dyn Send + Send {}

playground

trait Foo {}

impl Foo for dyn Send + Send {}

impl Foo for dyn Send + Send + Send {}

playground

CC @nikomatsakis @arielb1

Activity

  1. alexreg commented on Dec 22, 2018

    @alexreg
    ContributorAuthor

    Note, I intend to fix this in #55994 of course, but this services as a reference point at least, and will be cited in code.

  2. arielb1 commented on Dec 22, 2018

    @arielb1
    Contributor

    This will be fixed in #56837. This is consistent with itself and can't cause UB of any kind.

  3. added a commit that references this issue on Jan 5, 2019
    2fba17f
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-trait-systemArea: Trait systemC-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions