Skip to content

Commit e079afa

Browse files
committed
Auto merge of #31664 - nodakai:reference-negation, r=steveklabnik
It would be great if someone could check my English.
2 parents 79f914f + 559683c commit e079afa

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/doc/reference.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,10 @@ Examples of integer literals of various forms:
379379
0usize; // type usize
380380
```
381381

382+
Note that the Rust syntax considers `-1i8` as an application of the [unary minus
383+
operator](#unary-operator-expressions) to an integer literal `1i8`, rather than
384+
a single integer literal.
385+
382386
##### Floating-point literals
383387

384388
A _floating-point literal_ has one of two forms:
@@ -2776,7 +2780,9 @@ Rust defines the following unary operators. They are all written as prefix opera
27762780
before the expression they apply to.
27772781

27782782
* `-`
2779-
: Negation. May only be applied to numeric types.
2783+
: Negation. Signed integer types and floating-point types support negation. It
2784+
is an error to apply negation to unsigned types; for example, the compiler
2785+
rejects `-1u32`.
27802786
* `*`
27812787
: Dereference. When applied to a [pointer](#pointer-types) it denotes the
27822788
pointed-to location. For pointers to mutable locations, the resulting

0 commit comments

Comments
 (0)