Skip to content

Comments

Document assignment expression as coercion site#1954

Merged
ehuss merged 1 commit intorust-lang:masterfrom
paldepind:coercion-site-assignment
Feb 19, 2026
Merged

Document assignment expression as coercion site#1954
ehuss merged 1 commit intorust-lang:masterfrom
paldepind:coercion-site-assignment

Conversation

@paldepind
Copy link
Contributor

I was recently confused as for why this is allowed in Rust

let mut a = &12;
let b = &&34;
a = b; 

as I couldn't find that documented anywhere.

I was told that assignment expressions are in fact coercion sites which explains the example above.

This PR documents assignment expressions as coercion sites in the reference.

@rustbot rustbot added the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Aug 2, 2025
@ehuss
Copy link
Contributor

ehuss commented Feb 3, 2026

Thanks! This seems correct to me.

I'm also feeling like the coercion site listing is also missing all of the bin operators.

Can someone at @rust-lang/types maybe give this a quick review? And let us know if it would make sense to also include bin ops, too, and if there are any complications are caveats around those. (The code for that seems a bit more tricky to follow.)

@jackh726
Copy link
Member

jackh726 commented Feb 3, 2026

This looks correct. I'm not sure about bin ops in general.

@paldepind
Copy link
Contributor Author

Thanks for taking a look! I'm happy to see this gaining some traction as it's such a simple gap to get filled out.

I don't think binary operators needs to be mentioned as they can be understood by their desugaring. E.g., a + b is equivalent to std::ops::Add::add(a, b) and then a and b being coercion sites falls out the fact that arguments are coercion sites.

Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ehuss ehuss added this pull request to the merge queue Feb 19, 2026
Merged via the queue into rust-lang:master with commit 70c99cb Feb 19, 2026
5 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Feb 19, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 24, 2026
Update books

## rust-embedded/book

1 commits in fe88fbb68391a465680dd91109f0a151a1676f3e..99d0341ff4e06757490af8fceee790c4ede50bc0
2026-02-11 12:58:13 UTC to 2026-02-11 12:58:13 UTC

