-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Confusing error message when applying binary operation on the wrong type #33877
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
Comments
estebank
added a commit
to estebank/rust
that referenced
this issue
Jul 6, 2016
```rust let vr = v.iter().filter(|x| { x % 2 == 0 }); ``` will now yield the following compiler output: ```bash ERROR binary operation `%` cannot be applied to type `&&_` NOTE this is a reference of a reference to a type that `%` can be applied to, you need to dereference this variable once for this operation to work NOTE an implementation of `std::ops::Rem` might be missing for `&&_` ``` The first NOTE is new. Bug rust-lang#33877
pnkfelix
pushed a commit
to pnkfelix/rust
that referenced
this issue
Dec 26, 2016
```rust let vr = v.iter().filter(|x| { x % 2 == 0 }); ``` will now yield the following compiler output: ```bash ERROR binary operation `%` cannot be applied to type `&&_` NOTE this is a reference of a reference to a type that `%` can be applied to, you need to dereference this variable once for this operation to work NOTE an implementation of `std::ops::Rem` might be missing for `&&_` ``` The first NOTE is new. Bug rust-lang#33877
pnkfelix
pushed a commit
to pnkfelix/rust
that referenced
this issue
Jan 3, 2017
```rust let vr = v.iter().filter(|x| { x % 2 == 0 }); ``` will now yield the following compiler output: ```bash ERROR binary operation `%` cannot be applied to type `&&_` NOTE this is a reference of a reference to a type that `%` can be applied to, you need to dereference this variable once for this operation to work NOTE an implementation of `std::ops::Rem` might be missing for `&&_` ``` The first NOTE is new. Bug rust-lang#33877
steveklabnik
added a commit
to steveklabnik/rust
that referenced
this issue
Jan 4, 2017
Detect double reference when applying binary op ``` rust let vr = v.iter().filter(|x| { x % 2 == 0 }); ``` will now yield the following compiler output: ``` bash ERROR binary operation `%` cannot be applied to type `&&_` NOTE this is a reference of a reference to a type that `%` can be applied to, you need to dereference this variable once for this operation to work NOTE an implementation of `std::ops::Rem` might be missing for `&&_` ``` The first NOTE is new. Fix rust-lang#33877 ---- Thanks to @estebank for providing the original PR rust-lang#34420 (of which this is a tweaked rebase).
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
Jan 28, 2017
Detect double reference when applying binary op ``` rust let vr = v.iter().filter(|x| { x % 2 == 0 }); ``` will now yield the following compiler output: ``` bash ERROR binary operation `%` cannot be applied to type `&&_` NOTE this is a reference of a reference to a type that `%` can be applied to, you need to dereference this variable once for this operation to work NOTE an implementation of `std::ops::Rem` might be missing for `&&_` ``` The first NOTE is new. Fix rust-lang#33877 ---- Thanks to @estebank for providing the original PR rust-lang#34420 (of which this is a tweaked rebase).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following snippet:
produces the following error:
How is anybody supposed to extract from
binary operation % cannot be applied to type &&_
that one forgot the&x
in the closure? The explanation E0369 doesn't help here.Maybe a better thing for rustc would be to "try" and see if a combination of
&
and&mut
would have solved the issue and offer a suggestion of the form "Did you meant to makex
a reference here?".The text was updated successfully, but these errors were encountered: