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

Detect double reference when applying binary op #38617

Merged
merged 2 commits into from
Jan 28, 2017

Conversation

pnkfelix
Copy link
Member

@pnkfelix pnkfelix commented Dec 26, 2016

let vr = v.iter().filter(|x| {
    x % 2 == 0
});

will now yield the following compiler output:

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 #33877


Thanks to @estebank for providing the original PR #34420 (of which this is a tweaked rebase).

@rust-highfive
Copy link
Collaborator

r? @arielb1

(rust_highfive has picked a reviewer for you, use r? to override)

@pnkfelix pnkfelix changed the title Double reference Detect double reference when applying binary op Dec 26, 2016
@pnkfelix
Copy link
Member Author

Thanks also to @rkruppe for providing the lion's share of the review effort here.

@pnkfelix
Copy link
Member Author

@bors r=pnkfelix

@bors
Copy link
Contributor

bors commented Dec 26, 2016

📌 Commit 98218b3 has been approved by pnkfelix

@pnkfelix
Copy link
Member Author

@bors r- Travis failed and it looks legit (but trivial to fix)

```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
… deref.

drive-by: fix merge conflict; fix test expected error output post rebase.
@pnkfelix
Copy link
Member Author

pnkfelix commented Jan 4, 2017

@bors r=pnkfelix

@bors
Copy link
Contributor

bors commented Jan 4, 2017

📌 Commit 98218b3 has been approved by pnkfelix

@pnkfelix
Copy link
Member Author

pnkfelix commented Jan 4, 2017

@bors rollup

steveklabnik added a commit to steveklabnik/rust that referenced this pull request 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).
@pnkfelix
Copy link
Member Author

pnkfelix commented Jan 6, 2017

@bors r+ b8669df rollup

@bors
Copy link
Contributor

bors commented Jan 6, 2017

💡 This pull request was already approved, no need to approve it again.

@bors
Copy link
Contributor

bors commented Jan 6, 2017

🙀 b8669dff556a03ca37b39cbb81be65c94d24defe is not a valid commit SHA. Please try again with 98218b3.

@pnkfelix
Copy link
Member Author

pnkfelix commented Jan 6, 2017

@bors r+ b8669df rollup

@bors
Copy link
Contributor

bors commented Jan 6, 2017

💡 This pull request was already approved, no need to approve it again.

@bors
Copy link
Contributor

bors commented Jan 6, 2017

🙀 b8669df is not a valid commit SHA. Please try again with 98218b3.

@bluss
Copy link
Member

bluss commented Jan 6, 2017

@bors r-

@bluss
Copy link
Member

bluss commented Jan 6, 2017

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jan 6, 2017

📌 Commit 98218b3 has been approved by bluss

@bluss
Copy link
Member

bluss commented Jan 6, 2017

@bors r-

@pnkfelix
Copy link
Member Author

pnkfelix commented Jan 6, 2017

@bors r+ b8669df rollup

@bors
Copy link
Contributor

bors commented Jan 6, 2017

🙀 b8669df is not a valid commit SHA. Please try again with 98218b3.

alexcrichton added a commit to alexcrichton/rust that referenced this pull request 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).
bors added a commit that referenced this pull request Jan 28, 2017
@bors bors merged commit b8669df into rust-lang:master Jan 28, 2017
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.

None yet

6 participants