You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> [^out-of-range]: A value ≥ 2<sup>128</sup> is not allowed.
16
14
17
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.
18
16
@@ -54,7 +52,7 @@ A string literal expression consists of a single [BYTE_STRING_LITERAL] or [RAW_B
54
52
55
53
An integer literal expression consists of a single [INTEGER_LITERAL] token.
56
54
57
-
If the token has a [suffix], the suffix will be the name of one of the [primitive integer types][numeric types]: `u8`, `i8`, `u16`, `i16`, `u32`, `i32`, `u64`, `i64`, `u128`, `i128`, `usize`, or `isize`, and the expression has that type.
55
+
If the token has a [suffix], the suffix must be the name of one of the [primitive integer types][numeric types]: `u8`, `i8`, `u16`, `i16`, `u32`, `i32`, `u64`, `i64`, `u128`, `i128`, `usize`, or `isize`, and the expression has that type.
58
56
59
57
If the token has no suffix, the expression's type is determined by type inference:
60
58
@@ -96,10 +94,12 @@ The value of the expression is determined from the string representation of the
96
94
97
95
* If the radix is not 10, the first two characters are removed from the string.
98
96
97
+
* Any suffix is removed from the string.
98
+
99
99
* Any underscores are removed from the string.
100
100
101
101
* The string is converted to a `u128` value as if by [`u128::from_str_radix`] with the chosen radix.
102
-
If the value does not fit in `u128`, the expression is rejected by the parser.
102
+
If the value does not fit in `u128`, it is a compiler error.
103
103
104
104
* The `u128` value is converted to the expression's type via a [numeric cast].
105
105
@@ -111,9 +111,11 @@ If the value does not fit in `u128`, the expression is rejected by the parser.
111
111
112
112
## Floating-point literal expressions
113
113
114
-
A floating-point literal expression consists of a single [FLOAT_LITERAL] token.
114
+
A floating-point literal expression has one of two forms:
115
+
* a single [FLOAT_LITERAL] token
116
+
* a single [INTEGER_LITERAL] token which has a suffix and no radix indicator
115
117
116
-
If the token has a [suffix], the suffix will be the name of one of the [primitive floating-point types][floating-point types]: `f32` or `f64`, and the expression has that type.
118
+
If the token has a [suffix], the suffix must be the name of one of the [primitive floating-point types][floating-point types]: `f32` or `f64`, and the expression has that type.
117
119
118
120
If the token has no suffix, the expression's type is determined by type inference:
119
121
@@ -136,6 +138,8 @@ let x: f64 = 2.; // type f64
136
138
137
139
The value of the expression is determined from the string representation of the token as follows:
138
140
141
+
* Any suffix is removed from the string.
142
+
139
143
* Any underscores are removed from the string.
140
144
141
145
* The string is converted to the expression's type as if by [`f32::from_str`] or [`f64::from_str`].
0 commit comments