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);
}
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);
}
-// 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(); }
-// error-pattern:`*` cannot be applied to type `bool`
+// error-pattern:cannot multiply `bool` to `bool`
fn main() { let x = true * false; }
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`
}
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 {}
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>`
}
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 ^
];
}
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`
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`
}
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() {
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`
}
fn main() {
() + f(&[1.0]);
- //~^ ERROR binary operation `+` cannot be applied to type `()`
+ //~^ ERROR cannot add `()` to `()`
}
enum Foo {
A = "" + 1
- //~^ ERROR binary operation `+` cannot be applied to type `&str`
+ //~^ ERROR cannot add `{integer}` to `&str`
}
enum Bar {
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.
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() { }
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 {
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
}
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);
}
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`
}
}
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() {}
}
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) {
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);
}