]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/struct-base-wrong-type-2.rs
New upstream version 1.12.0+dfsg1
[rustc.git] / src / test / compile-fail / struct-base-wrong-type-2.rs
CommitLineData
9346a6ac
AL
1// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
11// Check that `base` in `Fru { field: expr, ..base }` must have right type.
12//
13// See also struct-base-wrong-type.rs, which tests same condition
14// within a const expression.
15
16struct Foo { a: isize, b: isize }
17struct Bar { x: isize }
18
19fn main() {
20 let b = Bar { x: 5 };
21 let f = Foo { a: 2, ..b }; //~ ERROR mismatched types
a7813a04
XL
22 //~| expected type `Foo`
23 //~| found type `Bar`
24 //~| expected struct `Foo`, found struct `Bar`
9346a6ac 25 let f__isize = Foo { a: 2, ..4 }; //~ ERROR mismatched types
a7813a04 26 //~| expected type `Foo`
5bcae85e 27 //~| found type `{integer}`
a7813a04 28 //~| expected struct `Foo`, found integral variable
9346a6ac 29}