about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2024-07-05 00:52:01 +0000
committerEsteban Küber <esteban@kuber.com.ar>2024-07-05 00:52:01 +0000
commit86a19467c1da6eb9353ad878979a8f74a8b5b230 (patch)
treec003803360f6d45a6a913cd58270bfd530c4efa1 /tests
parentc4225812973cee4bba952cbf7a421f69871fed0d (diff)
downloadrust-86a19467c1da6eb9353ad878979a8f74a8b5b230.tar.gz
rust-86a19467c1da6eb9353ad878979a8f74a8b5b230.zip
Tweak `-1 as usize` suggestion
When writing a negative unsigned integer literal, use a verbose suggestion and account for `as` casting.
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/feature-gates/feature-gate-negate-unsigned.stderr9
-rw-r--r--tests/ui/unsigned-literal-negation.stderr27
2 files changed, 20 insertions, 16 deletions
diff --git a/tests/ui/feature-gates/feature-gate-negate-unsigned.stderr b/tests/ui/feature-gates/feature-gate-negate-unsigned.stderr
index d1f4ed5cb04..696326157ce 100644
--- a/tests/ui/feature-gates/feature-gate-negate-unsigned.stderr
+++ b/tests/ui/feature-gates/feature-gate-negate-unsigned.stderr
@@ -2,12 +2,13 @@ error[E0600]: cannot apply unary operator `-` to type `usize`
   --> $DIR/feature-gate-negate-unsigned.rs:10:23
    |
 LL |     let _max: usize = -1;
-   |                       ^^
-   |                       |
-   |                       cannot apply unary operator `-`
-   |                       help: you may have meant the maximum value of `usize`: `usize::MAX`
+   |                       ^^ cannot apply unary operator `-`
    |
    = note: unsigned values cannot be negated
+help: you may have meant the maximum value of `usize`
+   |
+LL |     let _max: usize = usize::MAX;
+   |                       ~~~~~~~~~~
 
 error[E0600]: cannot apply unary operator `-` to type `u8`
   --> $DIR/feature-gate-negate-unsigned.rs:14:14
diff --git a/tests/ui/unsigned-literal-negation.stderr b/tests/ui/unsigned-literal-negation.stderr
index 0aaa8c3b72f..b0a730477a1 100644
--- a/tests/ui/unsigned-literal-negation.stderr
+++ b/tests/ui/unsigned-literal-negation.stderr
@@ -2,34 +2,37 @@ error[E0600]: cannot apply unary operator `-` to type `usize`
   --> $DIR/unsigned-literal-negation.rs:2:13
    |
 LL |     let x = -1 as usize;
-   |             ^^
-   |             |
-   |             cannot apply unary operator `-`
-   |             help: you may have meant the maximum value of `usize`: `usize::MAX`
+   |             ^^ cannot apply unary operator `-`
    |
    = note: unsigned values cannot be negated
+help: you may have meant the maximum value of `usize`
+   |
+LL |     let x = usize::MAX;
+   |             ~~~~~~~~~~
 
 error[E0600]: cannot apply unary operator `-` to type `usize`
   --> $DIR/unsigned-literal-negation.rs:3:13
    |
 LL |     let x = (-1) as usize;
-   |             ^^^^
-   |             |
-   |             cannot apply unary operator `-`
-   |             help: you may have meant the maximum value of `usize`: `usize::MAX`
+   |             ^^^^ cannot apply unary operator `-`
    |
    = note: unsigned values cannot be negated
+help: you may have meant the maximum value of `usize`
+   |
+LL |     let x = usize::MAX;
+   |             ~~~~~~~~~~
 
 error[E0600]: cannot apply unary operator `-` to type `u32`
   --> $DIR/unsigned-literal-negation.rs:4:18
    |
 LL |     let x: u32 = -1;
-   |                  ^^
-   |                  |
-   |                  cannot apply unary operator `-`
-   |                  help: you may have meant the maximum value of `u32`: `u32::MAX`
+   |                  ^^ cannot apply unary operator `-`
    |
    = note: unsigned values cannot be negated
+help: you may have meant the maximum value of `u32`
+   |
+LL |     let x: u32 = u32::MAX;
+   |                  ~~~~~~~~
 
 error: aborting due to 3 previous errors