rust/tests/ui/span/issue-39018.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

39 lines
1022 B
Rust
Raw Normal View History

pub fn main() {
let x = "Hello " + "World!";
2019-12-11 22:11:32 +00:00
//~^ 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;
2019-12-11 22:11:32 +00:00
//~^ ERROR cannot add
let x = "Hello " + "World!".to_owned();
2019-12-11 22:11:32 +00:00
//~^ ERROR cannot add
}
enum World {
Hello,
Goodbye,
}
fn foo() {
let a = String::new();
let b = String::new();
let c = "";
let d = "";
let e = &a;
2019-12-11 22:11:32 +00:00
let _ = &a + &b; //~ ERROR cannot add
let _ = &a + b; //~ ERROR cannot add
let _ = a + &b; // ok
let _ = a + b; //~ ERROR mismatched types
2019-12-11 22:11:32 +00:00
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
}