Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/expressions/operator-expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -539,17 +539,17 @@ reference types and `mut` or `const` in pointer types.
| [Function pointer] | Integer | Function pointer to address cast |
| Closure [^no-capture] | Function pointer | Closure to function pointer cast |

[^meta-compat]: where `T` and `V` have compatible metadata:
[^meta-compat]: Where `T` and `V` have compatible metadata:
* `V: Sized`, or
* Both slice metadata (`*[u16]` -> `*[u8]`, `*str` -> `*(u8, [u32])`), or
* Both the same trait object metadata, modulo dropping auto traits (`*dyn Debug` -> `*(u16, dyn Debug)`, `*dyn Debug + Send` -> `*dyn Debug`)
* **Note**: *adding* auto traits is only allowed if the principal trait has the auto trait as a super trait (given `trait T: Send {}`, `*dyn T` -> `*dyn T + Send` is valid, but `*dyn Debug` -> `*dyn Debug + Send` is not)
* **Note**: Generics (including lifetimes) must match (`*dyn T<'a, A>` -> `*dyn T<'b, B>` requires `'a = 'b` and `A = B`)

[^lessmut]: only when `m₁` is `mut` or `m₂` is `const`. Casting `mut` reference/pointer to
[^lessmut]: Only when `m₁` is `mut` or `m₂` is `const`. Casting `mut` reference/pointer to
`const` pointer is allowed.

[^no-capture]: only for closures that do not capture (close over) any local variables can be casted to function pointers.
[^no-capture]: Only closures that do not capture (close over) any local variables can be cast to function pointers.

### Semantics

Expand Down
2 changes: 1 addition & 1 deletion src/items/enumerations.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ assert_eq!(2, Enum::Baz as isize);
```

r[items.enum.discriminant.coercion.fieldless]
[Field-less enums] can be casted if they do not have explicit discriminants, or where only unit variants are explicit.
[Field-less enums] can be cast if they do not have explicit discriminants, or where only unit variants are explicit.

```rust
enum Fieldless {
Expand Down
2 changes: 1 addition & 1 deletion src/items/traits.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ trait DynIncompatible {
fn foo() {} // ERROR: associated function without Sized
fn returns(&self) -> Self; // ERROR: Self in return type
fn typed<T>(&self, x: T) {} // ERROR: has generic type parameters
fn nested(self: Rc<Box<Self>>) {} // ERROR: nested receiver cannot be downcasted
fn nested(self: Rc<Box<Self>>) {} // ERROR: nested receiver cannot be dispatched on
}

struct S;
Expand Down