Skip to content

RFC: Change operator method lookup to be less magical #283

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

Closed
rust-highfive opened this issue Sep 24, 2014 · 1 comment
Closed

RFC: Change operator method lookup to be less magical #283

rust-highfive opened this issue Sep 24, 2014 · 1 comment

Comments

@rust-highfive
Copy link

Issue by nikomatsakis
Wednesday Feb 13, 2013 at 21:40 GMT

For earlier discussion, see rust-lang/rust#4920

This issue was labelled with: A-traits, A-typesystem, B-RFC, I-cleanup, P-backcompat-lang in the Rust repository


Right now, operator "methods" proceed according to the same logic as any other method. But this leads to surprising results like this: https://gist.github.com/bstrie/4948410

Also, operators are already handled somewhat specially because we auto-ref their arguments. This means that you can write val1-of-my-linear-type == val2-of-my-linear-type and it doesn't move or do anything creepy (to call eq explicitly, in contrast, you'd write val1-of-my-linear-type.eq(&val2-of-my-linear-type)).

I think method lookup for operators should never apply any automatic transformations to the receiver or arguments, other than the current auto-ref behavior (which means that a OP b is kind of implicitly (&a).OP(&b))

@pcwalton I expect you in particular might have an opinion about this.

@nikomatsakis
Copy link
Contributor

This has largely been covered by other RFCs and/or implemented. Closing.

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

No branches or pull requests

2 participants