diff --git a/src/expressions/literal-expr.md b/src/expressions/literal-expr.md index 82363b70a..4eec37dcb 100644 --- a/src/expressions/literal-expr.md +++ b/src/expressions/literal-expr.md @@ -10,7 +10,7 @@ >    | [RAW_BYTE_STRING_LITERAL]\ >    | [INTEGER_LITERAL][^out-of-range]\ >    | [FLOAT_LITERAL]\ ->    | [BOOLEAN_LITERAL] +>    | `true` | `false` > > [^out-of-range]: A value ≥ 2128 is not allowed. @@ -18,7 +18,7 @@ A _literal expression_ is an expression consisting of a single token, rather tha A literal is a form of [constant expression], so is evaluated (primarily) at compile time. -Each of the lexical [literal][literal tokens] forms described earlier can make up a literal expression. +Each of the lexical [literal][literal tokens] forms described earlier can make up a literal expression, as can the keywords `true` and `false`. ```rust "hello"; // string type @@ -148,10 +148,14 @@ The value of the expression is determined from the string representation of the ## Boolean literal expressions -A boolean literal expression consists of a single [BOOLEAN_LITERAL] token. +A boolean literal expression consists of one of the keywords `true` or `false`. + +The expression's type is the primitive [boolean type], and its value is: + * true if the keyword is `true` + * false if the keyword is `false` -> **Note**: This section is incomplete. +[boolean type]: ../types/boolean.md [constant expression]: ../const_eval.md#constant-expressions [floating-point types]: ../types/numeric.md#floating-point-types [lint check]: ../attributes/diagnostics.md#lint-check-attributes @@ -176,4 +180,3 @@ A boolean literal expression consists of a single [BOOLEAN_LITERAL] token. [RAW_BYTE_STRING_LITERAL]: ../tokens.md#raw-byte-string-literals [INTEGER_LITERAL]: ../tokens.md#integer-literals [FLOAT_LITERAL]: ../tokens.md#floating-point-literals -[BOOLEAN_LITERAL]: ../tokens.md#boolean-literals diff --git a/src/patterns.md b/src/patterns.md index e13f198bc..91b8a7f48 100644 --- a/src/patterns.md +++ b/src/patterns.md @@ -122,7 +122,7 @@ if let (a, 3) = (1, 2) { // "(a, 3)" is refutable, and will not match > **Syntax**\ > _LiteralPattern_ :\ ->       [BOOLEAN_LITERAL]\ +>       `true` | `false`\ >    | [CHAR_LITERAL]\ >    | [BYTE_LITERAL]\ >    | [STRING_LITERAL]\ @@ -132,7 +132,6 @@ if let (a, 3) = (1, 2) { // "(a, 3)" is refutable, and will not match >    | `-`? [INTEGER_LITERAL]\ >    | `-`? [FLOAT_LITERAL] -[BOOLEAN_LITERAL]: tokens.md#boolean-literals [CHAR_LITERAL]: tokens.md#character-literals [BYTE_LITERAL]: tokens.md#byte-literals [STRING_LITERAL]: tokens.md#string-literals diff --git a/src/tokens.md b/src/tokens.md index 589d9eaa5..cdb4f07f7 100644 --- a/src/tokens.md +++ b/src/tokens.md @@ -560,15 +560,6 @@ Examples of reserved forms: 2.0em; // this is not a pseudoliteral, or `2.0` followed by `em` ``` -### Boolean literals - -> **Lexer**\ -> BOOLEAN_LITERAL :\ ->       `true`\ ->    | `false` - -The two values of the boolean type are written `true` and `false`. - ## Lifetimes and loop labels > **Lexer**\