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

Autoref/autoderef for operators #63

Merged
merged 2 commits into from
Aug 24, 2021

Conversation

Mark-Simulacrum
Copy link
Member

Also extracting from rust-lang/rust#44619, in concert with #62.

r? @rust-lang/lang

@joshtriplett
Copy link
Member

Looks good to me!

@Mark-Simulacrum
Copy link
Member Author

@nikomatsakis Did you intend to mere this or were you waiting on something?

@estebank
Copy link

Would a conversation about autoderef behavior in patterns be part of this?

@Mark-Simulacrum
Copy link
Member Author

I personally see that as pretty orthogonal.

- are never quite sufficient (always more references are possible)
- can cause inference regressions, as the compiler cannot in general know that
`&T + &T` is equivalent to `u64 + u64`.

Copy link
Member

@joshtriplett joshtriplett Jun 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this note accurately captures the primary benefits of this: the compiler could avoid inference failures by considering the reference and non-reference possibilities without them being completely separate impls.

It might be worth mentioning something here about other tradeoffs. And in particular, we should consider whether there are circumstances where we might not want this behavior for a type, and whether people should be able to opt into or out of this behavior for a type.

@scottmcm scottmcm self-assigned this Jun 2, 2021
@scottmcm scottmcm merged commit abc4087 into rust-lang:master Aug 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants