Revise trailing expression block rules

An earlier commit added a single rule, `r[expr.block.result-value]`,
that documented the value of a block expression in one compound
sentence.  While correct, that sentence carried a lot of weight -- the
three cases it described (final operand present, final operand absent,
and diverging) are different enough that each deserves its own rule
and example.

This commit replaces `r[expr.block.result-value]` and
`r[expr.block.type]` with three rules that each describe the type and
value together for one case:

- `r[expr.block.value-trailing-expr]`: when the block has a final
  operand, it has that operand's type and value.

- `r[expr.block.value-no-trailing-expr]`: when the block has no final
  operand and doesn't diverge, it has unit type and unit value.

- `r[expr.block.value-diverges-no-trailing-expr]`: when the block has
  no final operand and diverges, it has the never type and has no
  final value (because its type is uninhabited).

The existing example demonstrated type and value together in one
block.  We replace it with focused examples for each rule, each
demonstrating the specific case that rule describes.  A note after the
third rule highlights the distinction between omitting the final
operand and having an explicit unit final operand -- the diverging
case makes this difference visible, since `{ loop {}; }` has never
type while `{ loop {}; () }` has unit type.
2 files changed
tree: 7d8ae855235dee145f352a5e8452a52458c92a5f
  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.