Compound assignment desugaring doesn't take into account autoderef
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Documentation
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- rust
- Domain
- documentation
Research direction
Start with the compound-assignment section linked in the Rust Reference and compare its stated desugaring with the provided autoderef example. Verify the behavior against the example, then update the reference text so it accurately distinguishes += from an .add_assign method call; done when the documentation no longer implies equivalent autoderef behavior.
Written by the indexing model from the issue text.
Description
In the reference, compound assignment expressions with non-primitive operands are described as being desugared into method calls. That is, x += y is turned into x.add_assign(y).
This desugaring is incorrect. The += form does not do autoderef, while the .add_assign form does autoderef. For example:
use std::ops::AddAssign;
fn foo<T: AddAssign<U>, U>(x: &mut &mut T, y: U) {
// This compiles
x.add_assign(y);
// This doesn't compile
x += y;
}
- Dominant language
- Rust
- Stars
- 1.6k
- Forks
- 609
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 7
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rust-lang/reference
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
rust-lang/reference#2371 · 3 comments ·
Maintainers usually reply within 1 day
-
A-const-eval A-undefined-behavior
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
rust-lang/reference#2266 · 1 comment ·
Maintainers usually reply within 1 day
-
A-resolve
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
All issues in rust-lang/reference
Similar issues
-
Change output crossing a compactsize boundary leaves the fee slightly below the requested feerateOpenbug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
bitcoindevkit/bdk_wallet#578 ·
Maintainers usually reply within 8 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
521xueweihan/HelloGitHub#3832 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
canonical/opentelemetry-collector-operator#409 ·
Maintainers usually reply within 1 day