- Remove triagebot.toml (rust-embedded/book#405)

## rust-lang/reference

21 commits in addd0602c819b6526b9cc97653b0fadca395528c..442cbef9105662887d5eae2882ca551f3726bf28
2026-02-22 02:55:12 UTC to 2026-02-11 01:41:05 UTC

- Document importing path-segment keyword (rust-lang/reference#2136)
- avoid needless dereference (rust-lang/reference#2180)
- Use `clobber_abi`s corresponding to the called functions in `[asm.abi-clobbers.many]`'s example. (rust-lang/reference#2170)
- expr.paren.evaluation: fix and make more simple (rust-lang/reference#2158)
- const-eval.const-context.outer-generics: make more clear/obvious (rust-lang/reference#2159)
- Nightly test links: update rust branch name (use `main`) (rust-lang/reference#2185)
- tools/xtask: update rust branch name for linkcheck script (use `main`) (rust-lang/reference#2184)
- specify `if let` guards with updated scoping rules (rust-lang/reference#1957)
- Document assignment expression as coercion site (rust-lang/reference#1954)
- Remove exception WRT same-crate `non_exhaustive` reads (rust-lang/reference#2162)
- Add negative lookahead (rust-lang/reference#2172)
- Switch to new range syntax (rust-lang/reference#2173)
- add mdbook output for dev-guide to ignore file (rust-lang/reference#2178)
- Fix rule name for while syntax (rust-lang/reference#2175)
- block-expr: add new rule expr.block.result-value (rust-lang/reference#2174)
- lifetime-elision.md: add some missing periods (rust-lang/reference#2176)
- Add cut operator (`^`) to grammar (rust-lang/reference#2104)
- dev-guide stabilization.md: add missing "not" (rust-lang/reference#2167)
- Add method call and await expr for Dot in syntax index (rust-lang/reference#2163)
- Fix sort of punctuation list (rust-lang/reference#2161)
- Add a contributor guide (rust-lang/reference#2097)

## rust-lang/rust-by-example

1 commits in bac931ef1673af63fb60c3d691633034713cca20..5383db524711c0c9c43c3ca9e5e706089672ed6a
2026-02-16 12:02:33 UTC to 2026-02-16 12:02:33 UTC

- 1.2.2 Display: Fix typo in bonus instructions (before -> after) (rust-lang/rust-by-example#1998)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 24, 2026
Update books

## rust-embedded/book

1 commits in fe88fbb68391a465680dd91109f0a151a1676f3e..99d0341ff4e06757490af8fceee790c4ede50bc0
2026-02-11 12:58:13 UTC to 2026-02-11 12:58:13 UTC

- Remove triagebot.toml (rust-embedded/book#405)

## rust-lang/reference

21 commits in addd0602c819b6526b9cc97653b0fadca395528c..442cbef9105662887d5eae2882ca551f3726bf28
2026-02-22 02:55:12 UTC to 2026-02-11 01:41:05 UTC

- Document importing path-segment keyword (rust-lang/reference#2136)
- avoid needless dereference (rust-lang/reference#2180)
- Use `clobber_abi`s corresponding to the called functions in `[asm.abi-clobbers.many]`'s example. (rust-lang/reference#2170)
- expr.paren.evaluation: fix and make more simple (rust-lang/reference#2158)
- const-eval.const-context.outer-generics: make more clear/obvious (rust-lang/reference#2159)
- Nightly test links: update rust branch name (use `main`) (rust-lang/reference#2185)
- tools/xtask: update rust branch name for linkcheck script (use `main`) (rust-lang/reference#2184)
- specify `if let` guards with updated scoping rules (rust-lang/reference#1957)
- Document assignment expression as coercion site (rust-lang/reference#1954)
- Remove exception WRT same-crate `non_exhaustive` reads (rust-lang/reference#2162)
- Add negative lookahead (rust-lang/reference#2172)
- Switch to new range syntax (rust-lang/reference#2173)
- add mdbook output for dev-guide to ignore file (rust-lang/reference#2178)
- Fix rule name for while syntax (rust-lang/reference#2175)
- block-expr: add new rule expr.block.result-value (rust-lang/reference#2174)
- lifetime-elision.md: add some missing periods (rust-lang/reference#2176)
- Add cut operator (`^`) to grammar (rust-lang/reference#2104)
- dev-guide stabilization.md: add missing "not" (rust-lang/reference#2167)
- Add method call and await expr for Dot in syntax index (rust-lang/reference#2163)
- Fix sort of punctuation list (rust-lang/reference#2161)
- Add a contributor guide (rust-lang/reference#2097)

## rust-lang/rust-by-example

1 commits in bac931ef1673af63fb60c3d691633034713cca20..5383db524711c0c9c43c3ca9e5e706089672ed6a
2026-02-16 12:02:33 UTC to 2026-02-16 12:02:33 UTC

- 1.2.2 Display: Fix typo in bonus instructions (before -> after) (rust-lang/rust-by-example#1998)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 24, 2026
Update books

## rust-embedded/book

1 commits in fe88fbb68391a465680dd91109f0a151a1676f3e..99d0341ff4e06757490af8fceee790c4ede50bc0
2026-02-11 12:58:13 UTC to 2026-02-11 12:58:13 UTC

- Remove triagebot.toml (rust-embedded/book#405)

## rust-lang/reference

21 commits in addd0602c819b6526b9cc97653b0fadca395528c..442cbef9105662887d5eae2882ca551f3726bf28
2026-02-22 02:55:12 UTC to 2026-02-11 01:41:05 UTC

- Document importing path-segment keyword (rust-lang/reference#2136)
- avoid needless dereference (rust-lang/reference#2180)
- Use `clobber_abi`s corresponding to the called functions in `[asm.abi-clobbers.many]`'s example. (rust-lang/reference#2170)
- expr.paren.evaluation: fix and make more simple (rust-lang/reference#2158)
- const-eval.const-context.outer-generics: make more clear/obvious (rust-lang/reference#2159)
- Nightly test links: update rust branch name (use `main`) (rust-lang/reference#2185)
- tools/xtask: update rust branch name for linkcheck script (use `main`) (rust-lang/reference#2184)
- specify `if let` guards with updated scoping rules (rust-lang/reference#1957)
- Document assignment expression as coercion site (rust-lang/reference#1954)
- Remove exception WRT same-crate `non_exhaustive` reads (rust-lang/reference#2162)
- Add negative lookahead (rust-lang/reference#2172)
- Switch to new range syntax (rust-lang/reference#2173)
- add mdbook output for dev-guide to ignore file (rust-lang/reference#2178)
- Fix rule name for while syntax (rust-lang/reference#2175)
- block-expr: add new rule expr.block.result-value (rust-lang/reference#2174)
- lifetime-elision.md: add some missing periods (rust-lang/reference#2176)
- Add cut operator (`^`) to grammar (rust-lang/reference#2104)
- dev-guide stabilization.md: add missing "not" (rust-lang/reference#2167)
- Add method call and await expr for Dot in syntax index (rust-lang/reference#2163)
- Fix sort of punctuation list (rust-lang/reference#2161)
- Add a contributor guide (rust-lang/reference#2097)

## rust-lang/rust-by-example

1 commits in bac931ef1673af63fb60c3d691633034713cca20..5383db524711c0c9c43c3ca9e5e706089672ed6a
2026-02-16 12:02:33 UTC to 2026-02-16 12:02:33 UTC

- 1.2.2 Display: Fix typo in bonus instructions (before -> after) (rust-lang/rust-by-example#1998)
rust-timer added a commit to rust-lang/rust that referenced this pull request Feb 24, 2026
Rollup merge of #153023 - rustbot:docs-update, r=ehuss

Update books

## rust-embedded/book

1 commits in fe88fbb68391a465680dd91109f0a151a1676f3e..99d0341ff4e06757490af8fceee790c4ede50bc0
2026-02-11 12:58:13 UTC to 2026-02-11 12:58:13 UTC

- Remove triagebot.toml (rust-embedded/book#405)

## rust-lang/reference

21 commits in addd0602c819b6526b9cc97653b0fadca395528c..442cbef9105662887d5eae2882ca551f3726bf28
2026-02-22 02:55:12 UTC to 2026-02-11 01:41:05 UTC

- Document importing path-segment keyword (rust-lang/reference#2136)
- avoid needless dereference (rust-lang/reference#2180)
- Use `clobber_abi`s corresponding to the called functions in `[asm.abi-clobbers.many]`'s example. (rust-lang/reference#2170)
- expr.paren.evaluation: fix and make more simple (rust-lang/reference#2158)
- const-eval.const-context.outer-generics: make more clear/obvious (rust-lang/reference#2159)
- Nightly test links: update rust branch name (use `main`) (rust-lang/reference#2185)
- tools/xtask: update rust branch name for linkcheck script (use `main`) (rust-lang/reference#2184)
- specify `if let` guards with updated scoping rules (rust-lang/reference#1957)
- Document assignment expression as coercion site (rust-lang/reference#1954)
- Remove exception WRT same-crate `non_exhaustive` reads (rust-lang/reference#2162)
- Add negative lookahead (rust-lang/reference#2172)
- Switch to new range syntax (rust-lang/reference#2173)
- add mdbook output for dev-guide to ignore file (rust-lang/reference#2178)
- Fix rule name for while syntax (rust-lang/reference#2175)
- block-expr: add new rule expr.block.result-value (rust-lang/reference#2174)
- lifetime-elision.md: add some missing periods (rust-lang/reference#2176)
- Add cut operator (`^`) to grammar (rust-lang/reference#2104)
- dev-guide stabilization.md: add missing "not" (rust-lang/reference#2167)
- Add method call and await expr for Dot in syntax index (rust-lang/reference#2163)
- Fix sort of punctuation list (rust-lang/reference#2161)
- Add a contributor guide (rust-lang/reference#2097)

## rust-lang/rust-by-example

1 commits in bac931ef1673af63fb60c3d691633034713cca20..5383db524711c0c9c43c3ca9e5e706089672ed6a
2026-02-16 12:02:33 UTC to 2026-02-16 12:02:33 UTC

- 1.2.2 Display: Fix typo in bonus instructions (before -> after) (rust-lang/rust-by-example#1998)
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.

4 participants