]> git.lizzy.rs Git - rust.git/blob - src/test/ui/structs/struct-base-wrong-type-2.rs
562f75b8e85bda53e18794bb550db0ff18679a74
[rust.git] / src / test / ui / structs / struct-base-wrong-type-2.rs
1 // Check that `base` in `Fru { field: expr, ..base }` must have right type.
2 //
3 // See also struct-base-wrong-type.rs, which tests same condition
4 // within a const expression.
5
6 struct Foo { a: isize, b: isize }
7 struct Bar { x: isize }
8
9 fn main() {
10     let b = Bar { x: 5 };
11     let f = Foo { a: 2, ..b }; //~  ERROR mismatched types
12                                //~| expected type `Foo`
13                                //~| found type `Bar`
14                                //~| expected struct `Foo`, found struct `Bar`
15     let f__isize = Foo { a: 2, ..4 }; //~  ERROR mismatched types
16                                  //~| expected type `Foo`
17                                  //~| found type `{integer}`
18                                  //~| expected struct `Foo`, found integer
19 }