rust/tests/ui/autoderef-full-lval.rs

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

26 lines
599 B
Rust
Raw Normal View History

struct Clam {
2014-12-05 20:12:25 -06:00
x: Box<isize>,
y: Box<isize>,
2013-03-01 21:57:05 -06:00
}
struct Fish {
2014-12-05 20:12:25 -06:00
a: Box<isize>,
2013-03-01 21:57:05 -06:00
}
fn main() {
let a: Clam = Clam{ x: Box::new(1), y: Box::new(2) };
let b: Clam = Clam{ x: Box::new(10), y: Box::new(20) };
2017-01-21 08:40:31 -06:00
let z: isize = a.x + b.y;
//~^ ERROR cannot add `Box<isize>` to `Box<isize>`
2014-10-02 00:10:09 -05:00
println!("{}", z);
assert_eq!(z, 21);
let forty: Fish = Fish{ a: Box::new(40) };
let two: Fish = Fish{ a: Box::new(2) };
let answer: isize = forty.a + two.a;
//~^ ERROR cannot add `Box<isize>` to `Box<isize>`
2014-10-02 00:10:09 -05:00
println!("{}", answer);
assert_eq!(answer, 42);
}