-
Notifications
You must be signed in to change notification settings - Fork 577
Clarify only arrays undergo unsized coercion during dispatch #2139
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
Conversation
|
@BennoLossin and @Nadrieril pointed out that we could remove this step entirely with a simple impl<T, const N: usize> Deref for [T; N] {
type Target = [T];
fn deref(&self) -> &[T] { &*self }
}Similarly for |
This comment has been minimized.
This comment has been minimized.
156ace3 to
8f3bc72
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
This is true. Thanks for the PR. |
Update books ## rust-lang/book 1 commits in 39aeceaa3aeab845bc4517e7a44e48727d3b9dbe..05d114287b7d6f6c9253d5242540f00fbd6172ab 2026-02-03 15:19:04 UTC to 2026-02-03 15:19:04 UTC - Temporarily remove the link to `Drop::drop` (rust-lang/book#4576) ## rust-lang/nomicon 1 commits in 050c002a360fa45b701ea34feed7a860dc8a41bf..b8f254a991b8b7e8f704527f0d4f343a4697dfa9 2026-01-29 12:15:01 UTC to 2026-01-29 12:15:01 UTC - Fix deprecation warning for compare_and_swap in atomics.md (rust-lang/nomicon#519) ## rust-lang/reference 12 commits in 990819b86c22bbf538c0526f0287670f3dc1a67a..addd0602c819b6526b9cc97653b0fadca395528c 2026-02-04 14:35:59 UTC to 2026-01-26 18:02:14 UTC - const-eval.const-expr.field: make paragraph more clear (rust-lang/reference#2157) - make more clear what the link target is (rust-lang/reference#2156) - Update two URLs (rust-lang/reference#2154) - Add a chapter on divergence (rust-lang/reference#2067) - Guarantee `repr(C)` union field offset (rust-lang/reference#2128) - Reference updates for forbidding object lifetime changing pointer casts (rust-lang/reference#1951) - Clarify only arrays undergo unsized coercion during dispatch (rust-lang/reference#2139) - Split the textual chapter into separate char and str chapters (rust-lang/reference#2145) - Document ppc inline asm support (rust-lang/reference#2056) - Unwrap items, expressions, patterns, and types (rust-lang/reference#2141) - undefined behavior: add missing plural in `undefined.misaligned.ptr` (rust-lang/reference#2146) - inline-assembly: add a space to the `asm.abi-clobbers.many` example (rust-lang/reference#2144)
Update books ## rust-lang/book 1 commits in 39aeceaa3aeab845bc4517e7a44e48727d3b9dbe..05d114287b7d6f6c9253d5242540f00fbd6172ab 2026-02-03 15:19:04 UTC to 2026-02-03 15:19:04 UTC - Temporarily remove the link to `Drop::drop` (rust-lang/book#4576) ## rust-lang/nomicon 1 commits in 050c002a360fa45b701ea34feed7a860dc8a41bf..b8f254a991b8b7e8f704527f0d4f343a4697dfa9 2026-01-29 12:15:01 UTC to 2026-01-29 12:15:01 UTC - Fix deprecation warning for compare_and_swap in atomics.md (rust-lang/nomicon#519) ## rust-lang/reference 12 commits in 990819b86c22bbf538c0526f0287670f3dc1a67a..addd0602c819b6526b9cc97653b0fadca395528c 2026-02-04 14:35:59 UTC to 2026-01-26 18:02:14 UTC - const-eval.const-expr.field: make paragraph more clear (rust-lang/reference#2157) - make more clear what the link target is (rust-lang/reference#2156) - Update two URLs (rust-lang/reference#2154) - Add a chapter on divergence (rust-lang/reference#2067) - Guarantee `repr(C)` union field offset (rust-lang/reference#2128) - Reference updates for forbidding object lifetime changing pointer casts (rust-lang/reference#1951) - Clarify only arrays undergo unsized coercion during dispatch (rust-lang/reference#2139) - Split the textual chapter into separate char and str chapters (rust-lang/reference#2145) - Document ppc inline asm support (rust-lang/reference#2056) - Unwrap items, expressions, patterns, and types (rust-lang/reference#2141) - undefined behavior: add missing plural in `undefined.misaligned.ptr` (rust-lang/reference#2146) - inline-assembly: add a space to the `asm.abi-clobbers.many` example (rust-lang/reference#2144)
Update books ## rust-lang/book 1 commits in 39aeceaa3aeab845bc4517e7a44e48727d3b9dbe..05d114287b7d6f6c9253d5242540f00fbd6172ab 2026-02-03 15:19:04 UTC to 2026-02-03 15:19:04 UTC - Temporarily remove the link to `Drop::drop` (rust-lang/book#4576) ## rust-lang/nomicon 1 commits in 050c002a360fa45b701ea34feed7a860dc8a41bf..b8f254a991b8b7e8f704527f0d4f343a4697dfa9 2026-01-29 12:15:01 UTC to 2026-01-29 12:15:01 UTC - Fix deprecation warning for compare_and_swap in atomics.md (rust-lang/nomicon#519) ## rust-lang/reference 12 commits in 990819b86c22bbf538c0526f0287670f3dc1a67a..addd0602c819b6526b9cc97653b0fadca395528c 2026-02-04 14:35:59 UTC to 2026-01-26 18:02:14 UTC - const-eval.const-expr.field: make paragraph more clear (rust-lang/reference#2157) - make more clear what the link target is (rust-lang/reference#2156) - Update two URLs (rust-lang/reference#2154) - Add a chapter on divergence (rust-lang/reference#2067) - Guarantee `repr(C)` union field offset (rust-lang/reference#2128) - Reference updates for forbidding object lifetime changing pointer casts (rust-lang/reference#1951) - Clarify only arrays undergo unsized coercion during dispatch (rust-lang/reference#2139) - Split the textual chapter into separate char and str chapters (rust-lang/reference#2145) - Document ppc inline asm support (rust-lang/reference#2056) - Unwrap items, expressions, patterns, and types (rust-lang/reference#2141) - undefined behavior: add missing plural in `undefined.misaligned.ptr` (rust-lang/reference#2146) - inline-assembly: add a space to the `asm.abi-clobbers.many` example (rust-lang/reference#2144)
Update books ## rust-lang/book 1 commits in 39aeceaa3aeab845bc4517e7a44e48727d3b9dbe..05d114287b7d6f6c9253d5242540f00fbd6172ab 2026-02-03 15:19:04 UTC to 2026-02-03 15:19:04 UTC - Temporarily remove the link to `Drop::drop` (rust-lang/book#4576) ## rust-lang/nomicon 1 commits in 050c002a360fa45b701ea34feed7a860dc8a41bf..b8f254a991b8b7e8f704527f0d4f343a4697dfa9 2026-01-29 12:15:01 UTC to 2026-01-29 12:15:01 UTC - Fix deprecation warning for compare_and_swap in atomics.md (rust-lang/nomicon#519) ## rust-lang/reference 12 commits in 990819b86c22bbf538c0526f0287670f3dc1a67a..addd0602c819b6526b9cc97653b0fadca395528c 2026-02-04 14:35:59 UTC to 2026-01-26 18:02:14 UTC - const-eval.const-expr.field: make paragraph more clear (rust-lang/reference#2157) - make more clear what the link target is (rust-lang/reference#2156) - Update two URLs (rust-lang/reference#2154) - Add a chapter on divergence (rust-lang/reference#2067) - Guarantee `repr(C)` union field offset (rust-lang/reference#2128) - Reference updates for forbidding object lifetime changing pointer casts (rust-lang/reference#1951) - Clarify only arrays undergo unsized coercion during dispatch (rust-lang/reference#2139) - Split the textual chapter into separate char and str chapters (rust-lang/reference#2145) - Document ppc inline asm support (rust-lang/reference#2056) - Unwrap items, expressions, patterns, and types (rust-lang/reference#2141) - undefined behavior: add missing plural in `undefined.misaligned.ptr` (rust-lang/reference#2146) - inline-assembly: add a space to the `asm.abi-clobbers.many` example (rust-lang/reference#2144)
Update books ## rust-lang/book 1 commits in 39aeceaa3aeab845bc4517e7a44e48727d3b9dbe..05d114287b7d6f6c9253d5242540f00fbd6172ab 2026-02-03 15:19:04 UTC to 2026-02-03 15:19:04 UTC - Temporarily remove the link to `Drop::drop` (rust-lang/book#4576) ## rust-lang/nomicon 1 commits in 050c002a360fa45b701ea34feed7a860dc8a41bf..b8f254a991b8b7e8f704527f0d4f343a4697dfa9 2026-01-29 12:15:01 UTC to 2026-01-29 12:15:01 UTC - Fix deprecation warning for compare_and_swap in atomics.md (rust-lang/nomicon#519) ## rust-lang/reference 12 commits in 990819b86c22bbf538c0526f0287670f3dc1a67a..addd0602c819b6526b9cc97653b0fadca395528c 2026-02-04 14:35:59 UTC to 2026-01-26 18:02:14 UTC - const-eval.const-expr.field: make paragraph more clear (rust-lang/reference#2157) - make more clear what the link target is (rust-lang/reference#2156) - Update two URLs (rust-lang/reference#2154) - Add a chapter on divergence (rust-lang/reference#2067) - Guarantee `repr(C)` union field offset (rust-lang/reference#2128) - Reference updates for forbidding object lifetime changing pointer casts (rust-lang/reference#1951) - Clarify only arrays undergo unsized coercion during dispatch (rust-lang/reference#2139) - Split the textual chapter into separate char and str chapters (rust-lang/reference#2145) - Document ppc inline asm support (rust-lang/reference#2056) - Unwrap items, expressions, patterns, and types (rust-lang/reference#2141) - undefined behavior: add missing plural in `undefined.misaligned.ptr` (rust-lang/reference#2146) - inline-assembly: add a space to the `asm.abi-clobbers.many` example (rust-lang/reference#2144)
Update books ## rust-lang/book 1 commits in 39aeceaa3aeab845bc4517e7a44e48727d3b9dbe..05d114287b7d6f6c9253d5242540f00fbd6172ab 2026-02-03 15:19:04 UTC to 2026-02-03 15:19:04 UTC - Temporarily remove the link to `Drop::drop` (rust-lang/book#4576) ## rust-lang/nomicon 1 commits in 050c002a360fa45b701ea34feed7a860dc8a41bf..b8f254a991b8b7e8f704527f0d4f343a4697dfa9 2026-01-29 12:15:01 UTC to 2026-01-29 12:15:01 UTC - Fix deprecation warning for compare_and_swap in atomics.md (rust-lang/nomicon#519) ## rust-lang/reference 12 commits in 990819b86c22bbf538c0526f0287670f3dc1a67a..addd0602c819b6526b9cc97653b0fadca395528c 2026-02-04 14:35:59 UTC to 2026-01-26 18:02:14 UTC - const-eval.const-expr.field: make paragraph more clear (rust-lang/reference#2157) - make more clear what the link target is (rust-lang/reference#2156) - Update two URLs (rust-lang/reference#2154) - Add a chapter on divergence (rust-lang/reference#2067) - Guarantee `repr(C)` union field offset (rust-lang/reference#2128) - Reference updates for forbidding object lifetime changing pointer casts (rust-lang/reference#1951) - Clarify only arrays undergo unsized coercion during dispatch (rust-lang/reference#2139) - Split the textual chapter into separate char and str chapters (rust-lang/reference#2145) - Document ppc inline asm support (rust-lang/reference#2056) - Unwrap items, expressions, patterns, and types (rust-lang/reference#2141) - undefined behavior: add missing plural in `undefined.misaligned.ptr` (rust-lang/reference#2146) - inline-assembly: add a space to the `asm.abi-clobbers.many` example (rust-lang/reference#2144)
Rollup merge of #152397 - rustbot:docs-update, r=ehuss Update books ## rust-lang/book 1 commits in 39aeceaa3aeab845bc4517e7a44e48727d3b9dbe..05d114287b7d6f6c9253d5242540f00fbd6172ab 2026-02-03 15:19:04 UTC to 2026-02-03 15:19:04 UTC - Temporarily remove the link to `Drop::drop` (rust-lang/book#4576) ## rust-lang/nomicon 1 commits in 050c002a360fa45b701ea34feed7a860dc8a41bf..b8f254a991b8b7e8f704527f0d4f343a4697dfa9 2026-01-29 12:15:01 UTC to 2026-01-29 12:15:01 UTC - Fix deprecation warning for compare_and_swap in atomics.md (rust-lang/nomicon#519) ## rust-lang/reference 12 commits in 990819b86c22bbf538c0526f0287670f3dc1a67a..addd0602c819b6526b9cc97653b0fadca395528c 2026-02-04 14:35:59 UTC to 2026-01-26 18:02:14 UTC - const-eval.const-expr.field: make paragraph more clear (rust-lang/reference#2157) - make more clear what the link target is (rust-lang/reference#2156) - Update two URLs (rust-lang/reference#2154) - Add a chapter on divergence (rust-lang/reference#2067) - Guarantee `repr(C)` union field offset (rust-lang/reference#2128) - Reference updates for forbidding object lifetime changing pointer casts (rust-lang/reference#1951) - Clarify only arrays undergo unsized coercion during dispatch (rust-lang/reference#2139) - Split the textual chapter into separate char and str chapters (rust-lang/reference#2145) - Document ppc inline asm support (rust-lang/reference#2056) - Unwrap items, expressions, patterns, and types (rust-lang/reference#2141) - undefined behavior: add missing plural in `undefined.misaligned.ptr` (rust-lang/reference#2146) - inline-assembly: add a space to the `asm.abi-clobbers.many` example (rust-lang/reference#2144)
A small example to illustrate the difference between array and trait unsized coercions: (playground)
This came up during a discussion about autoref in zulip: #t-lang/custom-refs > Autoref. Thanks to @BennoLossin for the original example.
The rustc dev guide describes this algorithm similarly to the way the reference does today; it mentions unsized coercions in general, but only uses arrays as an example.