Skip to content

Commit

Permalink
clarify relaxed bounds tables
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtwco committed Dec 2, 2024
1 parent 02d1759 commit 8cbaef9
Showing 1 changed file with 37 additions and 36 deletions.
73 changes: 37 additions & 36 deletions text/3729-sized-hierarchy.md
Original file line number Diff line number Diff line change
Expand Up @@ -961,55 +961,56 @@ section][size_of-and-size_of_val] for rationale). In the next edition, `?Sized`
rewritten to `?Sized + const ValueSized` (remove the `Sized` default and add a `const ValueSized`
bound) and bare `?Sized` would only remove the `Sized` default bound.

Prior to the edition migration, the default bound is `Sized`, which could be changed using
Prior to the edition migration, with positive bounds and keeping `?Sized`, the default bound is
`Sized` (interpreted as `const Sized` for backwards compatibility), which could be changed using
the following syntax:

| With positive bounds | Keeping `?Sized` |
| -------------------- | ---------------- |
| `const Sized` | `const Sized` |
| `Sized` | `Sized` |
| `const ValueSized` | `?Sized` |
| `ValueSized` | Not possible |
| `Pointee` | Not possible |

After the edition migration, the default bound is `const Sized`, which could be changed
using the following syntax:

| With positive bounds | Keeping `?Sized` |
| --------------------- | --------------------------------- |
| `const Sized` | `const Sized` |
| `Sized` | `?const Sized + Sized` |
| `const ValueSized` | `?const Sized + const ValueSized` |
| `ValueSized` | `?const Sized + ValueSized` |
| `Pointee` | `?const Sized` |
| Canonically | Syntax with positive bounds | Syntax keeping `?Sized` |
| ------------------ | ------------------------------------ | ------------------------------------ |
| `const Sized` | `T: const Sized`, `T: Sized`, or `T` | `T: const Sized`, `T: Sized`, or `T` |
| `Sized` | Not possible | Not possible |
| `const ValueSized` | `T: const ValueSized` | `T: ?Sized` |
| `ValueSized` | `T: ValueSized` | Not possible |
| `Pointee` | `T: Pointee` | Not possible |

After the edition migration, with positive bounds and keeping `?Sized`, the default bound is
`const Sized`, which could be changed using the following syntax:

| Canonically | Syntax with positive bounds | Syntax keeping `?Sized` |
| ------------------ | --------------------------- | ------------------------------------ |
| `const Sized` | `T: const Sized` or `T` | `T: const Sized` or `T` |
| `Sized` | `T: Sized` | `T: ?const Sized + Sized` |
| `const ValueSized` | `T: const ValueSized` | `T: ?const Sized + const ValueSized` |
| `ValueSized` | `T: ValueSized` | `T: ?const Sized + ValueSized` |
| `Pointee` | `T: Pointee` | `T: ?const Sized` |

### Adding `?ValueSized`
[adding-valuesized]: #adding-valuesized

Another alternative is to make `ValueSized` a default bound in addition to `Sized` and establish
that relaxing a supertrait bound also implies relaxing subtrait bounds:

Prior to the edition migration, the default bound is `ValueSized + const ValueSized + Sized`,
which could be changed using:
Prior to the edition migration, when adding `?ValueSized`, the default bound is
`ValueSized + const ValueSized + Sized + const Sized`, which could be changed using:

| With positive bounds | Adding `?ValueSized` |
| --------------------- | -------------------------------- |
| `const Sized` | `const Sized` |
| `Sized` | `Sized` |
| `const ValueSized` | `?Sized` |
| `ValueSized` | `?const ValueSized` |
| `Pointee` | `?ValueSized` |
| Canonically | Syntax with positive bounds | Syntax adding `?ValueSized` |
| ------------------ | ----------------------------------- | ----------------------------------- |
| `const Sized` | `T: const Sized`, `T: Sized` or `T` | `T: const Sized`, `T: Sized` or `T` |
| `Sized` | Not possible | Not possible |
| `const ValueSized` | `T: const ValueSized` | `T: ?const Sized` or `T: ?Sized` |
| `ValueSized` | `T: ValueSized` | `T: ?const ValueSized` |
| `Pointee` | `T: Pointee` | `T: ?ValueSized` |

After the edition migration, the default bound is
After the edition migration, when adding `?ValueSized`, the default bound remains
`ValueSized + const ValueSized + Sized + const Sized`, which could be changed using:

| With positive bounds | Adding `?ValueSized` |
| -------------------- | -------------------------------- |
| `const Sized` | `const Sized` |
| `Sized` | `?const Sized` |
| `const ValueSized` | `?Sized` |
| `ValueSized` | `?const ValueSized` |
| `Pointee` | `?ValueSized` |
| Canonically | Syntax with positive bounds | Syntax adding `?ValueSized` |
| ------------------ | --------------------------- | --------------------------- |
| `const Sized` | `T: const Sized` or `T` | `T: const Sized` or `T` |
| `Sized` | `T: Sized` | `T: ?const Sized` |
| `const ValueSized` | `T: const ValueSized` | `T: ?Sized` |
| `ValueSized` | `T: ValueSized` | `T: ?const ValueSized` |
| `Pointee` | `T: Pointee` | `T: ?ValueSized` |

## Why not re-use `std::ptr::Pointee`?
[why-not-re-use-stdptrpointee]: #why-not-re-use-stdptrpointee
Expand Down

0 comments on commit 8cbaef9

Please sign in to comment.