about summary refs log tree commit diff
path: root/tests/ui/binop
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-04-12 08:41:20 +0000
committerbors <bors@rust-lang.org>2024-04-12 08:41:20 +0000
commitab71ee7a9214c2793108a41efb065aa77aeb7326 (patch)
tree63691abb45d6b276fda29db6ceed30dba1265e66 /tests/ui/binop
parent6bc9dcd7ecf2cff2b6ef2243e7aeaded8d0d4c0f (diff)
parent889ca7e2164a0032d668cb6b1e148507dc2bd9b2 (diff)
downloadrust-ab71ee7a9214c2793108a41efb065aa77aeb7326.tar.gz
rust-ab71ee7a9214c2793108a41efb065aa77aeb7326.zip
Auto merge of #123736 - compiler-errors:multiply-on-rhs, r=estebank
Don't delay a bug if we suggest adding a semicolon to the RHS of an assign operator

It only makes sense to delay a bug based on the assumption that "[we] defer to the later error produced by `check_lhs_assignable`" *if* the expression we're erroring actually is an LHS; otherwise, we should still report the error since it's both useful and required.

Fixes #123722
Diffstat (limited to 'tests/ui/binop')
-rw-r--r--tests/ui/binop/multiply-is-deref-on-rhs.rs8
-rw-r--r--tests/ui/binop/multiply-is-deref-on-rhs.stderr16
2 files changed, 24 insertions, 0 deletions
diff --git a/tests/ui/binop/multiply-is-deref-on-rhs.rs b/tests/ui/binop/multiply-is-deref-on-rhs.rs
new file mode 100644
index 00000000000..7c24e1b4d57
--- /dev/null
+++ b/tests/ui/binop/multiply-is-deref-on-rhs.rs
@@ -0,0 +1,8 @@
+pub fn test(y: &i32) {
+    let x;
+    x = ()
+    *y
+    //~^ ERROR cannot multiply `()` by `&i32`
+}
+
+fn main() {}
diff --git a/tests/ui/binop/multiply-is-deref-on-rhs.stderr b/tests/ui/binop/multiply-is-deref-on-rhs.stderr
new file mode 100644
index 00000000000..e157f4f58ca
--- /dev/null
+++ b/tests/ui/binop/multiply-is-deref-on-rhs.stderr
@@ -0,0 +1,16 @@
+error[E0369]: cannot multiply `()` by `&i32`
+  --> $DIR/multiply-is-deref-on-rhs.rs:4:5
+   |
+LL |     x = ()
+   |         -- ()
+LL |     *y
+   |     ^- &i32
+   |
+help: you might have meant to write a semicolon here
+   |
+LL |     x = ();
+   |           +
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0369`.