Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/librustc_typeck/check/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,14 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
err.emit();
}
IsAssign::No => {
let mut err = struct_span_err!(self.tcx.sess, expr.span, E0369,
let mut err = struct_span_err!(self.tcx.sess, op.span, E0369,
"binary operation `{}` cannot be applied to type `{}`",
op.node.as_str(),
lhs_ty);

err.span_label(lhs_expr.span, lhs_ty.to_string());
err.span_label(rhs_expr.span, rhs_ty.to_string());

let mut suggested_deref = false;
if let Ref(_, mut rty, _) = lhs_ty.sty {
if {
Expand Down
12 changes: 8 additions & 4 deletions src/test/ui/autoderef-full-lval.stderr
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
error[E0369]: binary operation `+` cannot be applied to type `std::boxed::Box<isize>`
--> $DIR/autoderef-full-lval.rs:15:20
--> $DIR/autoderef-full-lval.rs:15:24
|
LL | let z: isize = a.x + b.y;
| ^^^^^^^^^
| --- ^ --- std::boxed::Box<isize>
| |
| std::boxed::Box<isize>
|
= note: an implementation of `std::ops::Add` might be missing for `std::boxed::Box<isize>`

error[E0369]: binary operation `+` cannot be applied to type `std::boxed::Box<isize>`
--> $DIR/autoderef-full-lval.rs:21:25
--> $DIR/autoderef-full-lval.rs:21:33
|
LL | let answer: isize = forty.a + two.a;
| ^^^^^^^^^^^^^^^
| ------- ^ ----- std::boxed::Box<isize>
| |
| std::boxed::Box<isize>
|
= note: an implementation of `std::ops::Add` might be missing for `std::boxed::Box<isize>`

Expand Down
6 changes: 4 additions & 2 deletions src/test/ui/binary-op-on-double-ref.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
error[E0369]: binary operation `%` cannot be applied to type `&&{integer}`
--> $DIR/binary-op-on-double-ref.rs:4:9
--> $DIR/binary-op-on-double-ref.rs:4:11
|
LL | x % 2 == 0
| ^^^^^
| - ^ - {integer}
| |
| &&{integer}
|
= help: `%` can be used on '{integer}', you can dereference `x`: `*x`

Expand Down
6 changes: 4 additions & 2 deletions src/test/ui/binop/binop-bitxor-str.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
error[E0369]: binary operation `^` cannot be applied to type `std::string::String`
--> $DIR/binop-bitxor-str.rs:3:21
--> $DIR/binop-bitxor-str.rs:3:37
|
LL | fn main() { let x = "a".to_string() ^ "b".to_string(); }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| --------------- ^ --------------- std::string::String
| |
| std::string::String
|
= note: an implementation of `std::ops::BitXor` might be missing for `std::string::String`

Expand Down
6 changes: 4 additions & 2 deletions src/test/ui/binop/binop-mul-bool.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
error[E0369]: binary operation `*` cannot be applied to type `bool`
--> $DIR/binop-mul-bool.rs:3:21
--> $DIR/binop-mul-bool.rs:3:26
|
LL | fn main() { let x = true * false; }
| ^^^^^^^^^^^^
| ---- ^ ----- bool
| |
| bool
|
= note: an implementation of `std::ops::Mul` might be missing for `bool`

Expand Down
6 changes: 4 additions & 2 deletions src/test/ui/binop/binop-typeck.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
error[E0369]: binary operation `+` cannot be applied to type `bool`
--> $DIR/binop-typeck.rs:6:13
--> $DIR/binop-typeck.rs:6:15
|
LL | let z = x + y;
| ^^^^^
| - ^ - {integer}
| |
| bool
|
= note: an implementation of `std::ops::Add` might be missing for `bool`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ error[E0369]: binary operation `==` cannot be applied to type `Error`
|
LL | x: Error
| ^^^^^^^^
| |
| Error
| Error
|
= note: an implementation of `std::cmp::PartialEq` might be missing for `Error`

Expand All @@ -11,6 +14,9 @@ error[E0369]: binary operation `!=` cannot be applied to type `Error`
|
LL | x: Error
| ^^^^^^^^
| |
| Error
| Error
|
= note: an implementation of `std::cmp::PartialEq` might be missing for `Error`

Expand Down
6 changes: 6 additions & 0 deletions src/test/ui/derives/derives-span-PartialEq-enum.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ error[E0369]: binary operation `==` cannot be applied to type `Error`
|
LL | Error
| ^^^^^
| |
| Error
| Error
|
= note: an implementation of `std::cmp::PartialEq` might be missing for `Error`

Expand All @@ -11,6 +14,9 @@ error[E0369]: binary operation `!=` cannot be applied to type `Error`
|
LL | Error
| ^^^^^
| |
| Error
| Error
|
= note: an implementation of `std::cmp::PartialEq` might be missing for `Error`

Expand Down
6 changes: 6 additions & 0 deletions src/test/ui/derives/derives-span-PartialEq-struct.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ error[E0369]: binary operation `==` cannot be applied to type `Error`
|
LL | x: Error
| ^^^^^^^^
| |
| Error
| Error
|
= note: an implementation of `std::cmp::PartialEq` might be missing for `Error`

Expand All @@ -11,6 +14,9 @@ error[E0369]: binary operation `!=` cannot be applied to type `Error`
|
LL | x: Error
| ^^^^^^^^
| |
| Error
| Error
|
= note: an implementation of `std::cmp::PartialEq` might be missing for `Error`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ error[E0369]: binary operation `==` cannot be applied to type `Error`
|
LL | Error
| ^^^^^
| |
| Error
| Error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a check for the case when both left and right overlap to avoid this output?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fixed

|
= note: an implementation of `std::cmp::PartialEq` might be missing for `Error`

Expand All @@ -11,6 +14,9 @@ error[E0369]: binary operation `!=` cannot be applied to type `Error`
|
LL | Error
| ^^^^^
| |
| Error
| Error
|
= note: an implementation of `std::cmp::PartialEq` might be missing for `Error`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ error[E0369]: binary operation `==` cannot be applied to type `NoCloneOrEq`
|
LL | x: NoCloneOrEq
| ^^^^^^^^^^^^^^
| |
| NoCloneOrEq
| NoCloneOrEq
|
= note: an implementation of `std::cmp::PartialEq` might be missing for `NoCloneOrEq`

Expand All @@ -11,6 +14,9 @@ error[E0369]: binary operation `!=` cannot be applied to type `NoCloneOrEq`
|
LL | x: NoCloneOrEq
| ^^^^^^^^^^^^^^
| |
| NoCloneOrEq
| NoCloneOrEq
|
= note: an implementation of `std::cmp::PartialEq` might be missing for `NoCloneOrEq`

Expand Down
6 changes: 4 additions & 2 deletions src/test/ui/fn/fn-compare-mismatch.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
error[E0369]: binary operation `==` cannot be applied to type `fn() {main::f}`
--> $DIR/fn-compare-mismatch.rs:4:13
--> $DIR/fn-compare-mismatch.rs:4:15
|
LL | let x = f == g;
| ^^^^^^
| - ^^ - fn() {main::g}
| |
| fn() {main::f}
|
= note: an implementation of `std::cmp::PartialEq` might be missing for `fn() {main::f}`

Expand Down
6 changes: 4 additions & 2 deletions src/test/ui/for/for-loop-type-error.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
error[E0369]: binary operation `+` cannot be applied to type `()`
--> $DIR/for-loop-type-error.rs:2:13
--> $DIR/for-loop-type-error.rs:2:16
|
LL | let x = () + ();
| ^^^^^^^
| -- ^ -- ()
| |
| ()
|
= note: an implementation of `std::ops::Add` might be missing for `()`

Expand Down
6 changes: 4 additions & 2 deletions src/test/ui/issues/issue-14915.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
error[E0369]: binary operation `+` cannot be applied to type `std::boxed::Box<isize>`
--> $DIR/issue-14915.rs:6:20
--> $DIR/issue-14915.rs:6:22
|
LL | println!("{}", x + 1);
| ^^^^^
| - ^ - {integer}
| |
| std::boxed::Box<isize>
|
= note: an implementation of `std::ops::Add` might be missing for `std::boxed::Box<isize>`

Expand Down
6 changes: 4 additions & 2 deletions src/test/ui/issues/issue-24363.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ LL | 1.create_a_type_error[
| ^^^^^^^^^^^^^^^^^^^

error[E0369]: binary operation `+` cannot be applied to type `()`
--> $DIR/issue-24363.rs:3:9
--> $DIR/issue-24363.rs:3:11
|
LL | ()+()
| ^^^^^
| --^-- ()
| |
| ()
|
= note: an implementation of `std::ops::Add` might be missing for `()`

Expand Down
Loading