]> git.lizzy.rs Git - rust.git/blob - src/test/ui/dst/dst-bad-coerce1.rs
Rollup merge of #100479 - compiler-errors:argument-type-error-improvements, r=lcnr
[rust.git] / src / test / ui / dst / dst-bad-coerce1.rs
1 // Attempt to change the type as well as unsizing.
2
3 #![feature(unsized_tuple_coercion)]
4
5 struct Fat<T: ?Sized> {
6     ptr: T
7 }
8
9 struct Foo;
10 trait Bar { fn bar(&self) {} }
11
12 pub fn main() {
13     // With a vec of isize.
14     let f1 = Fat { ptr: [1, 2, 3] };
15     let f2: &Fat<[isize; 3]> = &f1;
16     let f3: &Fat<[usize]> = f2;
17     //~^ ERROR mismatched types
18
19     // With a trait.
20     let f1 = Fat { ptr: Foo };
21     let f2: &Fat<Foo> = &f1;
22     let f3: &Fat<dyn Bar> = f2;
23     //~^ ERROR `Foo: Bar` is not satisfied
24
25     // Tuple with a vec of isize.
26     let f1 = ([1, 2, 3],);
27     let f2: &([isize; 3],) = &f1;
28     let f3: &([usize],) = f2;
29     //~^ ERROR mismatched types
30
31     // Tuple with a trait.
32     let f1 = (Foo,);
33     let f2: &(Foo,) = &f1;
34     let f3: &(dyn Bar,) = f2;
35     //~^ ERROR `Foo: Bar` is not satisfied
36 }