Skip to content

Commit e06fea0

Browse files
committed
Move the general description of literal expressions from tokens.md to literal-expr.md
1 parent 34e7e5f commit e06fea0

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/expressions/literal-expr.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,20 @@
1212
>    | [FLOAT_LITERAL]\
1313
>    | [BOOLEAN_LITERAL]
1414
15-
A _literal expression_ consists of one of the [literal](../tokens.md#literals) forms described earlier.
16-
It directly describes a number, character, string, or boolean value.
15+
A _literal expression_ is an expression consisting of a single token, rather than a sequence of tokens, that immediately and directly denotes the value it evaluates to, rather than referring to it by name or some other evaluation rule.
16+
17+
A literal is a form of [constant expression], so is evaluated (primarily) at compile time.
18+
19+
Each of the lexical [literal][literal tokens] forms described earlier can make up a literal expression.
1720

1821
```rust
1922
"hello"; // string type
2023
'5'; // character type
2124
5; // integer type
2225
```
2326

27+
[constant expression]: ../const_eval.md#constant-expressions
28+
[literal tokens]: ../tokens.md#literals
2429
[CHAR_LITERAL]: ../tokens.md#character-literals
2530
[STRING_LITERAL]: ../tokens.md#string-literals
2631
[RAW_STRING_LITERAL]: ../tokens.md#raw-string-literals

src/tokens.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@ table production] form, and appear in `monospace` font.
1818

1919
## Literals
2020

21-
A literal is an expression consisting of a single token, rather than a sequence
22-
of tokens, that immediately and directly denotes the value it evaluates to,
23-
rather than referring to it by name or some other evaluation rule. A literal is
24-
a form of [constant expression](const_eval.md#constant-expressions), so is
25-
evaluated (primarily) at compile time.
21+
Literals are tokens used in [literal expressions].
2622

2723
### Examples
2824

@@ -667,6 +663,7 @@ Similarly the `r`, `b`, and `br` prefixes used in raw string literals, byte lite
667663
[if let]: expressions/if-expr.md#if-let-expressions
668664
[keywords]: keywords.md
669665
[lazy-bool]: expressions/operator-expr.md#lazy-boolean-operators
666+
[literal expressions]: expressions/literal-expr.md
670667
[loop labels]: expressions/loop-expr.md
671668
[machine types]: types/numeric.md
672669
[macros]: macros-by-example.md

0 commit comments

Comments
 (0)