]> git.lizzy.rs Git - rust.git/blob - src/test/ui/dst/dst-bad-coerce3.rs
Rollup merge of #100479 - compiler-errors:argument-type-error-improvements, r=lcnr
[rust.git] / src / test / ui / dst / dst-bad-coerce3.rs
1 // Attempt to extend the lifetime 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 impl Bar for Foo {}
12
13 fn baz<'a>() {
14     // With a vec of ints.
15     let f1 = Fat { ptr: [1, 2, 3] };
16     let f2: &Fat<[isize; 3]> = &f1; //~ ERROR `f1` does not live long enough
17     let f3: &'a Fat<[isize]> = f2;
18
19     // With a trait.
20     let f1 = Fat { ptr: Foo };
21     let f2: &Fat<Foo> = &f1; //~ ERROR `f1` does not live long enough
22     let f3: &'a Fat<dyn Bar> = f2;
23
24     // Tuple with a vec of ints.
25     let f1 = ([1, 2, 3],);
26     let f2: &([isize; 3],) = &f1; //~ ERROR `f1` does not live long enough
27     let f3: &'a ([isize],) = f2;
28
29     // Tuple with a trait.
30     let f1 = (Foo,);
31     let f2: &(Foo,) = &f1; //~ ERROR `f1` does not live long enough
32     let f3: &'a (dyn Bar,) = f2;
33 }
34
35 pub fn main() {
36     baz();
37 }