-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Unexpected compiler error E0308 on arithmetic with borrowed values #28293
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
Comments
It's a standard library quirk - operator minus (std::ops::Sub) is implemented for all combinations of values and references: |
I've tried to add the needed impls of |
/cc @rust-lang/libs , should these extra impls be added? /cc @rust-lang/lang , is this a breaking change that's worth making or not? |
The motivation to provide However, the comparison operators and |
I have mixed feelings on combinatoric impls so people don't have to think about indirections too much. @sellibitze's summary is apt. |
I agree the summary is good. I personally don't feel a strong need to make On Mon, Sep 28, 2015 at 10:13 AM, Alexis Beingessner <
|
Based on comments seems like this should be closed as intended behavior? |
I'm going to close this -- I don't think we want these impls at this point. Thanks for the issue, though! |
I've faced with compiler error on arithmetic operations with borrowed values. After some simplification of my code, it was reduced to following program:
Here we have two
if
statements. First compiles OK, and second fails with compiler error E0308: It complains on "incompatible" typesi32
and&i32
. However, expression in firstif
also contains variables of different types, and does not irritate Rust compiler.I suppose it's a bug, because this behaviour is counter-intuitive.
Note: I've tested it on stable 1.2.0 and nightly versions (via http://play.rust-lang.org) - results are the same.
The text was updated successfully, but these errors were encountered: