Rollup merge of #67189 - LeSeulArtichaut:binop-wording, r=estebank

Unify binop wording

Closes #60497
r? @estebank
This commit is contained in:
Mazdak Farrokhzad 2019-12-19 10:29:51 +01:00 committed by GitHub
commit eac5fb8b0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
47 changed files with 153 additions and 112 deletions

View File

@ -334,10 +334,70 @@ 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"))
},
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),
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 +442,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(

View File

@ -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<isize>`
//~^ ERROR cannot add `std::boxed::Box<isize>` to `std::boxed::Box<isize>`
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<isize>`
//~^ ERROR cannot add `std::boxed::Box<isize>` to `std::boxed::Box<isize>`
println!("{}", answer);
assert_eq!(answer, 42);
}

View File

@ -1,4 +1,4 @@
error[E0369]: binary operation `+` cannot be applied to type `std::boxed::Box<isize>`
error[E0369]: cannot add `std::boxed::Box<isize>` to `std::boxed::Box<isize>`
--> $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<isize>`
error[E0369]: binary operation `+` cannot be applied to type `std::boxed::Box<isize>`
error[E0369]: cannot add `std::boxed::Box<isize>` to `std::boxed::Box<isize>`
--> $DIR/autoderef-full-lval.rs:21:33
|
LL | let answer: isize = forty.a + two.a;

View File

@ -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);
}

View File

@ -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

View File

@ -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(); }

View File

@ -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(); }

View File

@ -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; }

View File

@ -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; }

View File

@ -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`
}

View File

@ -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;

View File

@ -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 {}

View File

@ -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 = () + ();

View File

@ -4,5 +4,5 @@ fn main() {
let x: Box<isize> = box 0;
println!("{}", x + 1);
//~^ ERROR binary operation `+` cannot be applied to type `std::boxed::Box<isize>`
//~^ ERROR cannot add `{integer}` to `std::boxed::Box<isize>`
}

View File

@ -1,4 +1,4 @@
error[E0369]: binary operation `+` cannot be applied to type `std::boxed::Box<isize>`
error[E0369]: cannot add `{integer}` to `std::boxed::Box<isize>`
--> $DIR/issue-14915.rs:6:22
|
LL | println!("{}", x + 1);

View File

@ -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 ^
];
}

View File

@ -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 | ()+()

View File

@ -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`

View File

@ -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;

View File

@ -11,7 +11,7 @@ impl Add<i32> 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`
}

View File

@ -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;

View File

@ -1,6 +1,6 @@
fn func<'a, T>(a: &'a [T]) -> impl Iterator<Item=&'a T> {
a.iter().map(|a| a*a)
//~^ ERROR binary operation `*` cannot be applied to type `&T`
//~^ ERROR cannot multiply `&T` to `&T`
}
fn main() {

View File

@ -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)

View File

@ -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`
}

View File

@ -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;

View File

@ -2,5 +2,5 @@ fn f(_: &[f32]) {}
fn main() {
() + f(&[1.0]);
//~^ ERROR binary operation `+` cannot be applied to type `()`
//~^ ERROR cannot add `()` to `()`
}

View File

@ -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]);

View File

@ -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 {

View File

@ -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

View File

@ -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!";

View File

@ -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!";

View File

@ -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.

View File

@ -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| ();

View File

@ -1,6 +1,6 @@
enum Bar { T1((), Option<Vec<isize>>), 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<isize>`
fn main() { }

View File

@ -1,4 +1,4 @@
error[E0369]: binary operation `*` cannot be applied to type `std::vec::Vec<isize>`
error[E0369]: cannot multiply `{integer}` to `std::vec::Vec<isize>`
--> $DIR/pattern-tyvar-2.rs:3:71
|
LL | fn foo(t: Bar) -> isize { match t { Bar::T1(_, Some(x)) => { return x * 3; } _ => { panic!(); } } }

View File

@ -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
}

View File

@ -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;

View File

@ -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);
}

View File

@ -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;

View File

@ -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`
}

View File

@ -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!";

View File

@ -5,7 +5,7 @@ trait MyMul<Rhs, Res> {
}
fn foo<T: MyMul<f64, f64>>(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() {}

View File

@ -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

View File

@ -2,7 +2,7 @@ fn main() {
}
fn foo<T>(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<T>(x: T) {

View File

@ -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;

View File

@ -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<R>` to `std::vec::Vec<R>`
println!("{:?}", j);
}

View File

@ -1,4 +1,4 @@
error[E0369]: binary operation `+` cannot be applied to type `std::vec::Vec<R>`
error[E0369]: cannot add `std::vec::Vec<R>` to `std::vec::Vec<R>`
--> $DIR/vec-res-add.rs:16:15
|
LL | let k = i + j;