Generalize the wide-pointer total-size bound

We document that, for references and `Box<T>`, pointed-to values
with slice or `str` metadata must be no larger than `isize::MAX`.  We
hadn't required this for pointed-to values with `dyn` metadata.  It's
tempting to think this isn't necessary since we separately require
that the metadata point to a vtable generated by the compiler, which
ensures the encoded size of the erased type is OK.

But the bound is on the total size of the pointed-to value, including
any sized prefix of a type with an unsized tail.  Since the prefix
combined with the size in the vtable can push us past the limit, we
need the separate restriction.

Let's apply the rule to both cases and add an admonition to remind
ourselves of why this is needed.
1 file changed
tree: 49810022819872081b7dc8cb7a7eefeb95fd9b01
  1. .cargo/
  2. .github/
  3. dev-guide/
  4. docs/
  5. src/
  6. theme/
  7. tools/
  8. .gitattributes
  9. .gitignore
  10. book.toml
  11. Cargo.lock
  12. Cargo.toml
  13. CONTRIBUTING.md
  14. LICENSE-APACHE
  15. LICENSE-MIT
  16. README.md
  17. reference.md
  18. rust-toolchain.toml
  19. rustfmt.toml
  20. triagebot.toml
README.md

The Rust Language Reference

This document is the primary reference for the Rust programming language.

Contributor docs

See the Reference Developer Guide for information on contributing to the Reference.