Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
alexreg opened this issue Dec 22, 2018 · 2 comments
Closed
Labels
A-traits Area: Trait system C-bug Category: This is a bug.

Comments

@alexreg
Copy link
Contributor

alexreg commented Dec 22, 2018

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

@alexreg
Copy link
Contributor Author

alexreg commented Dec 22, 2018

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.

@arielb1
Copy link
Contributor

arielb1 commented Dec 22, 2018

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

@Centril Centril added A-traits Area: Trait system C-bug Category: This is a bug. labels Dec 28, 2018
bors added a commit that referenced this issue Jan 5, 2019
…akis

Add support for trait-objects without a principal

The hard-error version of #56481 - should be merged after we do something about the `traitobject` crate.

Fixes #33140.
Fixes #57057.

r? @nikomatsakis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-traits Area: Trait system C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

3 participants