]> git.lizzy.rs Git - rust.git/blob - tests/ui/unsized/unsized-struct.stderr
Auto merge of #106711 - albertlarsan68:use-ci-llvm-when-lld, r=jyn514
[rust.git] / tests / ui / unsized / unsized-struct.stderr
1 error[E0277]: the size for values of type `T` cannot be known at compilation time
2   --> $DIR/unsized-struct.rs:6:36
3    |
4 LL | fn foo2<T: ?Sized>() { not_sized::<Foo<T>>() }
5    |         -                          ^^^^^^ doesn't have a size known at compile-time
6    |         |
7    |         this type parameter needs to be `std::marker::Sized`
8    |
9 note: required by a bound in `Foo`
10   --> $DIR/unsized-struct.rs:4:12
11    |
12 LL | struct Foo<T> { data: T }
13    |            ^ required by this bound in `Foo`
14 help: you could relax the implicit `Sized` bound on `T` if it were used through indirection like `&T` or `Box<T>`
15   --> $DIR/unsized-struct.rs:4:12
16    |
17 LL | struct Foo<T> { data: T }
18    |            ^          - ...if indirection were used here: `Box<T>`
19    |            |
20    |            this could be changed to `T: ?Sized`...
21 help: consider removing the `?Sized` bound to make the type parameter `Sized`
22    |
23 LL - fn foo2<T: ?Sized>() { not_sized::<Foo<T>>() }
24 LL + fn foo2<T>() { not_sized::<Foo<T>>() }
25    |
26
27 error[E0277]: the size for values of type `T` cannot be known at compilation time
28   --> $DIR/unsized-struct.rs:13:35
29    |
30 LL | fn bar2<T: ?Sized>() { is_sized::<Bar<T>>() }
31    |         -                         ^^^^^^ doesn't have a size known at compile-time
32    |         |
33    |         this type parameter needs to be `std::marker::Sized`
34    |
35 note: required because it appears within the type `Bar<T>`
36   --> $DIR/unsized-struct.rs:11:8
37    |
38 LL | struct Bar<T: ?Sized> { data: T }
39    |        ^^^
40 note: required by a bound in `is_sized`
41   --> $DIR/unsized-struct.rs:1:13
42    |
43 LL | fn is_sized<T:Sized>() { }
44    |             ^ required by this bound in `is_sized`
45 help: consider removing the `?Sized` bound to make the type parameter `Sized`
46    |
47 LL - fn bar2<T: ?Sized>() { is_sized::<Bar<T>>() }
48 LL + fn bar2<T>() { is_sized::<Bar<T>>() }
49    |
50
51 error: aborting due to 2 previous errors
52
53 For more information about this error, try `rustc --explain E0277`.