Skip to content

Commit e3d2240

Browse files
committed
rename "unsized" coercion as "unsizing"
1 parent 2a242c5 commit e3d2240

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/expressions/method-call-expr.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ The following procedure is used:
2525

2626
r[expr.method.candidate-receivers]
2727
The first step is to build a list of candidate receiver types.
28-
Obtain these by repeatedly [dereferencing][dereference] the receiver expression's type, adding each type encountered to the list, then finally attempting an [unsized coercion][coerce.unsize] at the end, and adding the result type if that is successful.
28+
Obtain these by repeatedly [dereferencing][dereference] the receiver expression's type, adding each type encountered to the list, then finally attempting an [unsizing coercion][coerce.unsize] at the end, and adding the result type if that is successful.
2929

3030
r[expr.method.candidate-receivers-refs]
3131
Then, for each candidate `T`, add `&T` and `&mut T` to the list immediately after `T`.
3232

33-
For instance, if the receiver has type `Box<[i32;2]>`, then the candidate types will be `Box<[i32;2]>`, `&Box<[i32;2]>`, `&mut Box<[i32;2]>`, `[i32; 2]` (by dereferencing), `&[i32; 2]`, `&mut [i32; 2]`, `[i32]` (by unsized coercion), `&[i32]`, and finally `&mut [i32]`.
33+
For instance, if the receiver has type `Box<[i32;2]>`, then the candidate types will be `Box<[i32;2]>`, `&Box<[i32;2]>`, `&mut Box<[i32;2]>`, `[i32; 2]` (by dereferencing), `&[i32; 2]`, `&mut [i32; 2]`, `[i32]` (by unsizing coercion), `&[i32]`, and finally `&mut [i32]`.
3434

3535
r[expr.method.candidate-search]
3636
Then, for each candidate type `T`, search for a [visible] method with a receiver of that type in the following places:

src/type-coercions.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ r[coerce.types.unsize]
141141
const _: &[u32] = &[0, 1, 2, 3, 4, 5]; // &[u32; 4] -> &[u32]
142142
```
143143

144-
See [unsized coercion](#unsized-coercions) for more details.
144+
See [unsizing coercion](#unsizing-coercions) for more details.
145145

146146
r[coerce.types.deref]
147147
* `&T` or `&mut T` to `&U` if `T` implements `Deref<Target = U>`. For example:
@@ -182,11 +182,11 @@ r[coerce.types.never]
182182
* `!` to any `T`
183183

184184
r[coerce.unsize]
185-
### Unsized Coercions
185+
### Unsizing Coercions
186186

187187
r[coerce.unsize.intro]
188-
The following coercions are called "unsized coercions", since their targets contain an unsized type.
189-
unsized coercions apply to pointer-like types which point to types which can lose some of their compile-time known information (such as size or implemented traits). For example:
188+
The following coercions are called "Unsizing coercions", since their targets contain an unsized type.
189+
Unsizing coercions apply to pointer-like types which point to types which can lose some of their compile-time known information (such as size or implemented traits). For example:
190190

191191
```rust
192192
use std::cell::Cell;
@@ -224,12 +224,12 @@ fn main() {
224224

225225
r[coerce.unsize.confusion]
226226
> [!NOTE]
227-
> The term "unsized" might be quite confusing, since the coercion works on sized types (pointers) and the source pointer might point to an unsized type in the first place (`&dyn A -> &dyn Super` in the example above).
227+
> The term "unsizing" might be quite confusing, since the coercion works on sized types (pointers) and the source pointer might point to an unsized type in the first place (`&dyn A -> &dyn Super` in the example above).
228228
>
229-
> "unsized" refers to the main purpose of these coercions --- converting (pointers to) sized types to (pointers to) unsized types. The pointers being not the focus, since unsized types can't exist without them.
229+
> "Unsizing" refers to the main purpose of these coercions --- converting (pointers to) sized types to (pointers to) unsized types. The pointers being not the focus, since unsized types can't exist without them.
230230
231231
r[coerce.unsize.metadata]
232-
When performing unsized coercion, the pointer metadata type changes. For example, when unsized `&u32` to `&dyn Debug` metadate type changes from `()` to `DynMetadata<dyn Debug>` (note that exact metadata types are not yet stable). This can also lead to a change in the pointer size -- `&u32` is half the size of `&dyn Debug`.
232+
When performing unsizing coercion, the pointer metadata type changes. For example, when unsizing `&u32` to `&dyn Debug` metadate type changes from `()` to `DynMetadata<dyn Debug>` (note that exact metadata types are not yet stable). This can also lead to a change in the pointer size -- `&u32` is half the size of `&dyn Debug`.
233233

234234
r[coerce.unsize.traits]
235235
Three traits, [`Unsize`], [`CoerceUnsized`], and [`PinCoerceUnsized`] are used to assist in this process and expose it for library use.
@@ -241,7 +241,7 @@ r[coerce.unsize.traits.coerce-unsized]
241241
[`CoerceUnsized`] represents the fact that a pointer-like type can be coerced to another pointer-like type, due to `Unsize` being implemented for their pointees. For example, `&T` implements `CoerceUnsized<&U>` when `T: Unsize<U>`.
242242

243243
r[coerce.unsize.traits.pin-coerce-unsized]
244-
[`PinCoerceUnsized`] is an unsafe marker trait for pointer-like types unsized coercion of which does not break [`Pin`] guarantees. It is a requirement of the [`CoerceUnsized` implementation for `Pin`][coerce.unsize.coerce-unsized-impls.pin-pin]. That is, `&D: PinCoerceUnsized` implies `Pin<&T>: CoerceUnsized<Pin<&U>>`.
244+
[`PinCoerceUnsized`] is an unsafe marker trait for pointer-like types unsizing coercion of which does not break [`Pin`] guarantees. It is a requirement of the [`CoerceUnsized` implementation for `Pin`][coerce.unsize.coerce-unsized-impls.pin-pin]. That is, `&D: PinCoerceUnsized` implies `Pin<&T>: CoerceUnsized<Pin<&U>>`.
245245

246246
The following implementations of [`Unsize`] are built-in:
247247

0 commit comments

Comments
 (0)