From 2c5f75977297d766a399fee5a2af0037206151a3 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sun, 12 Oct 2025 09:26:42 -0700 Subject: [PATCH 01/49] Create a syntax index This adds a new appendix caled "Syntax index" which is an index of various syntactical elements of the language. This initial commit just moves the index of punctuation symbols as-is without modification. --- src/SUMMARY.md | 1 + src/syntax-index.md | 100 +++++++++++++++++++++++++++++++++++++++++++ src/tokens.md | 101 ++------------------------------------------ 3 files changed, 104 insertions(+), 98 deletions(-) create mode 100644 src/syntax-index.md diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 977ad581e2..c3786707fa 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -133,6 +133,7 @@ - [Appendices](appendices.md) - [Grammar summary](grammar.md) + - [Syntax index](syntax-index.md) - [Macro follow-set ambiguity formal specification](macro-ambiguity.md) - [Influences](influences.md) - [Test summary](test-summary.md) diff --git a/src/syntax-index.md b/src/syntax-index.md new file mode 100644 index 0000000000..b57a4bd3a8 --- /dev/null +++ b/src/syntax-index.md @@ -0,0 +1,100 @@ +# Syntax index + +This appendix provides an index of tokens and common forms with links to where those elements are defined. + +## Keywords + +## Operators and punctuation + +| Symbol | Name | Usage | +|--------|-------------|-------| +| `+` | Plus | [Addition][arith], [Trait Bounds], [Macro Kleene Matcher][macros] +| `-` | Minus | [Subtraction][arith], [Negation] +| `*` | Star | [Multiplication][arith], [Dereference], [Raw Pointers], [Macro Kleene Matcher][macros], [Use wildcards] +| `/` | Slash | [Division][arith] +| `%` | Percent | [Remainder][arith] +| `^` | Caret | [Bitwise and Logical XOR][arith] +| `!` | Not | [Bitwise and Logical NOT][negation], [Macro Calls][macros], [Inner Attributes][attributes], [Never Type], [Negative impls] +| `&` | And | [Bitwise and Logical AND][arith], [Borrow], [References], [Reference patterns] +| \| | Or | [Bitwise and Logical OR][arith], [Closures], Patterns in [match], [if let], and [while let] +| `&&` | AndAnd | [Lazy AND][lazy-bool], [Borrow], [References], [Reference patterns] +| \|\| | OrOr | [Lazy OR][lazy-bool], [Closures] +| `<<` | Shl | [Shift Left][arith], [Nested Generics][generics] +| `>>` | Shr | [Shift Right][arith], [Nested Generics][generics] +| `+=` | PlusEq | [Addition assignment][compound] +| `-=` | MinusEq | [Subtraction assignment][compound] +| `*=` | StarEq | [Multiplication assignment][compound] +| `/=` | SlashEq | [Division assignment][compound] +| `%=` | PercentEq | [Remainder assignment][compound] +| `^=` | CaretEq | [Bitwise XOR assignment][compound] +| `&=` | AndEq | [Bitwise And assignment][compound] +| \|= | OrEq | [Bitwise Or assignment][compound] +| `<<=` | ShlEq | [Shift Left assignment][compound] +| `>>=` | ShrEq | [Shift Right assignment][compound], [Nested Generics][generics] +| `=` | Eq | [Assignment], [Attributes], Various type definitions +| `==` | EqEq | [Equal][comparison] +| `!=` | Ne | [Not Equal][comparison] +| `>` | Gt | [Greater than][comparison], [Generics], [Paths] +| `<` | Lt | [Less than][comparison], [Generics], [Paths] +| `>=` | Ge | [Greater than or equal to][comparison], [Generics] +| `<=` | Le | [Less than or equal to][comparison] +| `@` | At | [Subpattern binding] +| `.` | Dot | [Field access][field], [Tuple index] +| `..` | DotDot | [Range][range], [Struct expressions], [Patterns], [Range Patterns][rangepat] +| `...` | DotDotDot | [Variadic functions][extern], [Range patterns] +| `..=` | DotDotEq | [Inclusive Range][range], [Range patterns] +| `,` | Comma | Various separators +| `;` | Semi | Terminator for various items and statements, [Array types] +| `:` | Colon | Various separators +| `::` | PathSep | [Path separator][paths] +| `->` | RArrow | [Function return type][functions], [Closure return type][closures], [Function pointer type] +| `=>` | FatArrow | [Match arms][match], [Macros] +| `<-` | LArrow | The left arrow symbol has been unused since before Rust 1.0, but it is still treated as a single token +| `#` | Pound | [Attributes] +| `$` | Dollar | [Macros] +| `?` | Question | [Try propagation expressions][question], [Questionably sized][sized], [Macro Kleene Matcher][macros] +| `~` | Tilde | The tilde operator has been unused since before Rust 1.0, but its token may still be used + +[Inferred types]: types/inferred.md +[Range patterns]: patterns.md#range-patterns +[Reference patterns]: patterns.md#reference-patterns +[Subpattern binding]: patterns.md#identifier-patterns +[Wildcard patterns]: patterns.md#wildcard-pattern +[arith]: expressions/operator-expr.md#arithmetic-and-logical-binary-operators +[array types]: types/array.md +[assignment]: expressions/operator-expr.md#assignment-expressions +[attributes]: attributes.md +[borrow]: expressions/operator-expr.md#borrow-operators +[closures]: expressions/closure-expr.md +[comparison]: expressions/operator-expr.md#comparison-operators +[compound]: expressions/operator-expr.md#compound-assignment-expressions +[constants]: items/constant-items.md +[dereference]: expressions/operator-expr.md#the-dereference-operator +[destructuring assignment]: expressions/underscore-expr.md +[extern crates]: items/extern-crates.md +[extern]: items/external-blocks.md +[field]: expressions/field-expr.md +[function pointer type]: types/function-pointer.md +[functions]: items/functions.md +[generics]: items/generics.md +[if let]: expressions/if-expr.md#if-let-patterns +[lazy-bool]: expressions/operator-expr.md#lazy-boolean-operators +[macros]: macros-by-example.md +[match]: expressions/match-expr.md +[negation]: expressions/operator-expr.md#negation-operators +[negative impls]: items/implementations.md +[never type]: types/never.md +[paths]: paths.md +[patterns]: patterns.md +[question]: expressions/operator-expr.md#the-try-propagation-expression +[range]: expressions/range-expr.md +[rangepat]: patterns.md#range-patterns +[raw pointers]: types/pointer.md#raw-pointers-const-and-mut +[references]: types/pointer.md +[sized]: trait-bounds.md#sized +[struct expressions]: expressions/struct-expr.md +[trait bounds]: trait-bounds.md +[tuple index]: expressions/tuple-expr.md#tuple-indexing-expressions +[use declarations]: items/use-declarations.md +[use wildcards]: items/use-declarations.md +[while let]: expressions/loop-expr.md#while-let-patterns diff --git a/src/tokens.md b/src/tokens.md index c825d93eda..28fd8deffa 100644 --- a/src/tokens.md +++ b/src/tokens.md @@ -795,6 +795,9 @@ r[lex.token.life.raw.edition2021] r[lex.token.punct] ## Punctuation +r[lex.token.punct.intro] +Punctuation tokens are used as operators, separators, and other parts of the grammar. + r[lex.token.punct.syntax] ```grammar,lexer PUNCTUATION -> @@ -852,59 +855,6 @@ PUNCTUATION -> | `)` ``` -r[lex.token.punct.intro] -Punctuation symbol tokens are listed here for completeness. Their individual -usages and meanings are defined in the linked pages. - -| Symbol | Name | Usage | -|--------|-------------|-------| -| `+` | Plus | [Addition][arith], [Trait Bounds], [Macro Kleene Matcher][macros] -| `-` | Minus | [Subtraction][arith], [Negation] -| `*` | Star | [Multiplication][arith], [Dereference], [Raw Pointers], [Macro Kleene Matcher][macros], [Use wildcards] -| `/` | Slash | [Division][arith] -| `%` | Percent | [Remainder][arith] -| `^` | Caret | [Bitwise and Logical XOR][arith] -| `!` | Not | [Bitwise and Logical NOT][negation], [Macro Calls][macros], [Inner Attributes][attributes], [Never Type], [Negative impls] -| `&` | And | [Bitwise and Logical AND][arith], [Borrow], [References], [Reference patterns] -| \| | Or | [Bitwise and Logical OR][arith], [Closures], Patterns in [match], [if let], and [while let] -| `&&` | AndAnd | [Lazy AND][lazy-bool], [Borrow], [References], [Reference patterns] -| \|\| | OrOr | [Lazy OR][lazy-bool], [Closures] -| `<<` | Shl | [Shift Left][arith], [Nested Generics][generics] -| `>>` | Shr | [Shift Right][arith], [Nested Generics][generics] -| `+=` | PlusEq | [Addition assignment][compound] -| `-=` | MinusEq | [Subtraction assignment][compound] -| `*=` | StarEq | [Multiplication assignment][compound] -| `/=` | SlashEq | [Division assignment][compound] -| `%=` | PercentEq | [Remainder assignment][compound] -| `^=` | CaretEq | [Bitwise XOR assignment][compound] -| `&=` | AndEq | [Bitwise And assignment][compound] -| \|= | OrEq | [Bitwise Or assignment][compound] -| `<<=` | ShlEq | [Shift Left assignment][compound] -| `>>=` | ShrEq | [Shift Right assignment][compound], [Nested Generics][generics] -| `=` | Eq | [Assignment], [Attributes], Various type definitions -| `==` | EqEq | [Equal][comparison] -| `!=` | Ne | [Not Equal][comparison] -| `>` | Gt | [Greater than][comparison], [Generics], [Paths] -| `<` | Lt | [Less than][comparison], [Generics], [Paths] -| `>=` | Ge | [Greater than or equal to][comparison], [Generics] -| `<=` | Le | [Less than or equal to][comparison] -| `@` | At | [Subpattern binding] -| `.` | Dot | [Field access][field], [Tuple index] -| `..` | DotDot | [Range][range], [Struct expressions], [Patterns], [Range Patterns][rangepat] -| `...` | DotDotDot | [Variadic functions][extern], [Range patterns] -| `..=` | DotDotEq | [Inclusive Range][range], [Range patterns] -| `,` | Comma | Various separators -| `;` | Semi | Terminator for various items and statements, [Array types] -| `:` | Colon | Various separators -| `::` | PathSep | [Path separator][paths] -| `->` | RArrow | [Function return type][functions], [Closure return type][closures], [Function pointer type] -| `=>` | FatArrow | [Match arms][match], [Macros] -| `<-` | LArrow | The left arrow symbol has been unused since before Rust 1.0, but it is still treated as a single token -| `#` | Pound | [Attributes] -| `$` | Dollar | [Macros] -| `?` | Question | [Try propagation expressions][question], [Questionably sized][sized], [Macro Kleene Matcher][macros] -| `~` | Tilde | The tilde operator has been unused since before Rust 1.0, but its token may still be used - r[lex.token.delim] ## Delimiters @@ -1019,59 +969,14 @@ r[lex.token.reserved-guards.edition2024] > [!EDITION-2024] > Before the 2024 edition, reserved guards are accepted by the lexer and interpreted as multiple tokens. For example, the `#"foo"#` form is interpreted as three tokens. `##` is interpreted as two tokens. -[Inferred types]: types/inferred.md -[Range patterns]: patterns.md#range-patterns -[Reference patterns]: patterns.md#reference-patterns -[Subpattern binding]: patterns.md#identifier-patterns -[Wildcard patterns]: patterns.md#wildcard-pattern -[arith]: expressions/operator-expr.md#arithmetic-and-logical-binary-operators -[array types]: types/array.md -[assignment]: expressions/operator-expr.md#assignment-expressions -[attributes]: attributes.md -[borrow]: expressions/operator-expr.md#borrow-operators -[closures]: expressions/closure-expr.md -[comparison]: expressions/operator-expr.md#comparison-operators -[compound]: expressions/operator-expr.md#compound-assignment-expressions -[constants]: items/constant-items.md -[dereference]: expressions/operator-expr.md#the-dereference-operator -[destructuring assignment]: expressions/underscore-expr.md -[extern crates]: items/extern-crates.md -[extern]: items/external-blocks.md -[field]: expressions/field-expr.md [Floating-point literal expressions]: expressions/literal-expr.md#floating-point-literal-expressions -[floating-point types]: types/numeric.md#floating-point-types -[function pointer type]: types/function-pointer.md -[functions]: items/functions.md -[generics]: items/generics.md [identifier]: identifiers.md -[if let]: expressions/if-expr.md#if-let-patterns [Integer literal expressions]: expressions/literal-expr.md#integer-literal-expressions [keywords]: keywords.md -[lazy-bool]: expressions/operator-expr.md#lazy-boolean-operators [literal expressions]: expressions/literal-expr.md [loop labels]: expressions/loop-expr.md [macros]: macros-by-example.md -[match]: expressions/match-expr.md -[negation]: expressions/operator-expr.md#negation-operators -[negative impls]: items/implementations.md -[never type]: types/never.md -[numeric types]: types/numeric.md -[paths]: paths.md -[patterns]: patterns.md -[question]: expressions/operator-expr.md#the-try-propagation-expression -[range]: expressions/range-expr.md -[rangepat]: patterns.md#range-patterns -[raw pointers]: types/pointer.md#raw-pointers-const-and-mut -[references]: types/pointer.md -[sized]: trait-bounds.md#sized [String continuation escapes]: expressions/literal-expr.md#string-continuation-escapes -[struct expressions]: expressions/struct-expr.md -[trait bounds]: trait-bounds.md -[tuple index]: expressions/tuple-expr.md#tuple-indexing-expressions [tuple structs]: items/structs.md [tuple enum variants]: items/enumerations.md [tuples]: types/tuple.md -[unary minus operator]: expressions/operator-expr.md#negation-operators -[use declarations]: items/use-declarations.md -[use wildcards]: items/use-declarations.md -[while let]: expressions/loop-expr.md#while-let-patterns From 12678cb139501955d102eec5820652c39b2a836a Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 22 Oct 2025 16:28:10 -0700 Subject: [PATCH 02/49] Lowercase punctuation index links This adjusts the capitalization just because I felt the mixed and inconsistent capitalization looked odd, and it felt simpler to just keep it lowercase. I also didn't feel like there was a particular need to sentence case these. --- src/syntax-index.md | 102 ++++++++++++++++++++++---------------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index b57a4bd3a8..99113a0678 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -8,58 +8,53 @@ This appendix provides an index of tokens and common forms with links to where t | Symbol | Name | Usage | |--------|-------------|-------| -| `+` | Plus | [Addition][arith], [Trait Bounds], [Macro Kleene Matcher][macros] -| `-` | Minus | [Subtraction][arith], [Negation] -| `*` | Star | [Multiplication][arith], [Dereference], [Raw Pointers], [Macro Kleene Matcher][macros], [Use wildcards] -| `/` | Slash | [Division][arith] -| `%` | Percent | [Remainder][arith] -| `^` | Caret | [Bitwise and Logical XOR][arith] -| `!` | Not | [Bitwise and Logical NOT][negation], [Macro Calls][macros], [Inner Attributes][attributes], [Never Type], [Negative impls] -| `&` | And | [Bitwise and Logical AND][arith], [Borrow], [References], [Reference patterns] -| \| | Or | [Bitwise and Logical OR][arith], [Closures], Patterns in [match], [if let], and [while let] -| `&&` | AndAnd | [Lazy AND][lazy-bool], [Borrow], [References], [Reference patterns] -| \|\| | OrOr | [Lazy OR][lazy-bool], [Closures] -| `<<` | Shl | [Shift Left][arith], [Nested Generics][generics] -| `>>` | Shr | [Shift Right][arith], [Nested Generics][generics] -| `+=` | PlusEq | [Addition assignment][compound] -| `-=` | MinusEq | [Subtraction assignment][compound] -| `*=` | StarEq | [Multiplication assignment][compound] -| `/=` | SlashEq | [Division assignment][compound] -| `%=` | PercentEq | [Remainder assignment][compound] -| `^=` | CaretEq | [Bitwise XOR assignment][compound] -| `&=` | AndEq | [Bitwise And assignment][compound] -| \|= | OrEq | [Bitwise Or assignment][compound] -| `<<=` | ShlEq | [Shift Left assignment][compound] -| `>>=` | ShrEq | [Shift Right assignment][compound], [Nested Generics][generics] -| `=` | Eq | [Assignment], [Attributes], Various type definitions -| `==` | EqEq | [Equal][comparison] -| `!=` | Ne | [Not Equal][comparison] -| `>` | Gt | [Greater than][comparison], [Generics], [Paths] -| `<` | Lt | [Less than][comparison], [Generics], [Paths] -| `>=` | Ge | [Greater than or equal to][comparison], [Generics] -| `<=` | Le | [Less than or equal to][comparison] -| `@` | At | [Subpattern binding] -| `.` | Dot | [Field access][field], [Tuple index] -| `..` | DotDot | [Range][range], [Struct expressions], [Patterns], [Range Patterns][rangepat] -| `...` | DotDotDot | [Variadic functions][extern], [Range patterns] -| `..=` | DotDotEq | [Inclusive Range][range], [Range patterns] -| `,` | Comma | Various separators -| `;` | Semi | Terminator for various items and statements, [Array types] -| `:` | Colon | Various separators -| `::` | PathSep | [Path separator][paths] -| `->` | RArrow | [Function return type][functions], [Closure return type][closures], [Function pointer type] -| `=>` | FatArrow | [Match arms][match], [Macros] -| `<-` | LArrow | The left arrow symbol has been unused since before Rust 1.0, but it is still treated as a single token -| `#` | Pound | [Attributes] -| `$` | Dollar | [Macros] -| `?` | Question | [Try propagation expressions][question], [Questionably sized][sized], [Macro Kleene Matcher][macros] -| `~` | Tilde | The tilde operator has been unused since before Rust 1.0, but its token may still be used +| `+` | Plus | [addition][arith], [trait bounds], [macro Kleene matcher][macros] +| `-` | Minus | [subtraction][arith], [negation] +| `*` | Star | [multiplication][arith], [dereference], [raw pointers], [macro Kleene matcher][macros], [use wildcards] +| `/` | Slash | [division][arith] +| `%` | Percent | [remainder][arith] +| `^` | Caret | [bitwise and logical XOR][arith] +| `!` | Not | [bitwise and logical NOT][negation], [macro calls][macros], [inner attributes][attributes], [never type], [negative impls] +| `&` | And | [bitwise and logical AND][arith], [borrow], [references], [reference patterns] +| \| | Or | [bitwise and logical OR][arith], [closures], patterns in [match], [if let], and [while let] +| `&&` | AndAnd | [lazy AND][lazy-bool], [borrow], [references], [reference patterns] +| \|\| | OrOr | [lazy OR][lazy-bool], [closures] +| `<<` | Shl | [shift left][arith], [nested generics][generics] +| `>>` | Shr | [shift right][arith], [nested generics][generics] +| `+=` | PlusEq | [addition assignment][compound] +| `-=` | MinusEq | [subtraction assignment][compound] +| `*=` | StarEq | [multiplication assignment][compound] +| `/=` | SlashEq | [division assignment][compound] +| `%=` | PercentEq | [remainder assignment][compound] +| `^=` | CaretEq | [bitwise XOR assignment][compound] +| `&=` | AndEq | [bitwise AND assignment][compound] +| \|= | OrEq | [bitwise OR assignment][compound] +| `<<=` | ShlEq | [shift left assignment][compound] +| `>>=` | ShrEq | [shift right assignment][compound], [nested generics][generics] +| `=` | Eq | [assignment], [attributes], various type definitions +| `==` | EqEq | [equal][comparison] +| `!=` | Ne | [not equal][comparison] +| `>` | Gt | [greater than][comparison], [generics], [paths] +| `<` | Lt | [less than][comparison], [generics], [paths] +| `>=` | Ge | [greater than or equal to][comparison], [generics] +| `<=` | Le | [less than or equal to][comparison] +| `@` | At | [subpattern binding] +| `.` | Dot | [field access][field], [tuple index] +| `..` | DotDot | [range][range], [struct expressions], [patterns], [range patterns][rangepat] +| `...` | DotDotDot | [variadic functions][extern], [range patterns] +| `..=` | DotDotEq | [inclusive range][range], [range patterns] +| `,` | Comma | various separators +| `;` | Semi | terminator for various items and statements, [array types] +| `:` | Colon | various separators +| `::` | PathSep | [path separator][paths] +| `->` | RArrow | [function return type][functions], [closure return type][closures], [function pointer type] +| `=>` | FatArrow | [match arms][match], [macros] +| `<-` | LArrow | The left arrow symbol has been unused since before Rust 1.0, but it is still treated as a single token. +| `#` | Pound | [attributes] +| `$` | Dollar | [macros] +| `?` | Question | [try propagation expressions][question], [questionably sized][sized], [macro Kleene matcher][macros] +| `~` | Tilde | The tilde operator has been unused since before Rust 1.0, but its token may still be used. -[Inferred types]: types/inferred.md -[Range patterns]: patterns.md#range-patterns -[Reference patterns]: patterns.md#reference-patterns -[Subpattern binding]: patterns.md#identifier-patterns -[Wildcard patterns]: patterns.md#wildcard-pattern [arith]: expressions/operator-expr.md#arithmetic-and-logical-binary-operators [array types]: types/array.md [assignment]: expressions/operator-expr.md#assignment-expressions @@ -78,6 +73,7 @@ This appendix provides an index of tokens and common forms with links to where t [functions]: items/functions.md [generics]: items/generics.md [if let]: expressions/if-expr.md#if-let-patterns +[inferred types]: types/inferred.md [lazy-bool]: expressions/operator-expr.md#lazy-boolean-operators [macros]: macros-by-example.md [match]: expressions/match-expr.md @@ -87,14 +83,18 @@ This appendix provides an index of tokens and common forms with links to where t [paths]: paths.md [patterns]: patterns.md [question]: expressions/operator-expr.md#the-try-propagation-expression +[range patterns]: patterns.md#range-patterns [range]: expressions/range-expr.md [rangepat]: patterns.md#range-patterns [raw pointers]: types/pointer.md#raw-pointers-const-and-mut +[reference patterns]: patterns.md#reference-patterns [references]: types/pointer.md [sized]: trait-bounds.md#sized [struct expressions]: expressions/struct-expr.md +[subpattern binding]: patterns.md#identifier-patterns [trait bounds]: trait-bounds.md [tuple index]: expressions/tuple-expr.md#tuple-indexing-expressions [use declarations]: items/use-declarations.md [use wildcards]: items/use-declarations.md [while let]: expressions/loop-expr.md#while-let-patterns +[wildcard patterns]: patterns.md#wildcard-pattern From 89294c20b4e480a7eb2e6d331cc62a935b04be5b Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 22 Oct 2025 16:34:21 -0700 Subject: [PATCH 03/49] Remove a stray "and" None of the other lists use "and" for the final element. I'm not sure why this was here. --- src/syntax-index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index 99113a0678..3531686f32 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -16,7 +16,7 @@ This appendix provides an index of tokens and common forms with links to where t | `^` | Caret | [bitwise and logical XOR][arith] | `!` | Not | [bitwise and logical NOT][negation], [macro calls][macros], [inner attributes][attributes], [never type], [negative impls] | `&` | And | [bitwise and logical AND][arith], [borrow], [references], [reference patterns] -| \| | Or | [bitwise and logical OR][arith], [closures], patterns in [match], [if let], and [while let] +| \| | Or | [bitwise and logical OR][arith], [closures], patterns in [match], [if let], [while let] | `&&` | AndAnd | [lazy AND][lazy-bool], [borrow], [references], [reference patterns] | \|\| | OrOr | [lazy OR][lazy-bool], [closures] | `<<` | Shl | [shift left][arith], [nested generics][generics] From f0a259b92b4b54946258ce1968e10215c12499b7 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 22 Oct 2025 16:35:24 -0700 Subject: [PATCH 04/49] Add a trailing pipe for the punctuation table This adds a pipe at the end of the line because it is the recommended style for gfm tables. --- src/syntax-index.md | 92 ++++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index 3531686f32..d0a018ac6f 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -8,52 +8,52 @@ This appendix provides an index of tokens and common forms with links to where t | Symbol | Name | Usage | |--------|-------------|-------| -| `+` | Plus | [addition][arith], [trait bounds], [macro Kleene matcher][macros] -| `-` | Minus | [subtraction][arith], [negation] -| `*` | Star | [multiplication][arith], [dereference], [raw pointers], [macro Kleene matcher][macros], [use wildcards] -| `/` | Slash | [division][arith] -| `%` | Percent | [remainder][arith] -| `^` | Caret | [bitwise and logical XOR][arith] -| `!` | Not | [bitwise and logical NOT][negation], [macro calls][macros], [inner attributes][attributes], [never type], [negative impls] -| `&` | And | [bitwise and logical AND][arith], [borrow], [references], [reference patterns] -| \| | Or | [bitwise and logical OR][arith], [closures], patterns in [match], [if let], [while let] -| `&&` | AndAnd | [lazy AND][lazy-bool], [borrow], [references], [reference patterns] -| \|\| | OrOr | [lazy OR][lazy-bool], [closures] -| `<<` | Shl | [shift left][arith], [nested generics][generics] -| `>>` | Shr | [shift right][arith], [nested generics][generics] -| `+=` | PlusEq | [addition assignment][compound] -| `-=` | MinusEq | [subtraction assignment][compound] -| `*=` | StarEq | [multiplication assignment][compound] -| `/=` | SlashEq | [division assignment][compound] -| `%=` | PercentEq | [remainder assignment][compound] -| `^=` | CaretEq | [bitwise XOR assignment][compound] -| `&=` | AndEq | [bitwise AND assignment][compound] -| \|= | OrEq | [bitwise OR assignment][compound] -| `<<=` | ShlEq | [shift left assignment][compound] -| `>>=` | ShrEq | [shift right assignment][compound], [nested generics][generics] -| `=` | Eq | [assignment], [attributes], various type definitions -| `==` | EqEq | [equal][comparison] -| `!=` | Ne | [not equal][comparison] -| `>` | Gt | [greater than][comparison], [generics], [paths] -| `<` | Lt | [less than][comparison], [generics], [paths] -| `>=` | Ge | [greater than or equal to][comparison], [generics] -| `<=` | Le | [less than or equal to][comparison] -| `@` | At | [subpattern binding] -| `.` | Dot | [field access][field], [tuple index] -| `..` | DotDot | [range][range], [struct expressions], [patterns], [range patterns][rangepat] -| `...` | DotDotDot | [variadic functions][extern], [range patterns] -| `..=` | DotDotEq | [inclusive range][range], [range patterns] -| `,` | Comma | various separators -| `;` | Semi | terminator for various items and statements, [array types] -| `:` | Colon | various separators -| `::` | PathSep | [path separator][paths] -| `->` | RArrow | [function return type][functions], [closure return type][closures], [function pointer type] -| `=>` | FatArrow | [match arms][match], [macros] -| `<-` | LArrow | The left arrow symbol has been unused since before Rust 1.0, but it is still treated as a single token. -| `#` | Pound | [attributes] -| `$` | Dollar | [macros] -| `?` | Question | [try propagation expressions][question], [questionably sized][sized], [macro Kleene matcher][macros] -| `~` | Tilde | The tilde operator has been unused since before Rust 1.0, but its token may still be used. +| `+` | Plus | [addition][arith], [trait bounds], [macro Kleene matcher][macros] | +| `-` | Minus | [subtraction][arith], [negation] | +| `*` | Star | [multiplication][arith], [dereference], [raw pointers], [macro Kleene matcher][macros], [use wildcards] | +| `/` | Slash | [division][arith] | +| `%` | Percent | [remainder][arith] | +| `^` | Caret | [bitwise and logical XOR][arith] | +| `!` | Not | [bitwise and logical NOT][negation], [macro calls][macros], [inner attributes][attributes], [never type], [negative impls] | +| `&` | And | [bitwise and logical AND][arith], [borrow], [references], [reference patterns] | +| \| | Or | [bitwise and logical OR][arith], [closures], patterns in [match], [if let], [while let] | +| `&&` | AndAnd | [lazy AND][lazy-bool], [borrow], [references], [reference patterns] | +| \|\| | OrOr | [lazy OR][lazy-bool], [closures] | +| `<<` | Shl | [shift left][arith], [nested generics][generics] | +| `>>` | Shr | [shift right][arith], [nested generics][generics] | +| `+=` | PlusEq | [addition assignment][compound] | +| `-=` | MinusEq | [subtraction assignment][compound] | +| `*=` | StarEq | [multiplication assignment][compound] | +| `/=` | SlashEq | [division assignment][compound] | +| `%=` | PercentEq | [remainder assignment][compound] | +| `^=` | CaretEq | [bitwise XOR assignment][compound] | +| `&=` | AndEq | [bitwise AND assignment][compound] | +| \|= | OrEq | [bitwise OR assignment][compound] | +| `<<=` | ShlEq | [shift left assignment][compound] | +| `>>=` | ShrEq | [shift right assignment][compound], [nested generics][generics] | +| `=` | Eq | [assignment], [attributes], various type definitions | +| `==` | EqEq | [equal][comparison] | +| `!=` | Ne | [not equal][comparison] | +| `>` | Gt | [greater than][comparison], [generics], [paths] | +| `<` | Lt | [less than][comparison], [generics], [paths] | +| `>=` | Ge | [greater than or equal to][comparison], [generics] | +| `<=` | Le | [less than or equal to][comparison] | +| `@` | At | [subpattern binding] | +| `.` | Dot | [field access][field], [tuple index] | +| `..` | DotDot | [range][range], [struct expressions], [patterns], [range patterns][rangepat] | +| `...` | DotDotDot | [variadic functions][extern], [range patterns] | +| `..=` | DotDotEq | [inclusive range][range], [range patterns] | +| `,` | Comma | various separators | +| `;` | Semi | terminator for various items and statements, [array types] | +| `:` | Colon | various separators | +| `::` | PathSep | [path separator][paths] | +| `->` | RArrow | [function return type][functions], [closure return type][closures], [function pointer type] | +| `=>` | FatArrow | [match arms][match], [macros] | +| `<-` | LArrow | The left arrow symbol has been unused since before Rust 1.0, but it is still treated as a single token. | +| `#` | Pound | [attributes] | +| `$` | Dollar | [macros] | +| `?` | Question | [try propagation expressions][question], [questionably sized][sized], [macro Kleene matcher][macros] | +| `~` | Tilde | The tilde operator has been unused since before Rust 1.0, but its token may still be used. | [arith]: expressions/operator-expr.md#arithmetic-and-logical-binary-operators [array types]: types/array.md From f8b53c7bb04fb6f9c90a0fe4e3056f3f7e276227 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 22 Oct 2025 16:38:08 -0700 Subject: [PATCH 05/49] Update pipe for or-patterns The pipe symbol wasn't updated when or-patterns were stabilized. This updates it for that new grammar. --- src/syntax-index.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index d0a018ac6f..c81dbc8ed0 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -16,7 +16,7 @@ This appendix provides an index of tokens and common forms with links to where t | `^` | Caret | [bitwise and logical XOR][arith] | | `!` | Not | [bitwise and logical NOT][negation], [macro calls][macros], [inner attributes][attributes], [never type], [negative impls] | | `&` | And | [bitwise and logical AND][arith], [borrow], [references], [reference patterns] | -| \| | Or | [bitwise and logical OR][arith], [closures], patterns in [match], [if let], [while let] | +| \| | Or | [bitwise and logical OR][arith], [closures], [or patterns], [if let], [while let] | | `&&` | AndAnd | [lazy AND][lazy-bool], [borrow], [references], [reference patterns] | | \|\| | OrOr | [lazy OR][lazy-bool], [closures] | | `<<` | Shl | [shift left][arith], [nested generics][generics] | @@ -80,6 +80,7 @@ This appendix provides an index of tokens and common forms with links to where t [negation]: expressions/operator-expr.md#negation-operators [negative impls]: items/implementations.md [never type]: types/never.md +[or patterns]: patterns.or [paths]: paths.md [patterns]: patterns.md [question]: expressions/operator-expr.md#the-try-propagation-expression From cb0194fe4f4d874acb222bf613932dcb9e60dd9b Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 22 Oct 2025 16:40:33 -0700 Subject: [PATCH 06/49] Add use bounds for punctuation index When use bounds were stabilized, I forgot to add the angle brackets to the index. --- src/syntax-index.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index c81dbc8ed0..4bf1ac6440 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -34,8 +34,8 @@ This appendix provides an index of tokens and common forms with links to where t | `=` | Eq | [assignment], [attributes], various type definitions | | `==` | EqEq | [equal][comparison] | | `!=` | Ne | [not equal][comparison] | -| `>` | Gt | [greater than][comparison], [generics], [paths] | -| `<` | Lt | [less than][comparison], [generics], [paths] | +| `>` | Gt | [greater than][comparison], [generics], [paths], [use bounds] | +| `<` | Lt | [less than][comparison], [generics], [paths], [use bounds] | | `>=` | Ge | [greater than or equal to][comparison], [generics] | | `<=` | Le | [less than or equal to][comparison] | | `@` | At | [subpattern binding] | @@ -95,6 +95,7 @@ This appendix provides an index of tokens and common forms with links to where t [subpattern binding]: patterns.md#identifier-patterns [trait bounds]: trait-bounds.md [tuple index]: expressions/tuple-expr.md#tuple-indexing-expressions +[use bounds]: bound.use [use declarations]: items/use-declarations.md [use wildcards]: items/use-declarations.md [while let]: expressions/loop-expr.md#while-let-patterns From bc145b842c683f334cd0664ab739be1ea9448b66 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 22 Oct 2025 16:42:11 -0700 Subject: [PATCH 07/49] Add let statements for `=` This adds let statements to the `=` index entry. It really is distinct from assignment, and I probably just overlooked that. --- src/syntax-index.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index 4bf1ac6440..36ab460ee5 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -31,7 +31,7 @@ This appendix provides an index of tokens and common forms with links to where t | \|= | OrEq | [bitwise OR assignment][compound] | | `<<=` | ShlEq | [shift left assignment][compound] | | `>>=` | ShrEq | [shift right assignment][compound], [nested generics][generics] | -| `=` | Eq | [assignment], [attributes], various type definitions | +| `=` | Eq | [assignment], [let statements], [attributes], various type definitions | | `==` | EqEq | [equal][comparison] | | `!=` | Ne | [not equal][comparison] | | `>` | Gt | [greater than][comparison], [generics], [paths], [use bounds] | @@ -75,6 +75,7 @@ This appendix provides an index of tokens and common forms with links to where t [if let]: expressions/if-expr.md#if-let-patterns [inferred types]: types/inferred.md [lazy-bool]: expressions/operator-expr.md#lazy-boolean-operators +[let statements]: statement.let [macros]: macros-by-example.md [match]: expressions/match-expr.md [negation]: expressions/operator-expr.md#negation-operators From 81f798a46cdb1213c5dcec4e169994de95974bef Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 22 Oct 2025 17:12:16 -0700 Subject: [PATCH 08/49] Switch links to rule links This switches all the links to rule links for consistency. It's easier to link to specific rules this way. Some of the links were adjusted to go to more specific rules. --- src/syntax-index.md | 100 ++++++++++++++++++++++---------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index 36ab460ee5..e39ab4181b 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -8,13 +8,13 @@ This appendix provides an index of tokens and common forms with links to where t | Symbol | Name | Usage | |--------|-------------|-------| -| `+` | Plus | [addition][arith], [trait bounds], [macro Kleene matcher][macros] | +| `+` | Plus | [addition][arith], [trait bounds], [macro Kleene matcher] | | `-` | Minus | [subtraction][arith], [negation] | -| `*` | Star | [multiplication][arith], [dereference], [raw pointers], [macro Kleene matcher][macros], [use wildcards] | +| `*` | Star | [multiplication][arith], [dereference], [raw pointers], [macro Kleene matcher], [glob imports] | | `/` | Slash | [division][arith] | | `%` | Percent | [remainder][arith] | | `^` | Caret | [bitwise and logical XOR][arith] | -| `!` | Not | [bitwise and logical NOT][negation], [macro calls][macros], [inner attributes][attributes], [never type], [negative impls] | +| `!` | Not | [bitwise and logical NOT][negation], [macro calls], [inner attributes][attributes], [never type], [negative impls] | | `&` | And | [bitwise and logical AND][arith], [borrow], [references], [reference patterns] | | \| | Or | [bitwise and logical OR][arith], [closures], [or patterns], [if let], [while let] | | `&&` | AndAnd | [lazy AND][lazy-bool], [borrow], [references], [reference patterns] | @@ -40,9 +40,9 @@ This appendix provides an index of tokens and common forms with links to where t | `<=` | Le | [less than or equal to][comparison] | | `@` | At | [subpattern binding] | | `.` | Dot | [field access][field], [tuple index] | -| `..` | DotDot | [range][range], [struct expressions], [patterns], [range patterns][rangepat] | -| `...` | DotDotDot | [variadic functions][extern], [range patterns] | -| `..=` | DotDotEq | [inclusive range][range], [range patterns] | +| `..` | DotDot | [range expressions][expr.range], [struct expressions], [rest patterns], [range patterns], [struct patterns] | +| `...` | DotDotDot | [variadic functions], [range patterns] | +| `..=` | DotDotEq | [inclusive range expressions][expr.range], [range patterns] | | `,` | Comma | various separators | | `;` | Semi | terminator for various items and statements, [array types] | | `:` | Colon | various separators | @@ -52,52 +52,52 @@ This appendix provides an index of tokens and common forms with links to where t | `<-` | LArrow | The left arrow symbol has been unused since before Rust 1.0, but it is still treated as a single token. | | `#` | Pound | [attributes] | | `$` | Dollar | [macros] | -| `?` | Question | [try propagation expressions][question], [questionably sized][sized], [macro Kleene matcher][macros] | +| `?` | Question | [try propagation expressions][question], [questionably sized][sized], [macro Kleene matcher] | | `~` | Tilde | The tilde operator has been unused since before Rust 1.0, but its token may still be used. | -[arith]: expressions/operator-expr.md#arithmetic-and-logical-binary-operators -[array types]: types/array.md -[assignment]: expressions/operator-expr.md#assignment-expressions -[attributes]: attributes.md -[borrow]: expressions/operator-expr.md#borrow-operators -[closures]: expressions/closure-expr.md -[comparison]: expressions/operator-expr.md#comparison-operators -[compound]: expressions/operator-expr.md#compound-assignment-expressions -[constants]: items/constant-items.md -[dereference]: expressions/operator-expr.md#the-dereference-operator -[destructuring assignment]: expressions/underscore-expr.md -[extern crates]: items/extern-crates.md -[extern]: items/external-blocks.md -[field]: expressions/field-expr.md -[function pointer type]: types/function-pointer.md -[functions]: items/functions.md -[generics]: items/generics.md -[if let]: expressions/if-expr.md#if-let-patterns -[inferred types]: types/inferred.md -[lazy-bool]: expressions/operator-expr.md#lazy-boolean-operators +[arith]: expr.arith-logic +[array types]: type.array +[assignment]: expr.assign +[borrow]: expr.operator.borrow +[closures]: expr.closure +[comparison]: expr.cmp +[compound]: expr.compound-assign +[constants]: items.const +[dereference]: expr.deref +[destructuring assignment]: expr.placeholder +[extern crates]: items.extern-crate +[extern]: items.extern +[field]: expr.field +[function pointer type]: type.fn-pointer +[functions]: items.fn +[generics]: items.generics +[glob imports]: items.use.glob +[if let]: expr.if.let +[inferred types]: type.inferred +[lazy-bool]: expr.bool-logic [let statements]: statement.let -[macros]: macros-by-example.md -[match]: expressions/match-expr.md -[negation]: expressions/operator-expr.md#negation-operators -[negative impls]: items/implementations.md -[never type]: types/never.md +[macro calls]: macro.invocation +[macro Kleene matcher]: macro.decl.repetition +[macros]: macro.decl +[match]: expr.match +[negation]: expr.negate +[negative impls]: items.impl +[never type]: type.never [or patterns]: patterns.or -[paths]: paths.md -[patterns]: patterns.md -[question]: expressions/operator-expr.md#the-try-propagation-expression -[range patterns]: patterns.md#range-patterns -[range]: expressions/range-expr.md -[rangepat]: patterns.md#range-patterns -[raw pointers]: types/pointer.md#raw-pointers-const-and-mut -[reference patterns]: patterns.md#reference-patterns -[references]: types/pointer.md -[sized]: trait-bounds.md#sized -[struct expressions]: expressions/struct-expr.md -[subpattern binding]: patterns.md#identifier-patterns -[trait bounds]: trait-bounds.md -[tuple index]: expressions/tuple-expr.md#tuple-indexing-expressions +[question]: expr.try +[range patterns]: patterns.range +[raw pointers]: type.pointer.raw +[reference patterns]: patterns.ref +[references]: type.pointer.reference +[rest patterns]: patterns.rest +[sized]: bound.sized +[struct expressions]: expr.struct +[struct patterns]: patterns.struct +[subpattern binding]: patterns.ident.scrutinized +[trait bounds]: bound +[tuple index]: expr.tuple-index [use bounds]: bound.use -[use declarations]: items/use-declarations.md -[use wildcards]: items/use-declarations.md -[while let]: expressions/loop-expr.md#while-let-patterns -[wildcard patterns]: patterns.md#wildcard-pattern +[use declarations]: items.use +[variadic functions]: items.extern.variadic +[while let]: expr.loop.while.let +[wildcard patterns]: patterns.wildcard From 98ae16bea30fc2345bfbf0cad36c467cba7e40fe Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 22 Oct 2025 17:19:46 -0700 Subject: [PATCH 09/49] Add link forwarding to the syntax index --- src/tokens.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/tokens.md b/src/tokens.md index 28fd8deffa..316f232a21 100644 --- a/src/tokens.md +++ b/src/tokens.md @@ -855,6 +855,9 @@ PUNCTUATION -> | `)` ``` +> [!NOTE] +> See the [syntax index] for links to how punctuation characters are used. + r[lex.token.delim] ## Delimiters @@ -977,6 +980,7 @@ r[lex.token.reserved-guards.edition2024] [loop labels]: expressions/loop-expr.md [macros]: macros-by-example.md [String continuation escapes]: expressions/literal-expr.md#string-continuation-escapes +[syntax index]: syntax-index.md#operators-and-punctuation [tuple structs]: items/structs.md [tuple enum variants]: items/enumerations.md [tuples]: types/tuple.md From 120227e355df70ce6660a5a72dde43befb2b8752 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 22 Oct 2025 17:21:32 -0700 Subject: [PATCH 10/49] Disable indexing for the syntax index This pollutes the search index, since the reader probably wants to go to the things that these point to. --- book.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/book.toml b/book.toml index 8e85b4a787..efe1405354 100644 --- a/book.toml +++ b/book.toml @@ -18,8 +18,9 @@ level = 0 use-boolean-and = true [output.html.search.chapter] -"test-summary.md" = { enable = false } "grammar.md" = { enable = false } +"syntax-index.md" = { enable = false } +"test-summary.md" = { enable = false } [output.html.redirect] "/crates-and-source-files.html#preludes-and-no_std" = "names/preludes.html" From 1a1c5bd4459d447042321d9398cc5f4eb22a5c76 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 22 Oct 2025 17:32:30 -0700 Subject: [PATCH 11/49] Add keywords to the syntax index --- src/syntax-index.md | 135 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) diff --git a/src/syntax-index.md b/src/syntax-index.md index e39ab4181b..fe089a05af 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -4,6 +4,66 @@ This appendix provides an index of tokens and common forms with links to where t ## Keywords +| Keyword | Usage | +|---------------|-------| +| `_` | [wildcard patterns], [inferred types], unnamed items in [constants], [extern crates], [use declarations], [destructuring assignment] | +| `abstract` | [reserved keyword] | +| `as` | [extern crate alias], [use alias], [type cast expressions], [qualified paths] | +| `async` | [async functions], [async blocks], [async closures] | +| `await` | [await expressions] | +| `become` | [reserved keyword] | +| `box` | [reserved keyword] | +| `break` | [break expressions] | +| `const` | [const functions], [const items], [const generics], [const blocks], [raw borrow operator], [raw pointer type], [const assembly operands] | +| `continue` | [continue expressions] | +| `crate` | [extern crates], [visibility], [paths] | +| `do` | [reserved keyword] | +| `dyn` | [trait objects] | +| `else` | [let statements], [if expressions] | +| `enum` | [enumerations] | +| `extern` | [extern crate], [extern function qualifier], [external blocks], [extern function pointer types] | +| `false` | [boolean type], [boolean expressions], [configuration predicates] | +| `final` | [reserved keyword] | +| `fn` | [functions], [function pointer types] | +| `for` | [trait implementations], [iterator loops], [higher-ranked trait bounds] | +| `gen` | [reserved keyword] | +| `if` | [if expressions], [match guards] | +| `impl` | [inherent impls], [trait impls], [impl traits] | +| `in` | [visibility], [iterator loops], [assembly operands] | +| `let` | [let statements], [`if let` patterns] | +| `loop` | [infinite loops] | +| `macro_rules` | [macros by example] | +| `macro` | [reserved keyword] | +| `match` | [match expressions] | +| `mod` | [modules] | +| `move` | [closure expressions], [async blocks] | +| `mut` | [borrow expressions], [identifier patterns], [reference patterns], [struct patterns], [reference types], [raw pointer types], [self parameters], [static items] | +| `override` | [reserved keyword] | +| `priv` | [reserved keyword] | +| `pub` | [visibility] | +| `raw` | [borrow expressions], [raw assembly] | +| `ref` | [identifier patterns], [struct patterns] | +| `return` | [return expressions] | +| `safe` | [external block functions], [external block statics] | +| `self` | [extern crates][items.extern-crate.self], [self parameters], [visibility], [`self` paths] | +| `Self` | [`Self` type paths], [use bounds] | +| `static` | [static items], [`'static` lifetimes] | +| `struct` | [structs] | +| `super` | [super paths], [visibility] | +| `trait` | [trait items] | +| `true` | [boolean type], [boolean expressions], [configuration predicates] | +| `try` | [reserved keyword] | +| `type` | [type aliases] | +| `typeof` | [reserved keyword] | +| `union` | [union items] | +| `unsafe` | [unsafe attributes], [unsafe modules], [unsafe functions], [unsafe static items], [unsafe external blocks], [unsafe external functions], [unsafe external statics], [unsafe traits], [unsafe trait implementations] | +| `unsized` | [reserved keyword] | +| `use` | [use items], [use bounds] | +| `virtual` | [reserved keyword] | +| `where` | [where clauses] | +| `while` | [predicate loops] | +| `yield` | [reserved keyword] | + ## Operators and punctuation | Symbol | Name | Usage | @@ -55,49 +115,124 @@ This appendix provides an index of tokens and common forms with links to where t | `?` | Question | [try propagation expressions][question], [questionably sized][sized], [macro Kleene matcher] | | `~` | Tilde | The tilde operator has been unused since before Rust 1.0, but its token may still be used. | +[`'static` lifetimes]: bound +[`if let` patterns]: expr.if.let +[`self` paths]: paths.qualifiers.mod-self +[`Self` type paths]: paths.qualifiers.type-self [arith]: expr.arith-logic [array types]: type.array +[assembly operands]: asm.operand-type.supported-operands.in [assignment]: expr.assign +[async blocks]: expr.block.async +[async closures]: expr.closure.async +[async functions]: items.fn.async +[await expressions]: expr.await +[boolean expressions]: expr.literal +[boolean type]: type.bool +[borrow expressions]: expr.operator.borrow [borrow]: expr.operator.borrow +[break expressions]: expr.loop.break +[closure expressions]: expr.closure [closures]: expr.closure [comparison]: expr.cmp [compound]: expr.compound-assign +[configuration predicates]: cfg +[const assembly operands]: asm.operand-type.supported-operands.const +[const blocks]: expr.block.const +[const functions]: const-eval.const-fn +[const generics]: items.generics.const +[const items]: items.const [constants]: items.const +[continue expressions]: expr.loop.continue [dereference]: expr.deref [destructuring assignment]: expr.placeholder +[enumerations]: items.enum +[extern crate alias]: items.extern-crate.as +[extern crate]: items.extern-crate [extern crates]: items.extern-crate +[extern function pointer types]: type.fn-pointer.qualifiers +[extern function qualifier]: items.fn.extern [extern]: items.extern +[external block functions]: items.extern.fn +[external block statics]: items.extern.static +[external blocks]: items.extern [field]: expr.field [function pointer type]: type.fn-pointer +[function pointer types]: type.fn-pointer [functions]: items.fn [generics]: items.generics [glob imports]: items.use.glob +[higher-ranked trait bounds]: bound.higher-ranked +[identifier patterns]: patterns.ident +[if expressions]: expr.if [if let]: expr.if.let +[impl traits]: type.impl-trait [inferred types]: type.inferred +[infinite loops]: expr.loop.infinite +[inherent impls]: items.impl.inherent +[iterator loops]: expr.loop.for +[keywords chapter]: lex.keywords [lazy-bool]: expr.bool-logic [let statements]: statement.let [macro calls]: macro.invocation [macro Kleene matcher]: macro.decl.repetition +[macros by example]: macro.decl [macros]: macro.decl +[match expressions]: expr.match +[match guards]: expr.match.guard [match]: expr.match +[modules]: items.mod [negation]: expr.negate [negative impls]: items.impl [never type]: type.never [or patterns]: patterns.or +[predicate loops]: expr.loop.while +[qualified paths]: paths.qualified [question]: expr.try [range patterns]: patterns.range +[raw assembly]: asm.options.supported-options.raw +[raw borrow operator]: expr.borrow.raw +[raw pointer type]: type.pointer.raw +[raw pointer types]: type.pointer.raw [raw pointers]: type.pointer.raw [reference patterns]: patterns.ref +[reference types]: type.pointer.reference [references]: type.pointer.reference +[reserved keyword]: lex.keywords.reserved [rest patterns]: patterns.rest +[return expressions]: expr.return +[self parameters]: items.fn.params.self-pat [sized]: bound.sized +[static items]: items.static [struct expressions]: expr.struct [struct patterns]: patterns.struct +[structs]: items.struct [subpattern binding]: patterns.ident.scrutinized +[super paths]: paths.qualifiers.super [trait bounds]: bound +[trait implementations]: items.impl.trait +[trait impls]: items.impl.trait +[trait items]: items.traits +[trait objects]: type.trait-object [tuple index]: expr.tuple-index +[type aliases]: items.type +[type cast expressions]: expr.as +[union items]: items.union +[unsafe attributes]: attributes.safety +[unsafe external blocks]: unsafe.extern +[unsafe external functions]: items.extern.fn.safety +[unsafe external statics]: items.extern.static.safety +[unsafe functions]: unsafe.fn +[unsafe modules]: items.mod.unsafe +[unsafe static items]: items.static.mut.safety +[unsafe trait implementations]: items.impl.trait.safety +[unsafe traits]: items.traits.safety +[use alias]: items.use.forms.as [use bounds]: bound.use [use declarations]: items.use +[use items]: items.use [variadic functions]: items.extern.variadic +[visibility]: vis +[where clauses]: items.generics.where [while let]: expr.loop.while.let [wildcard patterns]: patterns.wildcard From 56826a3203c610c79adc1364cd9b3b96d427f07d Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 22 Oct 2025 17:37:35 -0700 Subject: [PATCH 12/49] Add comments to syntax index Unfortunately the comments chapter isn't organized in a way that it is easy to link to specific kinds of comments. --- src/syntax-index.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/syntax-index.md b/src/syntax-index.md index fe089a05af..78b21c15ae 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -115,6 +115,17 @@ This appendix provides an index of tokens and common forms with links to where t | `?` | Question | [try propagation expressions][question], [questionably sized][sized], [macro Kleene matcher] | | `~` | Tilde | The tilde operator has been unused since before Rust 1.0, but its token may still be used. | +## Comments + +| Comment | Usage | +|----------|-------| +| `//` | [line comment][comments] | +| `//!` | [inner line comment][comments] | +| `///` | [outer line doc comment][comments] | +| `/*…*/` | [block comment][comments] | +| `/*!…*/` | [inner block doc comment][comments] | +| `/**…*/` | [outer block doc comment][comments] | + [`'static` lifetimes]: bound [`if let` patterns]: expr.if.let [`self` paths]: paths.qualifiers.mod-self From fc335010ccc46ac8519881ff65388713e7511330 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 22 Oct 2025 18:02:28 -0700 Subject: [PATCH 13/49] Add other tokens to the syntax index --- src/syntax-index.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/syntax-index.md b/src/syntax-index.md index 78b21c15ae..b2c218e7b7 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -126,6 +126,24 @@ This appendix provides an index of tokens and common forms with links to where t | `/*!…*/` | [inner block doc comment][comments] | | `/**…*/` | [outer block doc comment][comments] | +## Other tokens + +| Token | Usage | +|--------------|-------| +| `ident` | [identifiers] | +| `r#ident` | [raw identifiers] | +| `'ident` | [lifetimes and loop labels] | +| `'r#ident` | [raw lifetimes and loop labels] | +| `…u8`, `…i32`, `…f64`, `…usize`, … | [number literals] | +| `"…"` | [string literals] | +| `r"…"`, `r#"…"#`, `r##"…"##`, … | [raw string literals] | +| `b"…"` | [byte string literals] | +| `br"…"`, `br#"…"#`, `br##"…"##`, … | [raw byte string literals] | +| `'…'` | [character literals] | +| `b'…'` | [byte literals] | +| `c"…"` | [C string literals] | +| `cr"…"`, `cr#"…"#`, `cr##"…"##`, … | [raw C string literals] | + [`'static` lifetimes]: bound [`if let` patterns]: expr.if.let [`self` paths]: paths.qualifiers.mod-self @@ -143,6 +161,10 @@ This appendix provides an index of tokens and common forms with links to where t [borrow expressions]: expr.operator.borrow [borrow]: expr.operator.borrow [break expressions]: expr.loop.break +[byte literals]: lex.token.byte +[byte string literals]: lex.token.str-byte +[C string literals]: lex.token.str-c +[character literals]: lex.token.literal.char [closure expressions]: expr.closure [closures]: expr.closure [comparison]: expr.cmp @@ -175,6 +197,7 @@ This appendix provides an index of tokens and common forms with links to where t [glob imports]: items.use.glob [higher-ranked trait bounds]: bound.higher-ranked [identifier patterns]: patterns.ident +[identifiers]: ident [if expressions]: expr.if [if let]: expr.if.let [impl traits]: type.impl-trait @@ -185,6 +208,7 @@ This appendix provides an index of tokens and common forms with links to where t [keywords chapter]: lex.keywords [lazy-bool]: expr.bool-logic [let statements]: statement.let +[lifetimes and loop labels]: lex.token.life [macro calls]: macro.invocation [macro Kleene matcher]: macro.decl.repetition [macros by example]: macro.decl @@ -196,6 +220,7 @@ This appendix provides an index of tokens and common forms with links to where t [negation]: expr.negate [negative impls]: items.impl [never type]: type.never +[number literals]: lex.token.literal.num [or patterns]: patterns.or [predicate loops]: expr.loop.while [qualified paths]: paths.qualified @@ -203,9 +228,14 @@ This appendix provides an index of tokens and common forms with links to where t [range patterns]: patterns.range [raw assembly]: asm.options.supported-options.raw [raw borrow operator]: expr.borrow.raw +[raw byte string literals]: lex.token.str-byte-raw +[raw C string literals]: lex.token.str-c-raw +[raw identifiers]: ident.raw +[raw lifetimes and loop labels]: lex.token.life [raw pointer type]: type.pointer.raw [raw pointer types]: type.pointer.raw [raw pointers]: type.pointer.raw +[raw string literals]: lex.token.literal.str-raw [reference patterns]: patterns.ref [reference types]: type.pointer.reference [references]: type.pointer.reference @@ -215,6 +245,7 @@ This appendix provides an index of tokens and common forms with links to where t [self parameters]: items.fn.params.self-pat [sized]: bound.sized [static items]: items.static +[string literals]: lex.token.literal.str [struct expressions]: expr.struct [struct patterns]: patterns.struct [structs]: items.struct From b49facd9dc28c39305bd515982c73b9451a8c68d Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Thu, 23 Oct 2025 07:19:45 -0700 Subject: [PATCH 14/49] Add macros to the syntax index --- src/syntax-index.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/syntax-index.md b/src/syntax-index.md index b2c218e7b7..6025888fa1 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -144,6 +144,15 @@ This appendix provides an index of tokens and common forms with links to where t | `c"…"` | [C string literals] | | `cr"…"`, `cr#"…"#`, `cr##"…"##`, … | [raw C string literals] | +## Macros + +| Syntax | Usage | +|-------------------------------------------|-------| +| `ident!(…)`
`ident!{…}`
`ident![…]` | [macro invocations] | +| `$ident` | [macro fragment substitution] | +| `$ident:kind` | [macro fragment specifier] | +| `$(…)…` | [macro repetition] | + [`'static` lifetimes]: bound [`if let` patterns]: expr.if.let [`self` paths]: paths.qualifiers.mod-self @@ -210,7 +219,11 @@ This appendix provides an index of tokens and common forms with links to where t [let statements]: statement.let [lifetimes and loop labels]: lex.token.life [macro calls]: macro.invocation +[macro fragment specifier]: macro.decl.meta.specifier +[macro fragment substitution]: macro.decl.meta.transcription +[macro invocations]: macro.invocation [macro Kleene matcher]: macro.decl.repetition +[macro repetition]: macro.decl.repetition [macros by example]: macro.decl [macros]: macro.decl [match expressions]: expr.match From 41e7de93eedd5f43ac177e4b2c866990dc5094a6 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Fri, 24 Oct 2025 05:52:44 -0700 Subject: [PATCH 15/49] Add attributes to syntax index --- src/syntax-index.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/syntax-index.md b/src/syntax-index.md index 6025888fa1..2bdc79b27c 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -153,6 +153,13 @@ This appendix provides an index of tokens and common forms with links to where t | `$ident:kind` | [macro fragment specifier] | | `$(…)…` | [macro repetition] | +## Attributes + +| Syntax | Usage | +|------------|-------| +| `#[meta]` | [outer attribute] | +| `#![meta]` | [inner attribute] | + [`'static` lifetimes]: bound [`if let` patterns]: expr.if.let [`self` paths]: paths.qualifiers.mod-self @@ -213,6 +220,7 @@ This appendix provides an index of tokens and common forms with links to where t [inferred types]: type.inferred [infinite loops]: expr.loop.infinite [inherent impls]: items.impl.inherent +[inner attribute]: attributes.inner [iterator loops]: expr.loop.for [keywords chapter]: lex.keywords [lazy-bool]: expr.bool-logic @@ -235,6 +243,7 @@ This appendix provides an index of tokens and common forms with links to where t [never type]: type.never [number literals]: lex.token.literal.num [or patterns]: patterns.or +[outer attribute]: attributes.outer [predicate loops]: expr.loop.while [qualified paths]: paths.qualified [question]: expr.try From 16c8bbc3a1a9f14324df18d2f86f759956d22b9e Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Fri, 24 Oct 2025 07:57:29 -0700 Subject: [PATCH 16/49] Add expressions, items, types, and patterns to syntax index --- src/syntax-index.md | 155 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 155 insertions(+) diff --git a/src/syntax-index.md b/src/syntax-index.md index 2bdc79b27c..967e5f239e 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -160,18 +160,128 @@ This appendix provides an index of tokens and common forms with links to where t | `#[meta]` | [outer attribute] | | `#![meta]` | [inner attribute] | +## Expressions + +| Expression | Usage | +|---------------------------|-------| +| \|…\| expr | [closures] | +| `ident::…` | [paths] | +| `::crate_name::…` | [explicit crate paths] | +| `crate::…` | [crate-relative paths] | +| `self::…` | [module-relative paths] | +| `super::…` | [parent module paths] | +| `Type::…`
`::ident` | [associated items] | +| `::…` | [qualified paths] which can be used for types without names such as `<&T>::…`, `<[T]>::…`, etc. | +| `Trait::method(…)`
`Type::method(…)`
`::method(…)` | [disambiguated method calls] | +| `Type<…>` | [generic arguments] (e.g. `Vec`) | +| `method::<…>(…)`
`path::<…>` | [generic arguments], aka turbofish | +| `Type` | [explicit associated type bounds] (e.g. `Iterator`) | +| `()` | [unit] | +| `(expr)` | [parenthesized expressions] | +| `(expr,)` | [single-element tuple expression] | +| `(expr, …)` | [tuple expressions] | +| `expr(expr, …)` | [call expressions] | +| `expr.0`, `expr.1`, … | [tuple indexing expressions] | +| `expr.ident` | [field access expressions] | +| `{…}` | [block expressions] | +| `Type{…}` | [struct expressions] | +| `Type(…)` | [tuple struct constructors] | +| `[…]` | [array expressions] | +| `[expr; len]` | [repeat array expressions] | +| `expr[..]`, `expr[a..]`, `expr[..b]`, `expr[a..b]`, `expr[a..=b]`, `expr[..=b]` | [array and slice indexing expressions] | +| `if expr {…} else {…}` | [if expressions] | +| `match expr { pattern => {…} }` | [match expressions] | +| `loop {…}` | [infinite loop expressions] | +| `while expr {…}` | [predicate loop expressions] | +| `for pattern in expr {…}` | [iterator loops] | +| `&expr`
`&mut expr` | [borrow expressions] | +| `&raw const expr`
`&raw mut expr` | [raw borrow expressions] | +| `*expr` | [dereference expressions] | +| `expr?` | [try propagation expressions] | +| `-expr` | [negation expressions] | +| `!expr` | [bitwise and logical NOT expressions] | +| `expr as Type` | [type cast expressions] | + +## Items + +[Items] are declarations in a crate. + +| Item | Usage | +|-------------------------------|-------| +| `mod ident;`
`mod ident {…}` | [modules] | +| `use path;` | [use declarations] | +| `fn ident(…) {…}` | [functions] | +| `type Type = Type` | [type aliases] | +| `struct ident {…}` | [structs] | +| `enum ident {…}` | [enumerations] | +| `union ident {…}` | [unions] | +| `trait ident {…}` | [traits] | +| `impl Type {…}`
`impl Type for Trait {…}` | [implementations] | +| `const ident = expr` | [constant items] | +| `static ident = expr` | [static items] | +| `extern "C" {…}` | [external blocks] | +| `fn ident<…>(…) …`
`struct ident<…> {…}`
`enum ident<…> {…}`
`impl<…> Type<…> {…}` | [generic definitions] | + +## Type expressions + +[Type expressions] are used to refer to types. + +| Type | Usage | +|---------------------------------------|-------| +| `bool`, `u8`, `f64`, `char`, `str` | [primitive types] | +| `for<…>` | [higher-ranked trait bounds] | +| `T: U` | [trait bounds] | +| `T: 'a` | [lifetime bounds] | +| `T: ?Sized` | [relaxed trait bounds] | +| `'a + Trait`
`Trait + Trait` | [compound type bounds] | +| `[Type; len]` | [array types] | +| `(Type, …)` | [tuple types] | +| `[Type, …]` | [slice types] | +| `(Type)` | [parenthesized types] | +| `impl Trait` | [impl trait types] | +| `dyn Trait` | [trait object types] | +| `ident`
`ident::…` | [type paths] (can refer to structs, enums, unions, aliases, traits, generics, etc.) | +| `&Type`
`&mut Type` | [reference types] | +| `*mut Type`
`*const Type` | [raw pointer types] | +| `fn(…) -> Type` | [function pointer types] | +| `_` | [inferred type] | +| `!` | [never type] | + +## Patterns + +[Patterns] are used to match values. + +| Pattern | Usage | +|-----------------------------------|-------| +| `"foo"`, `'a'`, `123`, `2.4`, … | [literal patterns] | +| `ident` | [identifier patterns] | +| `_` | [wildcard patterns] | +| `..` | [rest patterns] | +| `&pattern`
`&mut pattern` | [reference patterns] | +| `path{…}` | [struct patterns] | +| `path(…)` | [tuple struct patterns] | +| `(pattern, …)` | [tuple patterns] | +| `(pattern)` | [grouped patterns] | +| `[pattern, …]` | [slice patterns] | +| `CONST`, `Enum::Variant`, … | [path patterns] | + [`'static` lifetimes]: bound [`if let` patterns]: expr.if.let [`self` paths]: paths.qualifiers.mod-self [`Self` type paths]: paths.qualifiers.type-self [arith]: expr.arith-logic +[array and slice indexing expressions]: expr.array.index +[array expressions]: expr.array [array types]: type.array [assembly operands]: asm.operand-type.supported-operands.in [assignment]: expr.assign +[associated items]: items.associated [async blocks]: expr.block.async [async closures]: expr.closure.async [async functions]: items.fn.async [await expressions]: expr.await +[bitwise and logical NOT expressions]: expr.negate +[block expressions]: expr.block [boolean expressions]: expr.literal [boolean type]: type.bool [borrow expressions]: expr.operator.borrow @@ -180,10 +290,12 @@ This appendix provides an index of tokens and common forms with links to where t [byte literals]: lex.token.byte [byte string literals]: lex.token.str-byte [C string literals]: lex.token.str-c +[call expressions]: expr.call [character literals]: lex.token.literal.char [closure expressions]: expr.closure [closures]: expr.closure [comparison]: expr.cmp +[compound type bounds]: bound [compound]: expr.compound-assign [configuration predicates]: cfg [const assembly operands]: asm.operand-type.supported-operands.const @@ -191,11 +303,17 @@ This appendix provides an index of tokens and common forms with links to where t [const functions]: const-eval.const-fn [const generics]: items.generics.const [const items]: items.const +[constant items]: items.const [constants]: items.const [continue expressions]: expr.loop.continue +[crate-relative paths]: paths.qualifiers.crate +[dereference expressions]: expr.deref [dereference]: expr.deref [destructuring assignment]: expr.placeholder +[disambiguated method calls]: expr.call.desugar [enumerations]: items.enum +[explicit associated type bounds]: paths.expr +[explicit crate paths]: paths.qualifiers.global-root [extern crate alias]: items.extern-crate.as [extern crate]: items.extern-crate [extern crates]: items.extern-crate @@ -205,19 +323,27 @@ This appendix provides an index of tokens and common forms with links to where t [external block functions]: items.extern.fn [external block statics]: items.extern.static [external blocks]: items.extern +[field access expressions]: expr.field [field]: expr.field [function pointer type]: type.fn-pointer [function pointer types]: type.fn-pointer [functions]: items.fn +[generic arguments]: items.generics +[generic definitions]: items.generics [generics]: items.generics [glob imports]: items.use.glob +[grouped patterns]: patterns.paren [higher-ranked trait bounds]: bound.higher-ranked [identifier patterns]: patterns.ident [identifiers]: ident [if expressions]: expr.if [if let]: expr.if.let +[impl trait types]: type.impl-trait [impl traits]: type.impl-trait +[implementations]: items.impl +[inferred type]: type.inferred [inferred types]: type.inferred +[infinite loop expressions]: expr.loop.infinite [infinite loops]: expr.loop.infinite [inherent impls]: items.impl.inherent [inner attribute]: attributes.inner @@ -225,7 +351,9 @@ This appendix provides an index of tokens and common forms with links to where t [keywords chapter]: lex.keywords [lazy-bool]: expr.bool-logic [let statements]: statement.let +[lifetime bounds]: bound.lifetime [lifetimes and loop labels]: lex.token.life +[literal patterns]: patterns.literal [macro calls]: macro.invocation [macro fragment specifier]: macro.decl.meta.specifier [macro fragment substitution]: macro.decl.meta.transcription @@ -237,18 +365,27 @@ This appendix provides an index of tokens and common forms with links to where t [match expressions]: expr.match [match guards]: expr.match.guard [match]: expr.match +[module-relative paths]: paths.qualifiers.mod-self [modules]: items.mod +[negation expressions]: expr.negate [negation]: expr.negate [negative impls]: items.impl [never type]: type.never [number literals]: lex.token.literal.num [or patterns]: patterns.or [outer attribute]: attributes.outer +[parent module paths]: paths.qualifiers.super +[parenthesized expressions]: expr.paren +[parenthesized types]: type.name.parenthesized +[path patterns]: patterns.path +[predicate loop expressions]: expr.loop.while [predicate loops]: expr.loop.while +[primitive types]: type.kinds [qualified paths]: paths.qualified [question]: expr.try [range patterns]: patterns.range [raw assembly]: asm.options.supported-options.raw +[raw borrow expressions]: expr.borrow.raw [raw borrow operator]: expr.borrow.raw [raw byte string literals]: lex.token.str-byte-raw [raw C string literals]: lex.token.str-c-raw @@ -261,11 +398,16 @@ This appendix provides an index of tokens and common forms with links to where t [reference patterns]: patterns.ref [reference types]: type.pointer.reference [references]: type.pointer.reference +[relaxed trait bounds]: bound.sized +[repeat array expressions]: expr.array [reserved keyword]: lex.keywords.reserved [rest patterns]: patterns.rest [return expressions]: expr.return [self parameters]: items.fn.params.self-pat +[single-element tuple expression]: expr.tuple [sized]: bound.sized +[slice patterns]: patterns.slice +[slice types]: type.slice [static items]: items.static [string literals]: lex.token.literal.str [struct expressions]: expr.struct @@ -277,11 +419,24 @@ This appendix provides an index of tokens and common forms with links to where t [trait implementations]: items.impl.trait [trait impls]: items.impl.trait [trait items]: items.traits +[trait object types]: type.trait-object [trait objects]: type.trait-object +[traits]: items.traits +[try propagation expressions]: expr.try +[tuple expressions]: expr.tuple [tuple index]: expr.tuple-index +[tuple indexing expressions]: expr.tuple-index +[tuple patterns]: patterns.tuple +[tuple struct constructors]: items.struct.tuple +[tuple struct patterns]: patterns.tuple-struct +[tuple types]: type.tuple [type aliases]: items.type [type cast expressions]: expr.as +[Type expressions]: type.name +[type paths]: type.name.path [union items]: items.union +[unions]: items.union +[unit]: type.tuple.unit [unsafe attributes]: attributes.safety [unsafe external blocks]: unsafe.extern [unsafe external functions]: items.extern.fn.safety From 34ccba18e2b3dfc8234da2ec47b26cbea35d7474 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Sat, 25 Oct 2025 04:24:34 +0000 Subject: [PATCH 17/49] Singularize "wildcard pattern", "inferred type" "The inferred type" and "the wildcard pattern" are singular things. Let's not pluralize these. --- src/syntax-index.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index 967e5f239e..9afb956c61 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -6,7 +6,7 @@ This appendix provides an index of tokens and common forms with links to where t | Keyword | Usage | |---------------|-------| -| `_` | [wildcard patterns], [inferred types], unnamed items in [constants], [extern crates], [use declarations], [destructuring assignment] | +| `_` | [wildcard pattern], [inferred type], unnamed items in [constants], [extern crates], [use declarations], [destructuring assignment] | | `abstract` | [reserved keyword] | | `as` | [extern crate alias], [use alias], [type cast expressions], [qualified paths] | | `async` | [async functions], [async blocks], [async closures] | @@ -255,7 +255,7 @@ This appendix provides an index of tokens and common forms with links to where t |-----------------------------------|-------| | `"foo"`, `'a'`, `123`, `2.4`, … | [literal patterns] | | `ident` | [identifier patterns] | -| `_` | [wildcard patterns] | +| `_` | [wildcard pattern] | | `..` | [rest patterns] | | `&pattern`
`&mut pattern` | [reference patterns] | | `path{…}` | [struct patterns] | @@ -342,7 +342,6 @@ This appendix provides an index of tokens and common forms with links to where t [impl traits]: type.impl-trait [implementations]: items.impl [inferred type]: type.inferred -[inferred types]: type.inferred [infinite loop expressions]: expr.loop.infinite [infinite loops]: expr.loop.infinite [inherent impls]: items.impl.inherent @@ -454,4 +453,4 @@ This appendix provides an index of tokens and common forms with links to where t [visibility]: vis [where clauses]: items.generics.where [while let]: expr.loop.while.let -[wildcard patterns]: patterns.wildcard +[wildcard pattern]: patterns.wildcard From addbb94dd0d4b98fd6767498766a334e58ac124c Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Sat, 25 Oct 2025 00:17:36 +0000 Subject: [PATCH 18/49] Add inferred const to keyword index We have now not just the inferred type but also the inferred const, so let's include that in the syntax index. --- src/syntax-index.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index 9afb956c61..14ee3a4c11 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -6,7 +6,7 @@ This appendix provides an index of tokens and common forms with links to where t | Keyword | Usage | |---------------|-------| -| `_` | [wildcard pattern], [inferred type], unnamed items in [constants], [extern crates], [use declarations], [destructuring assignment] | +| `_` | [wildcard pattern], [inferred const], [inferred type], unnamed items in [constants], [extern crates], [use declarations], [destructuring assignment] | | `abstract` | [reserved keyword] | | `as` | [extern crate alias], [use alias], [type cast expressions], [qualified paths] | | `async` | [async functions], [async blocks], [async closures] | @@ -244,7 +244,7 @@ This appendix provides an index of tokens and common forms with links to where t | `&Type`
`&mut Type` | [reference types] | | `*mut Type`
`*const Type` | [raw pointer types] | | `fn(…) -> Type` | [function pointer types] | -| `_` | [inferred type] | +| `_` | [inferred type], [inferred const] | | `!` | [never type] | ## Patterns @@ -341,6 +341,7 @@ This appendix provides an index of tokens and common forms with links to where t [impl trait types]: type.impl-trait [impl traits]: type.impl-trait [implementations]: items.impl +[inferred const]: items.generics.const.inferred [inferred type]: type.inferred [infinite loop expressions]: expr.loop.infinite [infinite loops]: expr.loop.infinite From 69c18db703145e3805773a6aac6e7899f1214938 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Sat, 25 Oct 2025 04:29:24 +0000 Subject: [PATCH 19/49] Add placeholder lifetime to syntax index The placeholder lifetime is the lifetime equivalent of the inferred const and the inferred type (and, in fact, we should probably rename it to the inferred lifetime). Let's mention it alongside these similar things in the syntax index. We could ask whether it should really appear in the "type expressions" section. After all, it's not exactly a type expression. However, neither is `for<...>`, but that appears in this section. We can justify both by observing that they may appear within `impl Trait` and `dyn Trait` -- and these are type expressions. --- src/syntax-index.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index 14ee3a4c11..7199ec56bc 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -6,7 +6,7 @@ This appendix provides an index of tokens and common forms with links to where t | Keyword | Usage | |---------------|-------| -| `_` | [wildcard pattern], [inferred const], [inferred type], unnamed items in [constants], [extern crates], [use declarations], [destructuring assignment] | +| `_` | [wildcard pattern], [inferred const], [inferred type], [placeholder lifetime], unnamed items in [constants], [extern crates], [use declarations], [destructuring assignment] | | `abstract` | [reserved keyword] | | `as` | [extern crate alias], [use alias], [type cast expressions], [qualified paths] | | `async` | [async functions], [async blocks], [async closures] | @@ -245,6 +245,7 @@ This appendix provides an index of tokens and common forms with links to where t | `*mut Type`
`*const Type` | [raw pointer types] | | `fn(…) -> Type` | [function pointer types] | | `_` | [inferred type], [inferred const] | +| `'_` | [placeholder lifetime] | | `!` | [never type] | ## Patterns @@ -378,6 +379,7 @@ This appendix provides an index of tokens and common forms with links to where t [parenthesized expressions]: expr.paren [parenthesized types]: type.name.parenthesized [path patterns]: patterns.path +[placeholder lifetime]: lifetime-elision.function.explicit-placeholder [predicate loop expressions]: expr.loop.while [predicate loops]: expr.loop.while [primitive types]: type.kinds From 29a0852692b756f7954e3281cca9268d7d41095b Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Sun, 26 Oct 2025 01:53:06 +0000 Subject: [PATCH 20/49] Add range patterns to patterns section of index In the patterns section of the syntax index, we had listed other kinds of patterns, and we had listed `..` for rest patterns, but we hadn't noted its use for range patterns or listed `..=`. Let's do that. --- src/syntax-index.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/syntax-index.md b/src/syntax-index.md index 7199ec56bc..97c72e65b6 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -258,6 +258,7 @@ This appendix provides an index of tokens and common forms with links to where t | `ident` | [identifier patterns] | | `_` | [wildcard pattern] | | `..` | [rest patterns] | +| `a..`, `..b`, `a..b`, `a..=b`, `..=b` | [range patterns] | | `&pattern`
`&mut pattern` | [reference patterns] | | `path{…}` | [struct patterns] | | `path(…)` | [tuple struct patterns] | From 4ae18da7927e37f2f8db7fc556c9fad90a5cbdee Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Mon, 27 Oct 2025 16:58:48 +0000 Subject: [PATCH 21/49] Clarify role of `_` with constants The text referred to `_` as applying to "unnamed items in constants", but this doesn't really speak to me. Let's say instead, "unnamed constant items". --- src/syntax-index.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index 97c72e65b6..ae16f79ed2 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -6,7 +6,7 @@ This appendix provides an index of tokens and common forms with links to where t | Keyword | Usage | |---------------|-------| -| `_` | [wildcard pattern], [inferred const], [inferred type], [placeholder lifetime], unnamed items in [constants], [extern crates], [use declarations], [destructuring assignment] | +| `_` | [wildcard pattern], [inferred const], [inferred type], [placeholder lifetime], unnamed [constant items], [extern crates], [use declarations], [destructuring assignment] | | `abstract` | [reserved keyword] | | `as` | [extern crate alias], [use alias], [type cast expressions], [qualified paths] | | `async` | [async functions], [async blocks], [async closures] | @@ -306,7 +306,6 @@ This appendix provides an index of tokens and common forms with links to where t [const generics]: items.generics.const [const items]: items.const [constant items]: items.const -[constants]: items.const [continue expressions]: expr.loop.continue [crate-relative paths]: paths.qualifiers.crate [dereference expressions]: expr.deref From c1c626f1ac52c08ff9f442914588cec51209a2c9 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Mon, 27 Oct 2025 17:12:42 +0000 Subject: [PATCH 22/49] Avoid overloading "alias" We had described `as` as applying to an "extern crate alias" or "use alias". While I gather the meaning, and we do use this term in some code examples, I'm not sure in the index we'd necessarily want to treat these as canonical names. The term "use alias" seems particularly tenuous; I'd probably at least say, e.g. "use declaration alias" or "use item alias" or similar. Other items in the list often just refer to the top-level feature; let's do that here. We'll keep (and inline) the link to the specific section. --- src/syntax-index.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index ae16f79ed2..54e255b3cc 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -8,7 +8,7 @@ This appendix provides an index of tokens and common forms with links to where t |---------------|-------| | `_` | [wildcard pattern], [inferred const], [inferred type], [placeholder lifetime], unnamed [constant items], [extern crates], [use declarations], [destructuring assignment] | | `abstract` | [reserved keyword] | -| `as` | [extern crate alias], [use alias], [type cast expressions], [qualified paths] | +| `as` | [extern crate][items.extern-crate.as], [use declarations][items.use.forms.as], [type cast expressions], [qualified paths] | | `async` | [async functions], [async blocks], [async closures] | | `await` | [await expressions] | | `become` | [reserved keyword] | @@ -315,7 +315,6 @@ This appendix provides an index of tokens and common forms with links to where t [enumerations]: items.enum [explicit associated type bounds]: paths.expr [explicit crate paths]: paths.qualifiers.global-root -[extern crate alias]: items.extern-crate.as [extern crate]: items.extern-crate [extern crates]: items.extern-crate [extern function pointer types]: type.fn-pointer.qualifiers @@ -448,7 +447,6 @@ This appendix provides an index of tokens and common forms with links to where t [unsafe static items]: items.static.mut.safety [unsafe trait implementations]: items.impl.trait.safety [unsafe traits]: items.traits.safety -[use alias]: items.use.forms.as [use bounds]: bound.use [use declarations]: items.use [use items]: items.use From 8f8eedb0bd76daf7ef97c361ee1f93f6922cc492 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Mon, 27 Oct 2025 18:16:46 +0000 Subject: [PATCH 23/49] Singularize "extern crate" While we do prefer to use the plural, the plural for "extern crate" would be "extern crate declarations". In lieu of that, let's just say "extern crate" as that's reminiscent of the syntax. --- src/syntax-index.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index 54e255b3cc..9466defed3 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -6,7 +6,7 @@ This appendix provides an index of tokens and common forms with links to where t | Keyword | Usage | |---------------|-------| -| `_` | [wildcard pattern], [inferred const], [inferred type], [placeholder lifetime], unnamed [constant items], [extern crates], [use declarations], [destructuring assignment] | +| `_` | [wildcard pattern], [inferred const], [inferred type], [placeholder lifetime], unnamed [constant items], [extern crate], [use declarations], [destructuring assignment] | | `abstract` | [reserved keyword] | | `as` | [extern crate][items.extern-crate.as], [use declarations][items.use.forms.as], [type cast expressions], [qualified paths] | | `async` | [async functions], [async blocks], [async closures] | @@ -16,7 +16,7 @@ This appendix provides an index of tokens and common forms with links to where t | `break` | [break expressions] | | `const` | [const functions], [const items], [const generics], [const blocks], [raw borrow operator], [raw pointer type], [const assembly operands] | | `continue` | [continue expressions] | -| `crate` | [extern crates], [visibility], [paths] | +| `crate` | [extern crate], [visibility], [paths] | | `do` | [reserved keyword] | | `dyn` | [trait objects] | | `else` | [let statements], [if expressions] | @@ -45,7 +45,7 @@ This appendix provides an index of tokens and common forms with links to where t | `ref` | [identifier patterns], [struct patterns] | | `return` | [return expressions] | | `safe` | [external block functions], [external block statics] | -| `self` | [extern crates][items.extern-crate.self], [self parameters], [visibility], [`self` paths] | +| `self` | [extern crate][items.extern-crate.self], [self parameters], [visibility], [`self` paths] | | `Self` | [`Self` type paths], [use bounds] | | `static` | [static items], [`'static` lifetimes] | | `struct` | [structs] | @@ -316,7 +316,6 @@ This appendix provides an index of tokens and common forms with links to where t [explicit associated type bounds]: paths.expr [explicit crate paths]: paths.qualifiers.global-root [extern crate]: items.extern-crate -[extern crates]: items.extern-crate [extern function pointer types]: type.fn-pointer.qualifiers [extern function qualifier]: items.fn.extern [extern]: items.extern From 6d88476812ff798e13d9f7ec02b0dd4298731138 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Mon, 27 Oct 2025 18:23:45 +0000 Subject: [PATCH 24/49] Say "impl trait types" The plural of "impl trait" is "impl trait types", so let's say that instead of "impl traits". We had already used this elsewhere. --- src/syntax-index.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index 9466defed3..7f9c80433a 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -28,7 +28,7 @@ This appendix provides an index of tokens and common forms with links to where t | `for` | [trait implementations], [iterator loops], [higher-ranked trait bounds] | | `gen` | [reserved keyword] | | `if` | [if expressions], [match guards] | -| `impl` | [inherent impls], [trait impls], [impl traits] | +| `impl` | [inherent impls], [trait impls], [impl trait types] | | `in` | [visibility], [iterator loops], [assembly operands] | | `let` | [let statements], [`if let` patterns] | | `loop` | [infinite loops] | @@ -338,7 +338,6 @@ This appendix provides an index of tokens and common forms with links to where t [if expressions]: expr.if [if let]: expr.if.let [impl trait types]: type.impl-trait -[impl traits]: type.impl-trait [implementations]: items.impl [inferred const]: items.generics.const.inferred [inferred type]: type.inferred From e79b6deaebab796233b763c179e314f960e7e9da Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Mon, 27 Oct 2025 18:29:47 +0000 Subject: [PATCH 25/49] Separate RPIT and APIT in the index Strictly speaking, use of `impl Trait` in APIT is not an "impl trait type". Let's point "impl trait type" at the entry for RPIT and add a separate item to the index for "anonymous type parameters". --- src/syntax-index.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index 7f9c80433a..f77e097dfb 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -28,7 +28,7 @@ This appendix provides an index of tokens and common forms with links to where t | `for` | [trait implementations], [iterator loops], [higher-ranked trait bounds] | | `gen` | [reserved keyword] | | `if` | [if expressions], [match guards] | -| `impl` | [inherent impls], [trait impls], [impl trait types] | +| `impl` | [inherent impls], [trait impls], [impl trait types], [anonymous type parameters] | | `in` | [visibility], [iterator loops], [assembly operands] | | `let` | [let statements], [`if let` patterns] | | `loop` | [infinite loops] | @@ -238,7 +238,7 @@ This appendix provides an index of tokens and common forms with links to where t | `(Type, …)` | [tuple types] | | `[Type, …]` | [slice types] | | `(Type)` | [parenthesized types] | -| `impl Trait` | [impl trait types] | +| `impl Trait` | [impl trait types], [anonymous type parameters] | | `dyn Trait` | [trait object types] | | `ident`
`ident::…` | [type paths] (can refer to structs, enums, unions, aliases, traits, generics, etc.) | | `&Type`
`&mut Type` | [reference types] | @@ -271,6 +271,7 @@ This appendix provides an index of tokens and common forms with links to where t [`if let` patterns]: expr.if.let [`self` paths]: paths.qualifiers.mod-self [`Self` type paths]: paths.qualifiers.type-self +[anonymous type parameters]: type.impl-trait.param [arith]: expr.arith-logic [array and slice indexing expressions]: expr.array.index [array expressions]: expr.array @@ -337,7 +338,7 @@ This appendix provides an index of tokens and common forms with links to where t [identifiers]: ident [if expressions]: expr.if [if let]: expr.if.let -[impl trait types]: type.impl-trait +[impl trait types]: type.impl-trait.return [implementations]: items.impl [inferred const]: items.generics.const.inferred [inferred type]: type.inferred From f2fc21267fa960ce4ed0d65493edf98518759b6f Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Mon, 27 Oct 2025 21:41:16 +0000 Subject: [PATCH 26/49] Remove "unsafe static items" from syntax index For the `unsafe` keyword, we had noted that it applied to "unsafe static items" and linked to the section that describes how mutable static items must be accessed within an `unsafe` block. Probably this link doesn't make sense. The requirement that an `unsafe` block be used to access mutable statics is just one of the places where an `unsafe` block is required. Conversely, if we mean for this to refer to the syntactic fact that static items can be modified with the `unsafe` keyword, then we'd want to note this as well for the `safe` keyword. However, semantically, we only support these modifiers on external statics, and we already list those separately. So let's just remove "unsafe static items" from the list. --- src/syntax-index.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index f77e097dfb..f0708b7db0 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -56,7 +56,7 @@ This appendix provides an index of tokens and common forms with links to where t | `type` | [type aliases] | | `typeof` | [reserved keyword] | | `union` | [union items] | -| `unsafe` | [unsafe attributes], [unsafe modules], [unsafe functions], [unsafe static items], [unsafe external blocks], [unsafe external functions], [unsafe external statics], [unsafe traits], [unsafe trait implementations] | +| `unsafe` | [unsafe attributes], [unsafe modules], [unsafe functions], [unsafe external blocks], [unsafe external functions], [unsafe external statics], [unsafe traits], [unsafe trait implementations] | | `unsized` | [reserved keyword] | | `use` | [use items], [use bounds] | | `virtual` | [reserved keyword] | @@ -443,7 +443,6 @@ This appendix provides an index of tokens and common forms with links to where t [unsafe external statics]: items.extern.static.safety [unsafe functions]: unsafe.fn [unsafe modules]: items.mod.unsafe -[unsafe static items]: items.static.mut.safety [unsafe trait implementations]: items.impl.trait.safety [unsafe traits]: items.traits.safety [use bounds]: bound.use From 59b8fa74f906f9282538b52aabd5b91eb225ce9e Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Mon, 27 Oct 2025 21:52:02 +0000 Subject: [PATCH 27/49] Add "unsafe blocks" to syntax index We had listed many other things as being related to `unsafe`, but not unsafe blocks, so let's list those. --- src/syntax-index.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index f0708b7db0..6acb188999 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -56,7 +56,7 @@ This appendix provides an index of tokens and common forms with links to where t | `type` | [type aliases] | | `typeof` | [reserved keyword] | | `union` | [union items] | -| `unsafe` | [unsafe attributes], [unsafe modules], [unsafe functions], [unsafe external blocks], [unsafe external functions], [unsafe external statics], [unsafe traits], [unsafe trait implementations] | +| `unsafe` | [unsafe blocks], [unsafe attributes], [unsafe modules], [unsafe functions], [unsafe external blocks], [unsafe external functions], [unsafe external statics], [unsafe traits], [unsafe trait implementations] | | `unsized` | [reserved keyword] | | `use` | [use items], [use bounds] | | `virtual` | [reserved keyword] | @@ -438,6 +438,7 @@ This appendix provides an index of tokens and common forms with links to where t [unions]: items.union [unit]: type.tuple.unit [unsafe attributes]: attributes.safety +[unsafe blocks]: expr.block.unsafe [unsafe external blocks]: unsafe.extern [unsafe external functions]: items.extern.fn.safety [unsafe external statics]: items.extern.static.safety From 11133a94b4a4f050510f6331e682f85bc188c715 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Mon, 27 Oct 2025 22:01:59 +0000 Subject: [PATCH 28/49] Add "array expressions" for semicolon in index For the semicolon, we had listed "array types", but we had not listed "array expressions" even though the semicolon is used for those as well. Let's add that. --- src/syntax-index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index 6acb188999..a980134b98 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -104,7 +104,7 @@ This appendix provides an index of tokens and common forms with links to where t | `...` | DotDotDot | [variadic functions], [range patterns] | | `..=` | DotDotEq | [inclusive range expressions][expr.range], [range patterns] | | `,` | Comma | various separators | -| `;` | Semi | terminator for various items and statements, [array types] | +| `;` | Semi | terminator for various items and statements, [array expressions], [array types] | | `:` | Colon | various separators | | `::` | PathSep | [path separator][paths] | | `->` | RArrow | [function return type][functions], [closure return type][closures], [function pointer type] | From c70d6021151f9a8a2a6224c6989e2b71bb4045f8 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Mon, 27 Oct 2025 22:06:52 +0000 Subject: [PATCH 29/49] Clarify about `->` and types For `->`, we had listed "function return type" and "closure return type". For me, I read this table as "the thing on the left is used in the thing on the right". But that's not really true here; the `->` is not used *in* the function or closure return type. It's probably better just to say that `->` is used in functions and closures, so let's do that. --- src/syntax-index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index a980134b98..569e04c896 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -107,7 +107,7 @@ This appendix provides an index of tokens and common forms with links to where t | `;` | Semi | terminator for various items and statements, [array expressions], [array types] | | `:` | Colon | various separators | | `::` | PathSep | [path separator][paths] | -| `->` | RArrow | [function return type][functions], [closure return type][closures], [function pointer type] | +| `->` | RArrow | [functions], [closures], [function pointer type] | | `=>` | FatArrow | [match arms][match], [macros] | | `<-` | LArrow | The left arrow symbol has been unused since before Rust 1.0, but it is still treated as a single token. | | `#` | Pound | [attributes] | From 02c7d4775a221eff2d925eebf9b595dd8a4a090b Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Mon, 27 Oct 2025 22:13:56 +0000 Subject: [PATCH 30/49] List raw string literals for `#` in index For `#`, we had noted that it was used in attributes, but it's also used in raw string literals, raw byte string literals, and raw C string literals, so let's list those as well. --- src/syntax-index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index 569e04c896..34e4c78cd5 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -110,7 +110,7 @@ This appendix provides an index of tokens and common forms with links to where t | `->` | RArrow | [functions], [closures], [function pointer type] | | `=>` | FatArrow | [match arms][match], [macros] | | `<-` | LArrow | The left arrow symbol has been unused since before Rust 1.0, but it is still treated as a single token. | -| `#` | Pound | [attributes] | +| `#` | Pound | [attributes], [raw string literals], [raw byte string literals], [raw C string literals] | | `$` | Dollar | [macros] | | `?` | Question | [try propagation expressions][question], [questionably sized][sized], [macro Kleene matcher] | | `~` | Tilde | The tilde operator has been unused since before Rust 1.0, but its token may still be used. | From 86fd49cd976f53015f6c2795dae4cdfa358c257e Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Mon, 27 Oct 2025 22:17:43 +0000 Subject: [PATCH 31/49] Refer to relaxed trait bounds for `?` For `?`, in this branch, we had listed "questionably sized" in the syntax index. I'm not a fan of this terminology. As I wrote elsewhere, in Rust PR 145924: > I don't think we should use the word "maybe" to refer to "?X" bound > relaxations. Either there's a predicate stating that a type > parameter implements some trait or there isn't. While of course I > get it -- the type argument provided may or may not implement the > trait -- I just think "maybe" is speaking to the wrong thing here. > It focuses on the type argument when what makes more sense to focus > on is the type parameter. And the type parameter is not in a > "maybe" state. In this regard, I feel the same about "questionably" as I do "maybe". We don't use this terminology elsewhere in the Reference, so let's not use it here. Let's instead refer simply to "relaxed trait bounds", as we do elsewhere in the syntax index. --- src/syntax-index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index 34e4c78cd5..1d2b61f966 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -112,7 +112,7 @@ This appendix provides an index of tokens and common forms with links to where t | `<-` | LArrow | The left arrow symbol has been unused since before Rust 1.0, but it is still treated as a single token. | | `#` | Pound | [attributes], [raw string literals], [raw byte string literals], [raw C string literals] | | `$` | Dollar | [macros] | -| `?` | Question | [try propagation expressions][question], [questionably sized][sized], [macro Kleene matcher] | +| `?` | Question | [try propagation expressions][question], [relaxed trait bounds], [macro Kleene matcher] | | `~` | Tilde | The tilde operator has been unused since before Rust 1.0, but its token may still be used. | ## Comments From a31a5d07c886153ef3623d250e493294cd8dce2e Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Mon, 27 Oct 2025 22:33:50 +0000 Subject: [PATCH 32/49] Call `$ident:kind` a macro matcher fragment specifier In writing RFC 3531, I came to believe that the most correct fully qualified term for what `kind` is in `$ident:kind` is a "macro matcher fragment specifier", and I still think that's right. It's unfortunate that it's such a mouthful, but let's use that term in the syntax index. --- src/syntax-index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index 1d2b61f966..f106b41299 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -150,7 +150,7 @@ This appendix provides an index of tokens and common forms with links to where t |-------------------------------------------|-------| | `ident!(…)`
`ident!{…}`
`ident![…]` | [macro invocations] | | `$ident` | [macro fragment substitution] | -| `$ident:kind` | [macro fragment specifier] | +| `$ident:kind` | [macro matcher fragment specifier] | | `$(…)…` | [macro repetition] | ## Attributes @@ -354,10 +354,10 @@ This appendix provides an index of tokens and common forms with links to where t [lifetimes and loop labels]: lex.token.life [literal patterns]: patterns.literal [macro calls]: macro.invocation -[macro fragment specifier]: macro.decl.meta.specifier [macro fragment substitution]: macro.decl.meta.transcription [macro invocations]: macro.invocation [macro Kleene matcher]: macro.decl.repetition +[macro matcher fragment specifier]: macro.decl.meta.specifier [macro repetition]: macro.decl.repetition [macros by example]: macro.decl [macros]: macro.decl From 2a62276a1e0368a287803b2badd67dc952fa1675 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Mon, 27 Oct 2025 22:42:02 +0000 Subject: [PATCH 33/49] Call `$ident` a "macro metavariable" in the index On the branch, in the syntax index, we had called `$ident` a "macro fragment substitution". The way that I think about it is that `$ident` is a macro metavariable that is bound to a fragment. That is, the metavariable is the parameter while the fragment is the argument. That's why a "macro matcher fragment specifier" makes sense -- we're specifying the kind of the fragment that can be bound to this macro metavariable in the matcher. In this light, let's call `$ident` simply a "macro metavariable" in the syntax index. --- src/syntax-index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index f106b41299..d3d036d4e9 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -149,7 +149,7 @@ This appendix provides an index of tokens and common forms with links to where t | Syntax | Usage | |-------------------------------------------|-------| | `ident!(…)`
`ident!{…}`
`ident![…]` | [macro invocations] | -| `$ident` | [macro fragment substitution] | +| `$ident` | [macro metavariable] | | `$ident:kind` | [macro matcher fragment specifier] | | `$(…)…` | [macro repetition] | @@ -354,10 +354,10 @@ This appendix provides an index of tokens and common forms with links to where t [lifetimes and loop labels]: lex.token.life [literal patterns]: patterns.literal [macro calls]: macro.invocation -[macro fragment substitution]: macro.decl.meta.transcription [macro invocations]: macro.invocation [macro Kleene matcher]: macro.decl.repetition [macro matcher fragment specifier]: macro.decl.meta.specifier +[macro metavariable]: macro.decl.meta [macro repetition]: macro.decl.repetition [macros by example]: macro.decl [macros]: macro.decl From 7ae6d27670c3085aeb4042d29b196ec5e4ae75b0 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Mon, 27 Oct 2025 22:54:09 +0000 Subject: [PATCH 34/49] Add `|..| -> Type { .. }` syntax for closures to index In closures without an ascribed return type, an expression follows the vertical bars. In closures with an ascribed return type, a block follows. Let's add this second syntax to the syntax index. --- src/syntax-index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index d3d036d4e9..f7dfd86f83 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -164,7 +164,7 @@ This appendix provides an index of tokens and common forms with links to where t | Expression | Usage | |---------------------------|-------| -| \|…\| expr | [closures] | +| \|…\| expr
\|…\| -> Type { … } | [closures] | | `ident::…` | [paths] | | `::crate_name::…` | [explicit crate paths] | | `crate::…` | [crate-relative paths] | From 256eb2fa48788f55943f2ca25d34c55e6ac79d9c Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Mon, 27 Oct 2025 23:00:22 +0000 Subject: [PATCH 35/49] Fix `Type as Trait` capitalization Elsewhere in this table, we spell `Type` and `Trait` in uppercase, so let's do that here as well. --- src/syntax-index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index f7dfd86f83..ff4f875152 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -170,7 +170,7 @@ This appendix provides an index of tokens and common forms with links to where t | `crate::…` | [crate-relative paths] | | `self::…` | [module-relative paths] | | `super::…` | [parent module paths] | -| `Type::…`
`::ident` | [associated items] | +| `Type::…`
`::ident` | [associated items] | | `::…` | [qualified paths] which can be used for types without names such as `<&T>::…`, `<[T]>::…`, etc. | | `Trait::method(…)`
`Type::method(…)`
`::method(…)` | [disambiguated method calls] | | `Type<…>` | [generic arguments] (e.g. `Vec`) | From e32a1a8420207d2c657e9a2fc231eaa1155b9742 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Mon, 27 Oct 2025 23:26:32 +0000 Subject: [PATCH 36/49] Clarify ATBs in syntax index On the branch, we had an entry in the expressions table for `Type`. This was notated as "explicit associated type bounds" and referenced a TODO item about default type parameters not being documented. Perhaps what this means to describe are associated type bindings and associated type bounds. Let's document those in the type expressions table. We'll remove the TODO note, as it's not relevant to this. --- src/syntax-index.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index ff4f875152..d3c442e37f 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -175,7 +175,6 @@ This appendix provides an index of tokens and common forms with links to where t | `Trait::method(…)`
`Type::method(…)`
`::method(…)` | [disambiguated method calls] | | `Type<…>` | [generic arguments] (e.g. `Vec`) | | `method::<…>(…)`
`path::<…>` | [generic arguments], aka turbofish | -| `Type` | [explicit associated type bounds] (e.g. `Iterator`) | | `()` | [unit] | | `(expr)` | [parenthesized expressions] | | `(expr,)` | [single-element tuple expression] | @@ -241,6 +240,8 @@ This appendix provides an index of tokens and common forms with links to where t | `impl Trait` | [impl trait types], [anonymous type parameters] | | `dyn Trait` | [trait object types] | | `ident`
`ident::…` | [type paths] (can refer to structs, enums, unions, aliases, traits, generics, etc.) | +| `Trait` | [associated type bindings] (e.g. `Iterator`) | +| `Trait` | [associated type bounds] (e.g. `Iterator`) | | `&Type`
`&mut Type` | [reference types] | | `*mut Type`
`*const Type` | [raw pointer types] | | `fn(…) -> Type` | [function pointer types] | @@ -279,6 +280,8 @@ This appendix provides an index of tokens and common forms with links to where t [assembly operands]: asm.operand-type.supported-operands.in [assignment]: expr.assign [associated items]: items.associated +[associated type bindings]: paths.expr +[associated type bounds]: paths.expr [async blocks]: expr.block.async [async closures]: expr.closure.async [async functions]: items.fn.async @@ -314,7 +317,6 @@ This appendix provides an index of tokens and common forms with links to where t [destructuring assignment]: expr.placeholder [disambiguated method calls]: expr.call.desugar [enumerations]: items.enum -[explicit associated type bounds]: paths.expr [explicit crate paths]: paths.qualifiers.global-root [extern crate]: items.extern-crate [extern function pointer types]: type.fn-pointer.qualifiers From a4ea4a1552adc892839fd6ca38c1ed5706a35809 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Mon, 27 Oct 2025 23:50:39 +0000 Subject: [PATCH 37/49] Move `Type<..>` to type expressions in index The syntax `Type<..>`, without turbofish, is only valid in a type expression. Let's move this to that table and document `Trait<..>` along with it. --- src/syntax-index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index d3c442e37f..f5f99df27e 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -173,7 +173,6 @@ This appendix provides an index of tokens and common forms with links to where t | `Type::…`
`::ident` | [associated items] | | `::…` | [qualified paths] which can be used for types without names such as `<&T>::…`, `<[T]>::…`, etc. | | `Trait::method(…)`
`Type::method(…)`
`::method(…)` | [disambiguated method calls] | -| `Type<…>` | [generic arguments] (e.g. `Vec`) | | `method::<…>(…)`
`path::<…>` | [generic arguments], aka turbofish | | `()` | [unit] | | `(expr)` | [parenthesized expressions] | @@ -240,6 +239,7 @@ This appendix provides an index of tokens and common forms with links to where t | `impl Trait` | [impl trait types], [anonymous type parameters] | | `dyn Trait` | [trait object types] | | `ident`
`ident::…` | [type paths] (can refer to structs, enums, unions, aliases, traits, generics, etc.) | +| `Type<…>`
`Trait<…>` | [generic arguments] (e.g. `Vec`) | | `Trait` | [associated type bindings] (e.g. `Iterator`) | | `Trait` | [associated type bounds] (e.g. `Iterator`) | | `&Type`
`&mut Type` | [reference types] | From 4946e967765fadbf4b5b0b2ede76655f6611f3c3 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Mon, 27 Oct 2025 23:56:53 +0000 Subject: [PATCH 38/49] Pluralize "single element tuple expressions" On the branch, we had pluralized other related expressions, so let's also pluralize "single element tuple expressions". --- src/syntax-index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index f5f99df27e..c23fcf541d 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -176,7 +176,7 @@ This appendix provides an index of tokens and common forms with links to where t | `method::<…>(…)`
`path::<…>` | [generic arguments], aka turbofish | | `()` | [unit] | | `(expr)` | [parenthesized expressions] | -| `(expr,)` | [single-element tuple expression] | +| `(expr,)` | [single-element tuple expressions] | | `(expr, …)` | [tuple expressions] | | `expr(expr, …)` | [call expressions] | | `expr.0`, `expr.1`, … | [tuple indexing expressions] | @@ -406,7 +406,7 @@ This appendix provides an index of tokens and common forms with links to where t [rest patterns]: patterns.rest [return expressions]: expr.return [self parameters]: items.fn.params.self-pat -[single-element tuple expression]: expr.tuple +[single-element tuple expressions]: expr.tuple [sized]: bound.sized [slice patterns]: patterns.slice [slice types]: type.slice From 7783ff44a13c2efb7d0f55c9717ac8ef01e2033a Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Tue, 28 Oct 2025 00:01:12 +0000 Subject: [PATCH 39/49] Add space ahead of curly brackets in index For macro invocations, struct expressions, and struct patterns, we had shown the opening curly brace without a space in front of it. This can make it visually difficult to distinguish from an opening parenthesis. Using the common Rust style of putting a space in front helps with that, so let's do that here. --- src/syntax-index.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index c23fcf541d..0edae204dc 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -146,12 +146,12 @@ This appendix provides an index of tokens and common forms with links to where t ## Macros -| Syntax | Usage | -|-------------------------------------------|-------| -| `ident!(…)`
`ident!{…}`
`ident![…]` | [macro invocations] | -| `$ident` | [macro metavariable] | -| `$ident:kind` | [macro matcher fragment specifier] | -| `$(…)…` | [macro repetition] | +| Syntax | Usage | +|--------------------------------------------|-------| +| `ident!(…)`
`ident! {…}`
`ident![…]` | [macro invocations] | +| `$ident` | [macro metavariable] | +| `$ident:kind` | [macro matcher fragment specifier] | +| `$(…)…` | [macro repetition] | ## Attributes @@ -182,7 +182,7 @@ This appendix provides an index of tokens and common forms with links to where t | `expr.0`, `expr.1`, … | [tuple indexing expressions] | | `expr.ident` | [field access expressions] | | `{…}` | [block expressions] | -| `Type{…}` | [struct expressions] | +| `Type {…}` | [struct expressions] | | `Type(…)` | [tuple struct constructors] | | `[…]` | [array expressions] | | `[expr; len]` | [repeat array expressions] | @@ -261,7 +261,7 @@ This appendix provides an index of tokens and common forms with links to where t | `..` | [rest patterns] | | `a..`, `..b`, `a..b`, `a..=b`, `..=b` | [range patterns] | | `&pattern`
`&mut pattern` | [reference patterns] | -| `path{…}` | [struct patterns] | +| `path {…}` | [struct patterns] | | `path(…)` | [tuple struct patterns] | | `(pattern, …)` | [tuple patterns] | | `(pattern)` | [grouped patterns] | From fe74fadee6841b5bb7609fd7fac28116065230ea Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Tue, 28 Oct 2025 00:08:36 +0000 Subject: [PATCH 40/49] Clarify description of items in syntax index On the branch, in the syntax index, items were described as "declarations in a crate". Some items may be declarations, but many items are actually definitions. It's probably better to not use either term here. Let's instead say that items are the components of a crate as that's the language that's used in the items chapter. --- src/syntax-index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index 0edae204dc..1585a93fed 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -202,7 +202,7 @@ This appendix provides an index of tokens and common forms with links to where t ## Items -[Items] are declarations in a crate. +[Items] are the components of a crate. | Item | Usage | |-------------------------------|-------| From e323abfdadf1e69e32298dc3d63d7ce6503afd71 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Tue, 28 Oct 2025 00:16:01 +0000 Subject: [PATCH 41/49] Add semicolons for items needing them in index On the branch, in the index, in the table for items, we had written `mod ident;` and `use path;` but we hadn't similarly indicated a trailing semicolon for type aliases, const items, and static items. Let's be consistent and indicate the trailing semicolon for those. --- src/syntax-index.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index 1585a93fed..641195ebfe 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -209,14 +209,14 @@ This appendix provides an index of tokens and common forms with links to where t | `mod ident;`
`mod ident {…}` | [modules] | | `use path;` | [use declarations] | | `fn ident(…) {…}` | [functions] | -| `type Type = Type` | [type aliases] | +| `type Type = Type;` | [type aliases] | | `struct ident {…}` | [structs] | | `enum ident {…}` | [enumerations] | | `union ident {…}` | [unions] | | `trait ident {…}` | [traits] | | `impl Type {…}`
`impl Type for Trait {…}` | [implementations] | -| `const ident = expr` | [constant items] | -| `static ident = expr` | [static items] | +| `const ident = expr;` | [constant items] | +| `static ident = expr;` | [static items] | | `extern "C" {…}` | [external blocks] | | `fn ident<…>(…) …`
`struct ident<…> {…}`
`enum ident<…> {…}`
`impl<…> Type<…> {…}` | [generic definitions] | From 33cb86212f8fcecae3d8314e09851e1caba4e6db Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Tue, 28 Oct 2025 00:21:42 +0000 Subject: [PATCH 42/49] Indicate list of primitive types is non-exhaustive In the syntax index, in the type expressions table, we list some primitive types but not all of them. Let's use the ellipses to indicate that the list is not exhaustive. --- src/syntax-index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index 641195ebfe..08f19c3472 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -226,7 +226,7 @@ This appendix provides an index of tokens and common forms with links to where t | Type | Usage | |---------------------------------------|-------| -| `bool`, `u8`, `f64`, `char`, `str` | [primitive types] | +| `bool`, `u8`, `f64`, `str`, … | [primitive types] | | `for<…>` | [higher-ranked trait bounds] | | `T: U` | [trait bounds] | | `T: 'a` | [lifetime bounds] | From f5b74cfea5ab16df2940a9ef8c0769858251bb1c Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Tue, 28 Oct 2025 00:29:45 +0000 Subject: [PATCH 43/49] Remove "compound type bounds" from syntax index On the branch, the syntax index had used "compound type bounds" to refer to a bound with a `+` in it. This isn't a term we use elsewhere; let's not use it here. --- src/syntax-index.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index 08f19c3472..351f8737e1 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -228,10 +228,10 @@ This appendix provides an index of tokens and common forms with links to where t |---------------------------------------|-------| | `bool`, `u8`, `f64`, `str`, … | [primitive types] | | `for<…>` | [higher-ranked trait bounds] | -| `T: U` | [trait bounds] | -| `T: 'a` | [lifetime bounds] | +| `T: TraitA + TraitB` | [trait bounds] | +| `T: 'a + 'b` | [lifetime bounds] | +| `T: TraitA + 'a` | [trait and lifetime bounds] | | `T: ?Sized` | [relaxed trait bounds] | -| `'a + Trait`
`Trait + Trait` | [compound type bounds] | | `[Type; len]` | [array types] | | `(Type, …)` | [tuple types] | | `[Type, …]` | [slice types] | @@ -417,6 +417,7 @@ This appendix provides an index of tokens and common forms with links to where t [structs]: items.struct [subpattern binding]: patterns.ident.scrutinized [super paths]: paths.qualifiers.super +[trait and lifetime bounds]: bound [trait bounds]: bound [trait implementations]: items.impl.trait [trait impls]: items.impl.trait From fc3a743cdd5a4aa7de76017d78895a40d2f46447 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Tue, 28 Oct 2025 00:32:43 +0000 Subject: [PATCH 44/49] Fix slice types syntax in syntax index On the branch, in the syntax index, we had notated a slice type so as to include a type and then ellipses, but it's more correct for a slice type to just have a type in the square brackets, so let's do that. --- src/syntax-index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index 351f8737e1..f09e20a121 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -234,7 +234,7 @@ This appendix provides an index of tokens and common forms with links to where t | `T: ?Sized` | [relaxed trait bounds] | | `[Type; len]` | [array types] | | `(Type, …)` | [tuple types] | -| `[Type, …]` | [slice types] | +| `[Type]` | [slice types] | | `(Type)` | [parenthesized types] | | `impl Trait` | [impl trait types], [anonymous type parameters] | | `dyn Trait` | [trait object types] | From bca3f52cd301fa97a7dc124f7cbc099ca12a1d1f Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Tue, 28 Oct 2025 00:36:55 +0000 Subject: [PATCH 45/49] Refer to "type aliases" rather than "aliases" In the syntax index, in a list of things to which type paths can refer, let's refer to "type aliases" rather than just to "aliases" for better clarity. --- src/syntax-index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index f09e20a121..4e617c47d3 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -238,7 +238,7 @@ This appendix provides an index of tokens and common forms with links to where t | `(Type)` | [parenthesized types] | | `impl Trait` | [impl trait types], [anonymous type parameters] | | `dyn Trait` | [trait object types] | -| `ident`
`ident::…` | [type paths] (can refer to structs, enums, unions, aliases, traits, generics, etc.) | +| `ident`
`ident::…` | [type paths] (can refer to structs, enums, unions, type aliases, traits, generics, etc.) | | `Type<…>`
`Trait<…>` | [generic arguments] (e.g. `Vec`) | | `Trait` | [associated type bindings] (e.g. `Iterator`) | | `Trait` | [associated type bounds] (e.g. `Iterator`) | From a1cd14754ecafd50f645cf932e2ca00fb9ad10e3 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Tue, 28 Oct 2025 00:40:16 +0000 Subject: [PATCH 46/49] Link to items listed for type paths In the syntax index, in the table about type expressions, we have a list of things that can be referred to by type paths. Let's link to each of the items in that list. --- src/syntax-index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index 4e617c47d3..51d222fc39 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -238,7 +238,7 @@ This appendix provides an index of tokens and common forms with links to where t | `(Type)` | [parenthesized types] | | `impl Trait` | [impl trait types], [anonymous type parameters] | | `dyn Trait` | [trait object types] | -| `ident`
`ident::…` | [type paths] (can refer to structs, enums, unions, type aliases, traits, generics, etc.) | +| `ident`
`ident::…` | [type paths] (can refer to [structs], [enumerations], [unions], [type aliases], [traits], [generics], etc.) | | `Type<…>`
`Trait<…>` | [generic arguments] (e.g. `Vec`) | | `Trait` | [associated type bindings] (e.g. `Iterator`) | | `Trait` | [associated type bounds] (e.g. `Iterator`) | From 4ac662670e8ed530f252bc419bf2d0b167df1da7 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Tue, 28 Oct 2025 00:46:58 +0000 Subject: [PATCH 47/49] Singularize "the rest pattern" Like "the wildcard pattern", there is only one "rest pattern". Let's singularize this and add the appropriate redirect. --- book.toml | 1 + src/patterns.md | 9 +++++---- src/syntax-index.md | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/book.toml b/book.toml index efe1405354..876d33c66a 100644 --- a/book.toml +++ b/book.toml @@ -35,6 +35,7 @@ use-boolean-and = true "/items/traits.html#object-safety" = "traits.html#dyn-compatibility" "/lifetime-elision.html#static-lifetime-elision" = "lifetime-elision.html#const-and-static-elision" "/macros-by-example.html#path-based-scope" = "macros-by-example.html#the-macro_export-attribute" +"/patterns.html#rest-patterns" = "patterns.html#rest-pattern" "/procedural-macros.html#attribute-macros" = "procedural-macros.html#the-proc_macro_attribute-attribute" "/procedural-macros.html#derive-macros" = "procedural-macros.html#the-proc_macro_derive-attribute" "/procedural-macros.html#function-like-procedural-macros" = "procedural-macros.html#the-proc_macro-attribute" diff --git a/src/patterns.md b/src/patterns.md index fd37352cdb..6c00126fc0 100644 --- a/src/patterns.md +++ b/src/patterns.md @@ -93,7 +93,7 @@ Destructuring breaks up a value into its component pieces. The syntax used is almost the same as when creating such values. r[patterns.destructure.wildcard] -In a pattern whose [scrutinee] expression has a `struct`, `enum` or `tuple` type, a [wildcard pattern](#wildcard-pattern) (`_`) stands in for a *single* data field, whereas an [et cetera](#grammar-StructPatternEtCetera) or [rest pattern](#rest-patterns) (`..`) stands in for *all* the remaining fields of a particular variant. +In a pattern whose [scrutinee] expression has a `struct`, `enum` or `tuple` type, a [wildcard pattern](#wildcard-pattern) (`_`) stands in for a *single* data field, whereas an [et cetera](#grammar-StructPatternEtCetera) or [rest pattern][patterns.rest] (`..`) stands in for *all* the remaining fields of a particular variant. r[patterns.destructure.named-field-shorthand] When destructuring a data structure with named (but not numbered) fields, it is allowed to write `fieldname` as a shorthand for `fieldname: fieldname`. @@ -421,7 +421,7 @@ r[patterns.wildcard.refutable] The wildcard pattern is always irrefutable. r[patterns.rest] -## Rest patterns +## Rest pattern r[patterns.rest.syntax] ```grammar,patterns @@ -470,7 +470,8 @@ if let [.., penultimate, _] = slice { } # let tuple = (1, 2, 3, 4, 5); -// Rest patterns may also be used in tuple and tuple struct patterns. +// The rest pattern may also be used in tuple and tuple +// struct patterns. match tuple { (1, .., y, z) => println!("y={} z={}", y, z), (.., 5) => println!("tail must be 5"), @@ -974,7 +975,7 @@ r[patterns.slice.refutable-array] Slice patterns are irrefutable when matching an array as long as each element is irrefutable. r[patterns.slice.refutable-slice] -When matching a slice, it is irrefutable only in the form with a single `..` [rest pattern](#rest-patterns) or [identifier pattern](#identifier-patterns) with the `..` rest pattern as a subpattern. +When matching a slice, it is irrefutable only in the form with a single `..` [rest pattern][patterns.rest] or [identifier pattern](#identifier-patterns) with the `..` rest pattern as a subpattern. r[patterns.slice.restriction] Within a slice, a range pattern without both lower and upper bound must be enclosed in parentheses, as in `(a..)`, to clarify it is intended to match against a single slice element. diff --git a/src/syntax-index.md b/src/syntax-index.md index 51d222fc39..97770efd6a 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -100,7 +100,7 @@ This appendix provides an index of tokens and common forms with links to where t | `<=` | Le | [less than or equal to][comparison] | | `@` | At | [subpattern binding] | | `.` | Dot | [field access][field], [tuple index] | -| `..` | DotDot | [range expressions][expr.range], [struct expressions], [rest patterns], [range patterns], [struct patterns] | +| `..` | DotDot | [range expressions][expr.range], [struct expressions], [rest pattern], [range patterns], [struct patterns] | | `...` | DotDotDot | [variadic functions], [range patterns] | | `..=` | DotDotEq | [inclusive range expressions][expr.range], [range patterns] | | `,` | Comma | various separators | @@ -258,7 +258,7 @@ This appendix provides an index of tokens and common forms with links to where t | `"foo"`, `'a'`, `123`, `2.4`, … | [literal patterns] | | `ident` | [identifier patterns] | | `_` | [wildcard pattern] | -| `..` | [rest patterns] | +| `..` | [rest pattern] | | `a..`, `..b`, `a..b`, `a..=b`, `..=b` | [range patterns] | | `&pattern`
`&mut pattern` | [reference patterns] | | `path {…}` | [struct patterns] | @@ -403,7 +403,7 @@ This appendix provides an index of tokens and common forms with links to where t [relaxed trait bounds]: bound.sized [repeat array expressions]: expr.array [reserved keyword]: lex.keywords.reserved -[rest patterns]: patterns.rest +[rest pattern]: patterns.rest [return expressions]: expr.return [self parameters]: items.fn.params.self-pat [single-element tuple expressions]: expr.tuple From fd446a107e541b7a2289f9962fa5ab718fe5d242 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Tue, 28 Oct 2025 06:06:12 +0000 Subject: [PATCH 48/49] Go with "constant items" for `_` in index In the keywords table in the syntax index, every entry except the one for constant items for `_` consists entirely of a link body. For that one, though, we had left "unnamed" out of the link body. Visually, that just stands out too much. We could just put "unnamed" in the link body, but most of the other entries aren't really that specific. It seems OK to just say "constant items" for this, so let's do that. --- src/syntax-index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index 97770efd6a..5fbb9f852a 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -6,7 +6,7 @@ This appendix provides an index of tokens and common forms with links to where t | Keyword | Usage | |---------------|-------| -| `_` | [wildcard pattern], [inferred const], [inferred type], [placeholder lifetime], unnamed [constant items], [extern crate], [use declarations], [destructuring assignment] | +| `_` | [wildcard pattern], [inferred const], [inferred type], [placeholder lifetime], [constant items], [extern crate], [use declarations], [destructuring assignment] | | `abstract` | [reserved keyword] | | `as` | [extern crate][items.extern-crate.as], [use declarations][items.use.forms.as], [type cast expressions], [qualified paths] | | `async` | [async functions], [async blocks], [async closures] | From e93dce5ef572d3063e98ac78e0b54bb5b43962bf Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Tue, 28 Oct 2025 06:26:09 +0000 Subject: [PATCH 49/49] Say "use" rather than "usage" in the syntax index In each table in the syntax index, we have some bit of syntax on the left and then on the right we have features in which that bit of syntax is used. Should we title the column on the right "use" (or maybe "uses") or "usage"? One could almost, superficially, make a case for "usage". As relevant here, Webster's defines it as "the way in which a word, phrase, etc. is used to express a particular idea". That sounds close. The trouble is that it's nearly the wrong way around. The "idea" here is actually the thing on the right. The "usage" would be the place or way in which the syntax is used to express that idea. Conversely, definitions of "use" apply cleanly: to "employ for or apply to a given purpose", "an instance or way of using", etc. As Garner says: > Whenever *use* is possible, *usage* shouldn't appear. Let's say "use". --- src/syntax-index.md | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/syntax-index.md b/src/syntax-index.md index 5fbb9f852a..03df966db6 100644 --- a/src/syntax-index.md +++ b/src/syntax-index.md @@ -4,8 +4,8 @@ This appendix provides an index of tokens and common forms with links to where t ## Keywords -| Keyword | Usage | -|---------------|-------| +| Keyword | Use | +|---------------|-----| | `_` | [wildcard pattern], [inferred const], [inferred type], [placeholder lifetime], [constant items], [extern crate], [use declarations], [destructuring assignment] | | `abstract` | [reserved keyword] | | `as` | [extern crate][items.extern-crate.as], [use declarations][items.use.forms.as], [type cast expressions], [qualified paths] | @@ -66,8 +66,8 @@ This appendix provides an index of tokens and common forms with links to where t ## Operators and punctuation -| Symbol | Name | Usage | -|--------|-------------|-------| +| Symbol | Name | Use | +|--------|-------------|-----| | `+` | Plus | [addition][arith], [trait bounds], [macro Kleene matcher] | | `-` | Minus | [subtraction][arith], [negation] | | `*` | Star | [multiplication][arith], [dereference], [raw pointers], [macro Kleene matcher], [glob imports] | @@ -117,8 +117,8 @@ This appendix provides an index of tokens and common forms with links to where t ## Comments -| Comment | Usage | -|----------|-------| +| Comment | Use | +|----------|-----| | `//` | [line comment][comments] | | `//!` | [inner line comment][comments] | | `///` | [outer line doc comment][comments] | @@ -128,8 +128,8 @@ This appendix provides an index of tokens and common forms with links to where t ## Other tokens -| Token | Usage | -|--------------|-------| +| Token | Use | +|--------------|-----| | `ident` | [identifiers] | | `r#ident` | [raw identifiers] | | `'ident` | [lifetimes and loop labels] | @@ -146,8 +146,8 @@ This appendix provides an index of tokens and common forms with links to where t ## Macros -| Syntax | Usage | -|--------------------------------------------|-------| +| Syntax | Use | +|--------------------------------------------|-----| | `ident!(…)`
`ident! {…}`
`ident![…]` | [macro invocations] | | `$ident` | [macro metavariable] | | `$ident:kind` | [macro matcher fragment specifier] | @@ -155,15 +155,15 @@ This appendix provides an index of tokens and common forms with links to where t ## Attributes -| Syntax | Usage | -|------------|-------| +| Syntax | Use | +|------------|-----| | `#[meta]` | [outer attribute] | | `#![meta]` | [inner attribute] | ## Expressions -| Expression | Usage | -|---------------------------|-------| +| Expression | Use | +|---------------------------|-----| | \|…\| expr
\|…\| -> Type { … } | [closures] | | `ident::…` | [paths] | | `::crate_name::…` | [explicit crate paths] | @@ -204,8 +204,8 @@ This appendix provides an index of tokens and common forms with links to where t [Items] are the components of a crate. -| Item | Usage | -|-------------------------------|-------| +| Item | Use | +|-------------------------------|-----| | `mod ident;`
`mod ident {…}` | [modules] | | `use path;` | [use declarations] | | `fn ident(…) {…}` | [functions] | @@ -224,8 +224,8 @@ This appendix provides an index of tokens and common forms with links to where t [Type expressions] are used to refer to types. -| Type | Usage | -|---------------------------------------|-------| +| Type | Use | +|---------------------------------------|-----| | `bool`, `u8`, `f64`, `str`, … | [primitive types] | | `for<…>` | [higher-ranked trait bounds] | | `T: TraitA + TraitB` | [trait bounds] | @@ -253,8 +253,8 @@ This appendix provides an index of tokens and common forms with links to where t [Patterns] are used to match values. -| Pattern | Usage | -|-----------------------------------|-------| +| Pattern | Use | +|-----------------------------------|-----| | `"foo"`, `'a'`, `123`, `2.4`, … | [literal patterns] | | `ident` | [identifier patterns] | | `_` | [wildcard pattern] |