From 29e5f8e9bc2d9c6fd70941185aabcb3694fbca90 Mon Sep 17 00:00:00 2001 From: LeSeulArtichaut Date: Sat, 7 Dec 2019 19:03:06 +0100 Subject: [PATCH 1/7] E0369 messages mimics E0277 --- src/librustc_typeck/check/op.rs | 66 ++++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 22 deletions(-) diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index 321faa4a32285..e85bf0797c832 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -334,10 +334,51 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err.emit(); } IsAssign::No => { + let (message, missing_trait) = match op.node { + hir::BinOpKind::Add => { + (format!("cannot add `{}` to `{}`", rhs_ty, lhs_ty), + Some("std::ops::Add")) + }, + hir::BinOpKind::Sub => { + (format!("cannot substract `{}` from `{}`", rhs_ty, lhs_ty), + Some("std::ops::Sub")) + }, + hir::BinOpKind::Mul => { + (format!("cannot multiply `{}` to `{}`", rhs_ty, lhs_ty), + Some("std::ops::Mul")) + }, + hir::BinOpKind::Div => { + (format!("cannot divide `{}` by `{}`", lhs_ty, rhs_ty), + Some("std::ops::Div")) + }, + hir::BinOpKind::Rem => { + (format!("cannot mod `{}` by `{}`", lhs_ty, rhs_ty), + Some("std::ops::Rem")) + }, + hir::BinOpKind::BitAnd => { + (format!("no implementation for `{} & {}`", lhs_ty, rhs_ty), + Some("std::ops::BitAnd")) + }, + hir::BinOpKind::BitXor => { + (format!("no implementation for `{} ^ {}`", lhs_ty, rhs_ty), + Some("std::ops::BitXor")) + }, + hir::BinOpKind::BitOr => { + (format!("no implementation for `{} | {}`", lhs_ty, rhs_ty), + Some("std::ops::BitOr")) + }, + hir::BinOpKind::Shl => { + (format!("no implementation for `{} << {}", lhs_ty, rhs_ty), + Some("std::ops::Shl")) + }, + hir::BinOpKind::Shr => { + (format!("no implementation for `{} << {}", lhs_ty, rhs_ty), + Some("std::ops::Shr")) + }, + _ => (format!("binary operation `{}` cannot be applied to type `{}`", op.node.as_str(), lhs_ty), None) + }; 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); + "{}", message.as_str()); let mut involves_fn = false; if !lhs_expr.span.eq(&rhs_expr.span) { @@ -382,25 +423,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } } - let missing_trait = match op.node { - hir::BinOpKind::Add => Some("std::ops::Add"), - hir::BinOpKind::Sub => Some("std::ops::Sub"), - hir::BinOpKind::Mul => Some("std::ops::Mul"), - hir::BinOpKind::Div => Some("std::ops::Div"), - hir::BinOpKind::Rem => Some("std::ops::Rem"), - hir::BinOpKind::BitAnd => Some("std::ops::BitAnd"), - hir::BinOpKind::BitXor => Some("std::ops::BitXor"), - hir::BinOpKind::BitOr => Some("std::ops::BitOr"), - hir::BinOpKind::Shl => Some("std::ops::Shl"), - hir::BinOpKind::Shr => Some("std::ops::Shr"), - hir::BinOpKind::Eq | - hir::BinOpKind::Ne => Some("std::cmp::PartialEq"), - hir::BinOpKind::Lt | - hir::BinOpKind::Le | - hir::BinOpKind::Gt | - hir::BinOpKind::Ge => Some("std::cmp::PartialOrd"), - _ => None - }; if let Some(missing_trait) = missing_trait { if op.node == hir::BinOpKind::Add && self.check_str_addition( From 8fb729ccda8abcc43d71eafc38ab0feccc93e886 Mon Sep 17 00:00:00 2001 From: LeSeulArtichaut Date: Tue, 10 Dec 2019 10:39:09 +0100 Subject: [PATCH 2/7] Comply to tidy checks --- src/librustc_typeck/check/op.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index e85bf0797c832..588726016d9ef 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -375,7 +375,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { (format!("no implementation for `{} << {}", lhs_ty, rhs_ty), Some("std::ops::Shr")) }, - _ => (format!("binary operation `{}` cannot be applied to type `{}`", op.node.as_str(), lhs_ty), None) + _ => (format!( + "binary operation `{}` cannot be applied to type `{}`", + op.node.as_str(), lhs_ty), + None) }; let mut err = struct_span_err!(self.tcx.sess, op.span, E0369, "{}", message.as_str()); From cf8c0d7a04eed6a1a5c245331dbcbf8e8a26ac8b Mon Sep 17 00:00:00 2001 From: LeSeulArtichaut Date: Tue, 10 Dec 2019 21:52:36 +0100 Subject: [PATCH 3/7] I have to revise left and right --- src/librustc_typeck/check/op.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index 588726016d9ef..2e56048fc0eb4 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -372,7 +372,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { Some("std::ops::Shl")) }, hir::BinOpKind::Shr => { - (format!("no implementation for `{} << {}", lhs_ty, rhs_ty), + (format!("no implementation for `{} >> {}", lhs_ty, rhs_ty), Some("std::ops::Shr")) }, _ => (format!( From 3bd46f1aecbcd3b7e57bd78c4dda72c076368f1f Mon Sep 17 00:00:00 2001 From: LeSeulArtichaut Date: Tue, 10 Dec 2019 22:03:13 +0100 Subject: [PATCH 4/7] Update UI test expectations --- src/test/ui/autoderef-full-lval.stderr | 4 +-- src/test/ui/binary-op-on-double-ref.stderr | 2 +- src/test/ui/binop/binop-bitxor-str.stderr | 2 +- src/test/ui/binop/binop-mul-bool.stderr | 2 +- src/test/ui/binop/binop-typeck.stderr | 2 +- src/test/ui/for/for-loop-type-error.stderr | 2 +- src/test/ui/issues/issue-14915.stderr | 2 +- src/test/ui/issues/issue-24363.stderr | 2 +- src/test/ui/issues/issue-28837.stderr | 18 ++++++------- src/test/ui/issues/issue-31076.stderr | 4 +-- src/test/ui/issues/issue-35668.stderr | 2 +- src/test/ui/issues/issue-3820.stderr | 2 +- src/test/ui/issues/issue-40610.stderr | 2 +- src/test/ui/issues/issue-41394.stderr | 2 +- src/test/ui/issues/issue-47377.stderr | 2 +- src/test/ui/issues/issue-47380.stderr | 2 +- .../or-patterns-syntactic-fail.stderr | 2 +- src/test/ui/pattern/pattern-tyvar-2.stderr | 2 +- src/test/ui/span/issue-39018.stderr | 26 +++++++++---------- .../ui/str/str-concat-on-double-ref.stderr | 2 +- ...non-1-width-unicode-multiline-label.stderr | 2 +- .../trait-resolution-in-overloaded-op.stderr | 2 +- .../type/type-check/missing_trait_impl.stderr | 2 +- src/test/ui/vec/vec-res-add.stderr | 2 +- 24 files changed, 46 insertions(+), 46 deletions(-) diff --git a/src/test/ui/autoderef-full-lval.stderr b/src/test/ui/autoderef-full-lval.stderr index c9f3e8b2e26c5..e2870ef8062d3 100644 --- a/src/test/ui/autoderef-full-lval.stderr +++ b/src/test/ui/autoderef-full-lval.stderr @@ -1,4 +1,4 @@ -error[E0369]: binary operation `+` cannot be applied to type `std::boxed::Box` +error[E0369]: cannot add `std::boxed::Box` to `std::boxed::Box` --> $DIR/autoderef-full-lval.rs:15:24 | LL | let z: isize = a.x + b.y; @@ -8,7 +8,7 @@ LL | let z: isize = a.x + b.y; | = note: an implementation of `std::ops::Add` might be missing for `std::boxed::Box` -error[E0369]: binary operation `+` cannot be applied to type `std::boxed::Box` +error[E0369]: cannot add `std::boxed::Box` to `std::boxed::Box` --> $DIR/autoderef-full-lval.rs:21:33 | LL | let answer: isize = forty.a + two.a; diff --git a/src/test/ui/binary-op-on-double-ref.stderr b/src/test/ui/binary-op-on-double-ref.stderr index d036f06a8c7d0..6c405333ec681 100644 --- a/src/test/ui/binary-op-on-double-ref.stderr +++ b/src/test/ui/binary-op-on-double-ref.stderr @@ -1,4 +1,4 @@ -error[E0369]: binary operation `%` cannot be applied to type `&&{integer}` +error[E0369]: cannot mod `&&{integer}` by `{integer}` --> $DIR/binary-op-on-double-ref.rs:4:11 | LL | x % 2 == 0 diff --git a/src/test/ui/binop/binop-bitxor-str.stderr b/src/test/ui/binop/binop-bitxor-str.stderr index 9e8992235edd1..9a0d301d86356 100644 --- a/src/test/ui/binop/binop-bitxor-str.stderr +++ b/src/test/ui/binop/binop-bitxor-str.stderr @@ -1,4 +1,4 @@ -error[E0369]: binary operation `^` cannot be applied to type `std::string::String` +error[E0369]: no implementation for `std::string::String ^ std::string::String` --> $DIR/binop-bitxor-str.rs:3:37 | LL | fn main() { let x = "a".to_string() ^ "b".to_string(); } diff --git a/src/test/ui/binop/binop-mul-bool.stderr b/src/test/ui/binop/binop-mul-bool.stderr index 92e14bccccd58..ade2202558934 100644 --- a/src/test/ui/binop/binop-mul-bool.stderr +++ b/src/test/ui/binop/binop-mul-bool.stderr @@ -1,4 +1,4 @@ -error[E0369]: binary operation `*` cannot be applied to type `bool` +error[E0369]: cannot multiply `bool` to `bool` --> $DIR/binop-mul-bool.rs:3:26 | LL | fn main() { let x = true * false; } diff --git a/src/test/ui/binop/binop-typeck.stderr b/src/test/ui/binop/binop-typeck.stderr index d33cff313e7f9..ebf82079ef2e8 100644 --- a/src/test/ui/binop/binop-typeck.stderr +++ b/src/test/ui/binop/binop-typeck.stderr @@ -1,4 +1,4 @@ -error[E0369]: binary operation `+` cannot be applied to type `bool` +error[E0369]: cannot add `{integer}` to `bool` --> $DIR/binop-typeck.rs:6:15 | LL | let z = x + y; diff --git a/src/test/ui/for/for-loop-type-error.stderr b/src/test/ui/for/for-loop-type-error.stderr index 588e7a0ed339e..0ed26384f4064 100644 --- a/src/test/ui/for/for-loop-type-error.stderr +++ b/src/test/ui/for/for-loop-type-error.stderr @@ -1,4 +1,4 @@ -error[E0369]: binary operation `+` cannot be applied to type `()` +error[E0369]: cannot add `()` to `()` --> $DIR/for-loop-type-error.rs:2:16 | LL | let x = () + (); diff --git a/src/test/ui/issues/issue-14915.stderr b/src/test/ui/issues/issue-14915.stderr index e8de44320da9c..00b9909af5979 100644 --- a/src/test/ui/issues/issue-14915.stderr +++ b/src/test/ui/issues/issue-14915.stderr @@ -1,4 +1,4 @@ -error[E0369]: binary operation `+` cannot be applied to type `std::boxed::Box` +error[E0369]: cannot add `{integer}` to `std::boxed::Box` --> $DIR/issue-14915.rs:6:22 | LL | println!("{}", x + 1); diff --git a/src/test/ui/issues/issue-24363.stderr b/src/test/ui/issues/issue-24363.stderr index 50d65e09bb1cc..a60fb24ec1209 100644 --- a/src/test/ui/issues/issue-24363.stderr +++ b/src/test/ui/issues/issue-24363.stderr @@ -4,7 +4,7 @@ error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields LL | 1.create_a_type_error[ | ^^^^^^^^^^^^^^^^^^^ -error[E0369]: binary operation `+` cannot be applied to type `()` +error[E0369]: cannot add `()` to `()` --> $DIR/issue-24363.rs:3:11 | LL | ()+() diff --git a/src/test/ui/issues/issue-28837.stderr b/src/test/ui/issues/issue-28837.stderr index ac2a9f2203d5a..92470f89805f3 100644 --- a/src/test/ui/issues/issue-28837.stderr +++ b/src/test/ui/issues/issue-28837.stderr @@ -1,4 +1,4 @@ -error[E0369]: binary operation `+` cannot be applied to type `A` +error[E0369]: cannot add `A` to `A` --> $DIR/issue-28837.rs:6:7 | LL | a + a; @@ -8,7 +8,7 @@ LL | a + a; | = note: an implementation of `std::ops::Add` might be missing for `A` -error[E0369]: binary operation `-` cannot be applied to type `A` +error[E0369]: cannot substract `A` from `A` --> $DIR/issue-28837.rs:8:7 | LL | a - a; @@ -18,7 +18,7 @@ LL | a - a; | = note: an implementation of `std::ops::Sub` might be missing for `A` -error[E0369]: binary operation `*` cannot be applied to type `A` +error[E0369]: cannot multiply `A` to `A` --> $DIR/issue-28837.rs:10:7 | LL | a * a; @@ -28,7 +28,7 @@ LL | a * a; | = note: an implementation of `std::ops::Mul` might be missing for `A` -error[E0369]: binary operation `/` cannot be applied to type `A` +error[E0369]: cannot divide `A` by `A` --> $DIR/issue-28837.rs:12:7 | LL | a / a; @@ -38,7 +38,7 @@ LL | a / a; | = note: an implementation of `std::ops::Div` might be missing for `A` -error[E0369]: binary operation `%` cannot be applied to type `A` +error[E0369]: cannot mod `A` by `A` --> $DIR/issue-28837.rs:14:7 | LL | a % a; @@ -48,7 +48,7 @@ LL | a % a; | = note: an implementation of `std::ops::Rem` might be missing for `A` -error[E0369]: binary operation `&` cannot be applied to type `A` +error[E0369]: no implementation for `A & A` --> $DIR/issue-28837.rs:16:7 | LL | a & a; @@ -58,7 +58,7 @@ LL | a & a; | = note: an implementation of `std::ops::BitAnd` might be missing for `A` -error[E0369]: binary operation `|` cannot be applied to type `A` +error[E0369]: no implementation for `A | A` --> $DIR/issue-28837.rs:18:7 | LL | a | a; @@ -68,7 +68,7 @@ LL | a | a; | = note: an implementation of `std::ops::BitOr` might be missing for `A` -error[E0369]: binary operation `<<` cannot be applied to type `A` +error[E0369]: no implementation for `A << A --> $DIR/issue-28837.rs:20:7 | LL | a << a; @@ -78,7 +78,7 @@ LL | a << a; | = note: an implementation of `std::ops::Shl` might be missing for `A` -error[E0369]: binary operation `>>` cannot be applied to type `A` +error[E0369]: no implementation for `A >> A --> $DIR/issue-28837.rs:22:7 | LL | a >> a; diff --git a/src/test/ui/issues/issue-31076.stderr b/src/test/ui/issues/issue-31076.stderr index 60a3be1c36b75..5d65734cd230a 100644 --- a/src/test/ui/issues/issue-31076.stderr +++ b/src/test/ui/issues/issue-31076.stderr @@ -1,4 +1,4 @@ -error[E0369]: binary operation `+` cannot be applied to type `{integer}` +error[E0369]: cannot add `{integer}` to `{integer}` --> $DIR/issue-31076.rs:13:15 | LL | let x = 5 + 6; @@ -8,7 +8,7 @@ LL | let x = 5 + 6; | = note: an implementation of `std::ops::Add` might be missing for `{integer}` -error[E0369]: binary operation `+` cannot be applied to type `i32` +error[E0369]: cannot add `i32` to `i32` --> $DIR/issue-31076.rs:15:18 | LL | let y = 5i32 + 6i32; diff --git a/src/test/ui/issues/issue-35668.stderr b/src/test/ui/issues/issue-35668.stderr index 59ca874bd2018..9d5796a5eefed 100644 --- a/src/test/ui/issues/issue-35668.stderr +++ b/src/test/ui/issues/issue-35668.stderr @@ -1,4 +1,4 @@ -error[E0369]: binary operation `*` cannot be applied to type `&T` +error[E0369]: cannot multiply `&T` to `&T` --> $DIR/issue-35668.rs:2:23 | LL | a.iter().map(|a| a*a) diff --git a/src/test/ui/issues/issue-3820.stderr b/src/test/ui/issues/issue-3820.stderr index 35eceb3b3c637..8cc768237a948 100644 --- a/src/test/ui/issues/issue-3820.stderr +++ b/src/test/ui/issues/issue-3820.stderr @@ -1,4 +1,4 @@ -error[E0369]: binary operation `*` cannot be applied to type `Thing` +error[E0369]: cannot multiply `{integer}` to `Thing` --> $DIR/issue-3820.rs:14:15 | LL | let w = u * 3; diff --git a/src/test/ui/issues/issue-40610.stderr b/src/test/ui/issues/issue-40610.stderr index 9d5775919296d..95f45c168e122 100644 --- a/src/test/ui/issues/issue-40610.stderr +++ b/src/test/ui/issues/issue-40610.stderr @@ -1,4 +1,4 @@ -error[E0369]: binary operation `+` cannot be applied to type `()` +error[E0369]: cannot add `()` to `()` --> $DIR/issue-40610.rs:4:8 | LL | () + f(&[1.0]); diff --git a/src/test/ui/issues/issue-41394.stderr b/src/test/ui/issues/issue-41394.stderr index c8437ab189d8d..3f60ea4bbf73a 100644 --- a/src/test/ui/issues/issue-41394.stderr +++ b/src/test/ui/issues/issue-41394.stderr @@ -1,4 +1,4 @@ -error[E0369]: binary operation `+` cannot be applied to type `&str` +error[E0369]: cannot add `{integer}` to `&str` --> $DIR/issue-41394.rs:2:12 | LL | A = "" + 1 diff --git a/src/test/ui/issues/issue-47377.stderr b/src/test/ui/issues/issue-47377.stderr index 3460c1dae2299..5f785679c5587 100644 --- a/src/test/ui/issues/issue-47377.stderr +++ b/src/test/ui/issues/issue-47377.stderr @@ -1,4 +1,4 @@ -error[E0369]: binary operation `+` cannot be applied to type `&str` +error[E0369]: cannot add `&str` to `&str` --> $DIR/issue-47377.rs:4:14 | LL | let _a = b + ", World!"; diff --git a/src/test/ui/issues/issue-47380.stderr b/src/test/ui/issues/issue-47380.stderr index f334dcbd916ac..216e32ddae411 100644 --- a/src/test/ui/issues/issue-47380.stderr +++ b/src/test/ui/issues/issue-47380.stderr @@ -1,4 +1,4 @@ -error[E0369]: binary operation `+` cannot be applied to type `&str` +error[E0369]: cannot add `&str` to `&str` --> $DIR/issue-47380.rs:3:35 | LL | println!("🦀🦀🦀🦀🦀"); let _a = b + ", World!"; diff --git a/src/test/ui/or-patterns/or-patterns-syntactic-fail.stderr b/src/test/ui/or-patterns/or-patterns-syntactic-fail.stderr index b6ff39d64d6db..e77d92e8b07d9 100644 --- a/src/test/ui/or-patterns/or-patterns-syntactic-fail.stderr +++ b/src/test/ui/or-patterns/or-patterns-syntactic-fail.stderr @@ -104,7 +104,7 @@ LL | #![feature(or_patterns)] | = note: `#[warn(incomplete_features)]` on by default -error[E0369]: binary operation `|` cannot be applied to type `E` +error[E0369]: no implementation for `E | ()` --> $DIR/or-patterns-syntactic-fail.rs:24:22 | LL | let _ = |A | B: E| (); diff --git a/src/test/ui/pattern/pattern-tyvar-2.stderr b/src/test/ui/pattern/pattern-tyvar-2.stderr index 7c6ae499cbb07..bb3e61017d487 100644 --- a/src/test/ui/pattern/pattern-tyvar-2.stderr +++ b/src/test/ui/pattern/pattern-tyvar-2.stderr @@ -1,4 +1,4 @@ -error[E0369]: binary operation `*` cannot be applied to type `std::vec::Vec` +error[E0369]: cannot multiply `{integer}` to `std::vec::Vec` --> $DIR/pattern-tyvar-2.rs:3:71 | LL | fn foo(t: Bar) -> isize { match t { Bar::T1(_, Some(x)) => { return x * 3; } _ => { panic!(); } } } diff --git a/src/test/ui/span/issue-39018.stderr b/src/test/ui/span/issue-39018.stderr index 9637d1d82ec7e..8a32561bd01db 100644 --- a/src/test/ui/span/issue-39018.stderr +++ b/src/test/ui/span/issue-39018.stderr @@ -1,4 +1,4 @@ -error[E0369]: binary operation `+` cannot be applied to type `&str` +error[E0369]: cannot add `&str` to `&str` --> $DIR/issue-39018.rs:2:22 | LL | let x = "Hello " + "World!"; @@ -12,7 +12,7 @@ help: `to_owned()` can be used to create an owned `String` from a string referen LL | let x = "Hello ".to_owned() + "World!"; | ^^^^^^^^^^^^^^^^^^^ -error[E0369]: binary operation `+` cannot be applied to type `World` +error[E0369]: cannot add `World` to `World` --> $DIR/issue-39018.rs:8:26 | LL | let y = World::Hello + World::Goodbye; @@ -22,7 +22,7 @@ LL | let y = World::Hello + World::Goodbye; | = note: an implementation of `std::ops::Add` might be missing for `World` -error[E0369]: binary operation `+` cannot be applied to type `&str` +error[E0369]: cannot add `std::string::String` to `&str` --> $DIR/issue-39018.rs:11:22 | LL | let x = "Hello " + "World!".to_owned(); @@ -36,7 +36,7 @@ help: `to_owned()` can be used to create an owned `String` from a string referen LL | let x = "Hello ".to_owned() + &"World!".to_owned(); | ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ -error[E0369]: binary operation `+` cannot be applied to type `&std::string::String` +error[E0369]: cannot add `&std::string::String` to `&std::string::String` --> $DIR/issue-39018.rs:26:16 | LL | let _ = &a + &b; @@ -50,7 +50,7 @@ help: String concatenation appends the string on the right to the string on the LL | let _ = a + &b; | ^ -error[E0369]: binary operation `+` cannot be applied to type `&std::string::String` +error[E0369]: cannot add `std::string::String` to `&std::string::String` --> $DIR/issue-39018.rs:27:16 | LL | let _ = &a + b; @@ -73,7 +73,7 @@ LL | let _ = a + b; | expected `&str`, found struct `std::string::String` | help: consider borrowing here: `&b` -error[E0369]: binary operation `+` cannot be applied to type `&std::string::String` +error[E0369]: cannot add `std::string::String` to `&std::string::String` --> $DIR/issue-39018.rs:30:15 | LL | let _ = e + b; @@ -87,7 +87,7 @@ help: `to_owned()` can be used to create an owned `String` from a string referen LL | let _ = e.to_owned() + &b; | ^^^^^^^^^^^^ ^^ -error[E0369]: binary operation `+` cannot be applied to type `&std::string::String` +error[E0369]: cannot add `&std::string::String` to `&std::string::String` --> $DIR/issue-39018.rs:31:15 | LL | let _ = e + &b; @@ -101,7 +101,7 @@ help: `to_owned()` can be used to create an owned `String` from a string referen LL | let _ = e.to_owned() + &b; | ^^^^^^^^^^^^ -error[E0369]: binary operation `+` cannot be applied to type `&std::string::String` +error[E0369]: cannot add `&str` to `&std::string::String` --> $DIR/issue-39018.rs:32:15 | LL | let _ = e + d; @@ -115,7 +115,7 @@ help: `to_owned()` can be used to create an owned `String` from a string referen LL | let _ = e.to_owned() + d; | ^^^^^^^^^^^^ -error[E0369]: binary operation `+` cannot be applied to type `&std::string::String` +error[E0369]: cannot add `&&str` to `&std::string::String` --> $DIR/issue-39018.rs:33:15 | LL | let _ = e + &d; @@ -129,7 +129,7 @@ help: `to_owned()` can be used to create an owned `String` from a string referen LL | let _ = e.to_owned() + &d; | ^^^^^^^^^^^^ -error[E0369]: binary operation `+` cannot be applied to type `&&str` +error[E0369]: cannot add `&&str` to `&&str` --> $DIR/issue-39018.rs:34:16 | LL | let _ = &c + &d; @@ -139,7 +139,7 @@ LL | let _ = &c + &d; | = note: an implementation of `std::ops::Add` might be missing for `&&str` -error[E0369]: binary operation `+` cannot be applied to type `&&str` +error[E0369]: cannot add `&str` to `&&str` --> $DIR/issue-39018.rs:35:16 | LL | let _ = &c + d; @@ -149,7 +149,7 @@ LL | let _ = &c + d; | = note: an implementation of `std::ops::Add` might be missing for `&&str` -error[E0369]: binary operation `+` cannot be applied to type `&str` +error[E0369]: cannot add `&&str` to `&str` --> $DIR/issue-39018.rs:36:15 | LL | let _ = c + &d; @@ -163,7 +163,7 @@ help: `to_owned()` can be used to create an owned `String` from a string referen LL | let _ = c.to_owned() + &d; | ^^^^^^^^^^^^ -error[E0369]: binary operation `+` cannot be applied to type `&str` +error[E0369]: cannot add `&str` to `&str` --> $DIR/issue-39018.rs:37:15 | LL | let _ = c + d; diff --git a/src/test/ui/str/str-concat-on-double-ref.stderr b/src/test/ui/str/str-concat-on-double-ref.stderr index d193955af4ba6..d77e0d8f242d7 100644 --- a/src/test/ui/str/str-concat-on-double-ref.stderr +++ b/src/test/ui/str/str-concat-on-double-ref.stderr @@ -1,4 +1,4 @@ -error[E0369]: binary operation `+` cannot be applied to type `&std::string::String` +error[E0369]: cannot add `&str` to `&std::string::String` --> $DIR/str-concat-on-double-ref.rs:4:15 | LL | let c = a + b; diff --git a/src/test/ui/terminal-width/non-1-width-unicode-multiline-label.stderr b/src/test/ui/terminal-width/non-1-width-unicode-multiline-label.stderr index 9f0f990670f2d..69daa93412a3a 100644 --- a/src/test/ui/terminal-width/non-1-width-unicode-multiline-label.stderr +++ b/src/test/ui/terminal-width/non-1-width-unicode-multiline-label.stderr @@ -1,4 +1,4 @@ -error[E0369]: binary operation `+` cannot be applied to type `&str` +error[E0369]: cannot add `&str` to `&str` --> $DIR/non-1-width-unicode-multiline-label.rs:5:260 | LL | ...ཽཾཿ྄ཱྀྀྂྃ྅྆྇ྈྉྊྋྌྍྎྏྐྑྒྒྷྔྕྖྗ྘ྙྚྛྜྜྷྞྟྠྡྡྷྣྤྥྦྦྷྨྩྪྫྫྷྭྮྯྰྱྲླྴྵྶྷྸྐྵྺྻྼ྽྾྿࿀࿁࿂࿃࿄࿅࿆࿇...࿋࿌࿍࿎࿏࿐࿑࿒࿓࿔࿕࿖࿗࿘࿙࿚"; let _a = unicode_is_fun + " really fun!"; diff --git a/src/test/ui/traits/trait-resolution-in-overloaded-op.stderr b/src/test/ui/traits/trait-resolution-in-overloaded-op.stderr index d11562e2a001b..8d7ba36c665b3 100644 --- a/src/test/ui/traits/trait-resolution-in-overloaded-op.stderr +++ b/src/test/ui/traits/trait-resolution-in-overloaded-op.stderr @@ -1,4 +1,4 @@ -error[E0369]: binary operation `*` cannot be applied to type `&T` +error[E0369]: cannot multiply `f64` to `&T` --> $DIR/trait-resolution-in-overloaded-op.rs:8:7 | LL | a * b diff --git a/src/test/ui/type/type-check/missing_trait_impl.stderr b/src/test/ui/type/type-check/missing_trait_impl.stderr index 2a158ab8564f3..7186d6a542dc9 100644 --- a/src/test/ui/type/type-check/missing_trait_impl.stderr +++ b/src/test/ui/type/type-check/missing_trait_impl.stderr @@ -1,4 +1,4 @@ -error[E0369]: binary operation `+` cannot be applied to type `T` +error[E0369]: cannot add `T` to `T` --> $DIR/missing_trait_impl.rs:5:15 | LL | let z = x + y; diff --git a/src/test/ui/vec/vec-res-add.stderr b/src/test/ui/vec/vec-res-add.stderr index 78b70f09e9005..1cc12a222e50b 100644 --- a/src/test/ui/vec/vec-res-add.stderr +++ b/src/test/ui/vec/vec-res-add.stderr @@ -1,4 +1,4 @@ -error[E0369]: binary operation `+` cannot be applied to type `std::vec::Vec` +error[E0369]: cannot add `std::vec::Vec` to `std::vec::Vec` --> $DIR/vec-res-add.rs:16:15 | LL | let k = i + j; From 27810e246c89777f39441d6cc050e540cb2e54e0 Mon Sep 17 00:00:00 2001 From: LeSeulArtichaut Date: Tue, 10 Dec 2019 22:51:47 +0100 Subject: [PATCH 5/7] Restore note for PartialOrd and PartialEq --- src/librustc_typeck/check/op.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index 2e56048fc0eb4..5fa6bdf2ee387 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -375,6 +375,22 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { (format!("no implementation for `{} >> {}", lhs_ty, rhs_ty), Some("std::ops::Shr")) }, + hir::BinOpKind::Eq | + hir::BinOpKind::Ne => { + (format!( + "binary operation `{}` cannot be applied to type `{}`", + op.node.as_str(), lhs_ty), + Some("std::cmp::PartialEq")) + }, + hir::BinOpKind::Lt | + hir::BinOpKind::Le | + hir::BinOpKind::Gt | + hir::BinOpKind::Ge => { + (format!( + "binary operation `{}` cannot be applied to type `{}`", + op.node.as_str(), lhs_ty), + Some("std::cmp::PartialOrd")) + } _ => (format!( "binary operation `{}` cannot be applied to type `{}`", op.node.as_str(), lhs_ty), From eac6fac10b572d4912d0bcd455c12909f63914b7 Mon Sep 17 00:00:00 2001 From: LeSeulArtichaut Date: Wed, 11 Dec 2019 23:11:32 +0100 Subject: [PATCH 6/7] Update tests --- src/test/ui/autoderef-full-lval.rs | 4 +-- src/test/ui/binary-op-on-double-ref.rs | 2 +- src/test/ui/binop/binop-bitxor-str.rs | 2 +- src/test/ui/binop/binop-mul-bool.rs | 2 +- src/test/ui/binop/binop-typeck.rs | 2 +- src/test/ui/for/for-loop-type-error.rs | 2 +- src/test/ui/issues/issue-14915.rs | 2 +- src/test/ui/issues/issue-24363.rs | 2 +- src/test/ui/issues/issue-28837.rs | 18 ++++++------- src/test/ui/issues/issue-31076.rs | 4 +-- src/test/ui/issues/issue-35668.rs | 2 +- src/test/ui/issues/issue-3820.rs | 2 +- src/test/ui/issues/issue-40610.rs | 2 +- src/test/ui/issues/issue-41394.rs | 2 +- .../or-patterns/or-patterns-syntactic-fail.rs | 2 +- src/test/ui/pattern/pattern-tyvar-2.rs | 2 +- src/test/ui/span/issue-39018.rs | 26 +++++++++---------- src/test/ui/str/str-concat-on-double-ref.rs | 2 +- .../non-1-width-unicode-multiline-label.rs | 2 +- .../trait-resolution-in-overloaded-op.rs | 2 +- .../ui/type/type-check/missing_trait_impl.rs | 2 +- src/test/ui/vec/vec-res-add.rs | 2 +- 22 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/test/ui/autoderef-full-lval.rs b/src/test/ui/autoderef-full-lval.rs index db09d036ad3b8..4bef1012e33de 100644 --- a/src/test/ui/autoderef-full-lval.rs +++ b/src/test/ui/autoderef-full-lval.rs @@ -13,13 +13,13 @@ fn main() { let a: Clam = Clam{x: box 1, y: box 2}; let b: Clam = Clam{x: box 10, y: box 20}; let z: isize = a.x + b.y; - //~^ ERROR binary operation `+` cannot be applied to type `std::boxed::Box` + //~^ ERROR cannot add `std::boxed::Box` to `std::boxed::Box` println!("{}", z); assert_eq!(z, 21); let forty: Fish = Fish{a: box 40}; let two: Fish = Fish{a: box 2}; let answer: isize = forty.a + two.a; - //~^ ERROR binary operation `+` cannot be applied to type `std::boxed::Box` + //~^ ERROR cannot add `std::boxed::Box` to `std::boxed::Box` println!("{}", answer); assert_eq!(answer, 42); } diff --git a/src/test/ui/binary-op-on-double-ref.rs b/src/test/ui/binary-op-on-double-ref.rs index 6490cc7fe5689..67e01b9327db1 100644 --- a/src/test/ui/binary-op-on-double-ref.rs +++ b/src/test/ui/binary-op-on-double-ref.rs @@ -2,7 +2,7 @@ fn main() { let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9]; let vr = v.iter().filter(|x| { x % 2 == 0 - //~^ ERROR binary operation `%` cannot be applied to type `&&{integer}` + //~^ ERROR cannot mod `&&{integer}` by `{integer}` }); println!("{:?}", vr); } diff --git a/src/test/ui/binop/binop-bitxor-str.rs b/src/test/ui/binop/binop-bitxor-str.rs index 6021c344dfb65..e98ea4df97def 100644 --- a/src/test/ui/binop/binop-bitxor-str.rs +++ b/src/test/ui/binop/binop-bitxor-str.rs @@ -1,3 +1,3 @@ -// error-pattern:`^` cannot be applied to type `std::string::String` +// error-pattern:no implementation for `std::string::String ^ std::string::String` fn main() { let x = "a".to_string() ^ "b".to_string(); } diff --git a/src/test/ui/binop/binop-mul-bool.rs b/src/test/ui/binop/binop-mul-bool.rs index 3d5349ba880fc..27b2f8bb3ff30 100644 --- a/src/test/ui/binop/binop-mul-bool.rs +++ b/src/test/ui/binop/binop-mul-bool.rs @@ -1,3 +1,3 @@ -// error-pattern:`*` cannot be applied to type `bool` +// error-pattern:cannot multiply `bool` to `bool` fn main() { let x = true * false; } diff --git a/src/test/ui/binop/binop-typeck.rs b/src/test/ui/binop/binop-typeck.rs index e1185cfba266c..812fe95db4e57 100644 --- a/src/test/ui/binop/binop-typeck.rs +++ b/src/test/ui/binop/binop-typeck.rs @@ -4,5 +4,5 @@ fn main() { let x = true; let y = 1; let z = x + y; - //~^ ERROR binary operation `+` cannot be applied to type `bool` + //~^ ERROR cannot add `{integer}` to `bool` } diff --git a/src/test/ui/for/for-loop-type-error.rs b/src/test/ui/for/for-loop-type-error.rs index 879fa47549e98..8d9fc20f0d0d6 100644 --- a/src/test/ui/for/for-loop-type-error.rs +++ b/src/test/ui/for/for-loop-type-error.rs @@ -1,5 +1,5 @@ pub fn main() { - let x = () + (); //~ ERROR binary operation + let x = () + (); //~ ERROR cannot add `()` to `()` // this shouldn't have a flow-on error: for _ in x {} diff --git a/src/test/ui/issues/issue-14915.rs b/src/test/ui/issues/issue-14915.rs index 294533f0cbb75..4acb51a4e50fa 100644 --- a/src/test/ui/issues/issue-14915.rs +++ b/src/test/ui/issues/issue-14915.rs @@ -4,5 +4,5 @@ fn main() { let x: Box = box 0; println!("{}", x + 1); - //~^ ERROR binary operation `+` cannot be applied to type `std::boxed::Box` + //~^ ERROR cannot add `{integer}` to `std::boxed::Box` } diff --git a/src/test/ui/issues/issue-24363.rs b/src/test/ui/issues/issue-24363.rs index a5b45f13e74ad..34726fba9c66a 100644 --- a/src/test/ui/issues/issue-24363.rs +++ b/src/test/ui/issues/issue-24363.rs @@ -1,6 +1,6 @@ fn main() { 1.create_a_type_error[ //~ `{integer}` is a primitive type and therefore doesn't have fields - ()+() //~ ERROR binary operation `+` cannot be applied + ()+() //~ ERROR cannot add // ^ ensure that we typeck the inner expression ^ ]; } diff --git a/src/test/ui/issues/issue-28837.rs b/src/test/ui/issues/issue-28837.rs index 114473f3acfec..438a4c521b198 100644 --- a/src/test/ui/issues/issue-28837.rs +++ b/src/test/ui/issues/issue-28837.rs @@ -3,23 +3,23 @@ struct A; fn main() { let a = A; - a + a; //~ ERROR binary operation `+` cannot be applied to type `A` + a + a; //~ ERROR cannot add `A` to `A` - a - a; //~ ERROR binary operation `-` cannot be applied to type `A` + a - a; //~ ERROR cannot substract `A` from `A` - a * a; //~ ERROR binary operation `*` cannot be applied to type `A` + a * a; //~ ERROR cannot multiply `A` to `A` - a / a; //~ ERROR binary operation `/` cannot be applied to type `A` + a / a; //~ ERROR cannot divide `A` by `A` - a % a; //~ ERROR binary operation `%` cannot be applied to type `A` + a % a; //~ ERROR cannot mod `A` by `A` - a & a; //~ ERROR binary operation `&` cannot be applied to type `A` + a & a; //~ ERROR no implementation for `A & A` - a | a; //~ ERROR binary operation `|` cannot be applied to type `A` + a | a; //~ ERROR no implementation for `A | A` - a << a; //~ ERROR binary operation `<<` cannot be applied to type `A` + a << a; //~ ERROR no implementation for `A << A` - a >> a; //~ ERROR binary operation `>>` cannot be applied to type `A` + a >> a; //~ ERROR no implementation for `A >> A` a == a; //~ ERROR binary operation `==` cannot be applied to type `A` diff --git a/src/test/ui/issues/issue-31076.rs b/src/test/ui/issues/issue-31076.rs index e4531072e9be4..f9c35526ec342 100644 --- a/src/test/ui/issues/issue-31076.rs +++ b/src/test/ui/issues/issue-31076.rs @@ -11,7 +11,7 @@ impl Add for i32 {} fn main() { let x = 5 + 6; - //~^ ERROR binary operation `+` cannot be applied to type `{integer}` + //~^ ERROR cannot add `{integer}` to `{integer}` let y = 5i32 + 6i32; - //~^ ERROR binary operation `+` cannot be applied to type `i32` + //~^ ERROR cannot add `i32` to `i32` } diff --git a/src/test/ui/issues/issue-35668.rs b/src/test/ui/issues/issue-35668.rs index 1b8ada57ed69c..6f6dfb00f86b7 100644 --- a/src/test/ui/issues/issue-35668.rs +++ b/src/test/ui/issues/issue-35668.rs @@ -1,6 +1,6 @@ fn func<'a, T>(a: &'a [T]) -> impl Iterator { a.iter().map(|a| a*a) - //~^ ERROR binary operation `*` cannot be applied to type `&T` + //~^ ERROR cannot multiply `&T` to `&T` } fn main() { diff --git a/src/test/ui/issues/issue-3820.rs b/src/test/ui/issues/issue-3820.rs index fbf60ce278df2..c090654623206 100644 --- a/src/test/ui/issues/issue-3820.rs +++ b/src/test/ui/issues/issue-3820.rs @@ -11,5 +11,5 @@ impl Thing { fn main() { let u = Thing {x: 2}; let _v = u.mul(&3); // This is ok - let w = u * 3; //~ ERROR binary operation `*` cannot be applied to type `Thing` + let w = u * 3; //~ ERROR cannot multiply `{integer}` to `Thing` } diff --git a/src/test/ui/issues/issue-40610.rs b/src/test/ui/issues/issue-40610.rs index 104cf7f54e5f3..c01233605b57c 100644 --- a/src/test/ui/issues/issue-40610.rs +++ b/src/test/ui/issues/issue-40610.rs @@ -2,5 +2,5 @@ fn f(_: &[f32]) {} fn main() { () + f(&[1.0]); - //~^ ERROR binary operation `+` cannot be applied to type `()` + //~^ ERROR cannot add `()` to `()` } diff --git a/src/test/ui/issues/issue-41394.rs b/src/test/ui/issues/issue-41394.rs index 45318f6efb892..64873ac35a002 100644 --- a/src/test/ui/issues/issue-41394.rs +++ b/src/test/ui/issues/issue-41394.rs @@ -1,6 +1,6 @@ enum Foo { A = "" + 1 - //~^ ERROR binary operation `+` cannot be applied to type `&str` + //~^ ERROR cannot add `{integer}` to `&str` } enum Bar { diff --git a/src/test/ui/or-patterns/or-patterns-syntactic-fail.rs b/src/test/ui/or-patterns/or-patterns-syntactic-fail.rs index b676ea851a3ba..ce6836f30f946 100644 --- a/src/test/ui/or-patterns/or-patterns-syntactic-fail.rs +++ b/src/test/ui/or-patterns/or-patterns-syntactic-fail.rs @@ -21,7 +21,7 @@ use E::*; fn no_top_level_or_patterns() { // We do *not* allow or-patterns at the top level of lambdas... - let _ = |A | B: E| (); //~ ERROR binary operation `|` cannot be applied to type `E` + let _ = |A | B: E| (); //~ ERROR no implementation for `E | ()` // -------- This looks like an or-pattern but is in fact `|A| (B: E | ())`. // ...and for now neither do we allow or-patterns at the top level of functions. diff --git a/src/test/ui/pattern/pattern-tyvar-2.rs b/src/test/ui/pattern/pattern-tyvar-2.rs index 9fba9cb876a25..4c6d515b86af3 100644 --- a/src/test/ui/pattern/pattern-tyvar-2.rs +++ b/src/test/ui/pattern/pattern-tyvar-2.rs @@ -1,6 +1,6 @@ enum Bar { T1((), Option>), T2, } fn foo(t: Bar) -> isize { match t { Bar::T1(_, Some(x)) => { return x * 3; } _ => { panic!(); } } } -//~^ ERROR binary operation `*` cannot be applied to +//~^ ERROR cannot multiply `{integer}` to `std::vec::Vec` fn main() { } diff --git a/src/test/ui/span/issue-39018.rs b/src/test/ui/span/issue-39018.rs index a3b1d1d81799f..b6db4008db0d7 100644 --- a/src/test/ui/span/issue-39018.rs +++ b/src/test/ui/span/issue-39018.rs @@ -1,15 +1,15 @@ pub fn main() { let x = "Hello " + "World!"; - //~^ ERROR cannot be applied to type + //~^ ERROR cannot add // Make sure that the span outputs a warning // for not having an implementation for std::ops::Add // that won't output for the above string concatenation let y = World::Hello + World::Goodbye; - //~^ ERROR cannot be applied to type + //~^ ERROR cannot add let x = "Hello " + "World!".to_owned(); - //~^ ERROR cannot be applied to type + //~^ ERROR cannot add } enum World { @@ -23,16 +23,16 @@ fn foo() { let c = ""; let d = ""; let e = &a; - let _ = &a + &b; //~ ERROR binary operation - let _ = &a + b; //~ ERROR binary operation + let _ = &a + &b; //~ ERROR cannot add + let _ = &a + b; //~ ERROR cannot add let _ = a + &b; // ok let _ = a + b; //~ ERROR mismatched types - let _ = e + b; //~ ERROR binary operation - let _ = e + &b; //~ ERROR binary operation - let _ = e + d; //~ ERROR binary operation - let _ = e + &d; //~ ERROR binary operation - let _ = &c + &d; //~ ERROR binary operation - let _ = &c + d; //~ ERROR binary operation - let _ = c + &d; //~ ERROR binary operation - let _ = c + d; //~ ERROR binary operation + let _ = e + b; //~ ERROR cannot add + let _ = e + &b; //~ ERROR cannot add + let _ = e + d; //~ ERROR cannot add + let _ = e + &d; //~ ERROR cannot add + let _ = &c + &d; //~ ERROR cannot add + let _ = &c + d; //~ ERROR cannot add + let _ = c + &d; //~ ERROR cannot add + let _ = c + d; //~ ERROR cannot add } diff --git a/src/test/ui/str/str-concat-on-double-ref.rs b/src/test/ui/str/str-concat-on-double-ref.rs index a671b6e191eeb..23e5f8920622e 100644 --- a/src/test/ui/str/str-concat-on-double-ref.rs +++ b/src/test/ui/str/str-concat-on-double-ref.rs @@ -2,6 +2,6 @@ fn main() { let a: &String = &"1".to_owned(); let b: &str = &"2"; let c = a + b; - //~^ ERROR binary operation `+` cannot be applied to type `&std::string::String` + //~^ ERROR cannot add `&str` to `&std::string::String` println!("{:?}", c); } diff --git a/src/test/ui/terminal-width/non-1-width-unicode-multiline-label.rs b/src/test/ui/terminal-width/non-1-width-unicode-multiline-label.rs index cc94680530cf2..1989ea8863592 100644 --- a/src/test/ui/terminal-width/non-1-width-unicode-multiline-label.rs +++ b/src/test/ui/terminal-width/non-1-width-unicode-multiline-label.rs @@ -3,5 +3,5 @@ fn main() { let unicode_is_fun = "؁‱ஹ௸௵꧄.ဪ꧅⸻𒈙𒐫﷽𒌄𒈟𒍼𒁎𒀱𒌧𒅃 𒈓𒍙𒊎𒄡𒅌𒁏𒀰𒐪𒐩𒈙𒐫𪚥"; let _ = "ༀ༁༂༃༄༅༆༇༈༉༊་༌།༎༏༐༑༒༓༔༕༖༗༘༙༚༛༜༝༞༟༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳༴༵༶༷༸༹༺༻༼༽༾༿ཀཁགགྷངཅཆཇ཈ཉཊཋཌཌྷཎཏཐདདྷནཔཕབབྷམཙཚཛཛྷཝཞཟའཡརལཤཥསཧཨཀྵཪཫཬ཭཮཯཰ཱཱཱིིུུྲྀཷླྀཹེཻོཽཾཿ྄ཱྀྀྂྃ྅྆྇ྈྉྊྋྌྍྎྏྐྑྒྒྷྔྕྖྗ྘ྙྚྛྜྜྷྞྟྠྡྡྷྣྤྥྦྦྷྨྩྪྫྫྷྭྮྯྰྱྲླྴྵྶྷྸྐྵྺྻྼ྽྾྿࿀࿁࿂࿃࿄࿅࿆࿇࿈࿉࿊࿋࿌࿍࿎࿏࿐࿑࿒࿓࿔࿕࿖࿗࿘࿙࿚"; let _a = unicode_is_fun + " really fun!"; - //~^ ERROR binary operation `+` cannot be applied to type `&str` + //~^ ERROR cannot add `&str` to `&str` } diff --git a/src/test/ui/traits/trait-resolution-in-overloaded-op.rs b/src/test/ui/traits/trait-resolution-in-overloaded-op.rs index 96f81a21a3bc1..286776985168f 100644 --- a/src/test/ui/traits/trait-resolution-in-overloaded-op.rs +++ b/src/test/ui/traits/trait-resolution-in-overloaded-op.rs @@ -5,7 +5,7 @@ trait MyMul { } fn foo>(a: &T, b: f64) -> f64 { - a * b //~ ERROR binary operation `*` cannot be applied to type `&T` + a * b //~ ERROR cannot multiply `f64` to `&T` } fn main() {} diff --git a/src/test/ui/type/type-check/missing_trait_impl.rs b/src/test/ui/type/type-check/missing_trait_impl.rs index dcca96b509b16..f61ada3f63ff9 100644 --- a/src/test/ui/type/type-check/missing_trait_impl.rs +++ b/src/test/ui/type/type-check/missing_trait_impl.rs @@ -2,7 +2,7 @@ fn main() { } fn foo(x: T, y: T) { - let z = x + y; //~ ERROR binary operation `+` cannot be applied to type `T` + let z = x + y; //~ ERROR cannot add `T` to `T` } fn bar(x: T) { diff --git a/src/test/ui/vec/vec-res-add.rs b/src/test/ui/vec/vec-res-add.rs index ea2aa6cda240a..4785178fb2575 100644 --- a/src/test/ui/vec/vec-res-add.rs +++ b/src/test/ui/vec/vec-res-add.rs @@ -14,6 +14,6 @@ fn main() { let i = vec![r(0)]; let j = vec![r(1)]; let k = i + j; - //~^ ERROR binary operation `+` cannot be applied to type + //~^ ERROR cannot add `std::vec::Vec` to `std::vec::Vec` println!("{:?}", j); } From e4abcfbd34f759c33da6f6d7e37235c15ede07c2 Mon Sep 17 00:00:00 2001 From: LeSeulArtichaut Date: Thu, 12 Dec 2019 20:55:00 +0100 Subject: [PATCH 7/7] Added missing backticks --- src/librustc_typeck/check/op.rs | 4 ++-- src/test/ui/issues/issue-28837.stderr | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index 5fa6bdf2ee387..4f20a91e4b013 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -368,11 +368,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { Some("std::ops::BitOr")) }, hir::BinOpKind::Shl => { - (format!("no implementation for `{} << {}", lhs_ty, rhs_ty), + (format!("no implementation for `{} << {}`", lhs_ty, rhs_ty), Some("std::ops::Shl")) }, hir::BinOpKind::Shr => { - (format!("no implementation for `{} >> {}", lhs_ty, rhs_ty), + (format!("no implementation for `{} >> {}`", lhs_ty, rhs_ty), Some("std::ops::Shr")) }, hir::BinOpKind::Eq | diff --git a/src/test/ui/issues/issue-28837.stderr b/src/test/ui/issues/issue-28837.stderr index 92470f89805f3..2ef571b576f89 100644 --- a/src/test/ui/issues/issue-28837.stderr +++ b/src/test/ui/issues/issue-28837.stderr @@ -68,7 +68,7 @@ LL | a | a; | = note: an implementation of `std::ops::BitOr` might be missing for `A` -error[E0369]: no implementation for `A << A +error[E0369]: no implementation for `A << A` --> $DIR/issue-28837.rs:20:7 | LL | a << a; @@ -78,7 +78,7 @@ LL | a << a; | = note: an implementation of `std::ops::Shl` might be missing for `A` -error[E0369]: no implementation for `A >> A +error[E0369]: no implementation for `A >> A` --> $DIR/issue-28837.rs:22:7 | LL | a >> a;