about summary refs log tree commit diff
path: root/tests/ui
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-06-22 22:18:08 +0000
committerbors <bors@rust-lang.org>2022-06-22 22:18:08 +0000
commit3d366fc2d8ab854adab6936c9d5d7b2cf929ae96 (patch)
tree36049a9fa8154e6888fd39efc657d15d67c0b517 /tests/ui
parentf9fea1737e34da3afedf4a0d35ea4866ce7f87a1 (diff)
parent6fc84d4da39942857e243cfe951bbefbdba5250b (diff)
downloadrust-3d366fc2d8ab854adab6936c9d5d7b2cf929ae96.tar.gz
rust-3d366fc2d8ab854adab6936c9d5d7b2cf929ae96.zip
Auto merge of #9026 - hellow554:neg_multiply_precedence, r=xFrednet
put parentheses around neg_multiply suggestion if needed

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: [`neg_multiply`]: put parentheses around suggestion if needed
Diffstat (limited to 'tests/ui')
-rw-r--r--tests/ui/neg_multiply.fixed3
-rw-r--r--tests/ui/neg_multiply.rs3
-rw-r--r--tests/ui/neg_multiply.stderr14
3 files changed, 19 insertions, 1 deletions
diff --git a/tests/ui/neg_multiply.fixed b/tests/ui/neg_multiply.fixed
index 35af9d6ae31..58ab9e85678 100644
--- a/tests/ui/neg_multiply.fixed
+++ b/tests/ui/neg_multiply.fixed
@@ -38,6 +38,9 @@ fn main() {
 
     0xcafe | -0xff00;
 
+    -(3_usize as i32);
+    -(3_usize as i32);
+
     -1 * -1; // should be ok
 
     X * -1; // should be ok
diff --git a/tests/ui/neg_multiply.rs b/tests/ui/neg_multiply.rs
index 7dbdb0906ce..581290dc72e 100644
--- a/tests/ui/neg_multiply.rs
+++ b/tests/ui/neg_multiply.rs
@@ -38,6 +38,9 @@ fn main() {
 
     0xcafe | 0xff00 * -1;
 
+    3_usize as i32 * -1;
+    (3_usize as i32) * -1;
+
     -1 * -1; // should be ok
 
     X * -1; // should be ok
diff --git a/tests/ui/neg_multiply.stderr b/tests/ui/neg_multiply.stderr
index dbf8fb36938..388ef29eb85 100644
--- a/tests/ui/neg_multiply.stderr
+++ b/tests/ui/neg_multiply.stderr
@@ -36,5 +36,17 @@ error: this multiplication by -1 can be written more succinctly
 LL |     0xcafe | 0xff00 * -1;
    |              ^^^^^^^^^^^ help: consider using: `-0xff00`
 
-error: aborting due to 6 previous errors
+error: this multiplication by -1 can be written more succinctly
+  --> $DIR/neg_multiply.rs:41:5
+   |
+LL |     3_usize as i32 * -1;
+   |     ^^^^^^^^^^^^^^^^^^^ help: consider using: `-(3_usize as i32)`
+
+error: this multiplication by -1 can be written more succinctly
+  --> $DIR/neg_multiply.rs:42:5
+   |
+LL |     (3_usize as i32) * -1;
+   |     ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `-(3_usize as i32)`
+
+error: aborting due to 8 previous errors