Test more cases of WF-checking for fields
This commit is contained in:
parent
9479792cb4
commit
2f4603b715
@ -1,11 +1,32 @@
|
||||
struct Foo {
|
||||
struct FooStruct {
|
||||
nested: &'static Bar<dyn std::fmt::Debug>,
|
||||
//~^ ERROR the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time
|
||||
}
|
||||
|
||||
struct FooTuple(&'static Bar<dyn std::fmt::Debug>);
|
||||
//~^ ERROR the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time
|
||||
|
||||
enum FooEnum1 {
|
||||
Struct { nested: &'static Bar<dyn std::fmt::Debug> },
|
||||
//~^ ERROR the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time
|
||||
}
|
||||
|
||||
enum FooEnum2 {
|
||||
Tuple(&'static Bar<dyn std::fmt::Debug>),
|
||||
//~^ ERROR the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time
|
||||
}
|
||||
|
||||
struct Bar<T>(T);
|
||||
|
||||
fn main() {
|
||||
let x = Foo { nested: &Bar(4) };
|
||||
// Ensure there's an error at the construction site, for error tainting purposes.
|
||||
|
||||
FooStruct { nested: &Bar(4) };
|
||||
//~^ ERROR the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time
|
||||
FooTuple(&Bar(4));
|
||||
//~^ ERROR the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time
|
||||
FooEnum1::Struct { nested: &Bar(4) };
|
||||
//~^ ERROR the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time
|
||||
FooEnum2::Tuple(&Bar(4));
|
||||
//~^ ERROR the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time
|
||||
}
|
||||
|
@ -6,12 +6,12 @@ LL | nested: &'static Bar<dyn std::fmt::Debug>,
|
||||
|
|
||||
= help: the trait `Sized` is not implemented for `(dyn Debug + 'static)`
|
||||
note: required by an implicit `Sized` bound in `Bar`
|
||||
--> $DIR/field-implied-unsizing-wfcheck.rs:6:12
|
||||
--> $DIR/field-implied-unsizing-wfcheck.rs:19:12
|
||||
|
|
||||
LL | struct Bar<T>(T);
|
||||
| ^ required by the implicit `Sized` requirement on this type parameter in `Bar`
|
||||
help: you could relax the implicit `Sized` bound on `T` if it were used through indirection like `&T` or `Box<T>`
|
||||
--> $DIR/field-implied-unsizing-wfcheck.rs:6:12
|
||||
--> $DIR/field-implied-unsizing-wfcheck.rs:19:12
|
||||
|
|
||||
LL | struct Bar<T>(T);
|
||||
| ^ - ...if indirection were used here: `Box<T>`
|
||||
@ -19,25 +19,145 @@ LL | struct Bar<T>(T);
|
||||
| this could be changed to `T: ?Sized`...
|
||||
|
||||
error[E0277]: the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time
|
||||
--> $DIR/field-implied-unsizing-wfcheck.rs:9:27
|
||||
--> $DIR/field-implied-unsizing-wfcheck.rs:6:17
|
||||
|
|
||||
LL | let x = Foo { nested: &Bar(4) };
|
||||
| ^^^^^^^ doesn't have a size known at compile-time
|
||||
LL | struct FooTuple(&'static Bar<dyn std::fmt::Debug>);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
= help: the trait `Sized` is not implemented for `(dyn Debug + 'static)`
|
||||
note: required by an implicit `Sized` bound in `Bar`
|
||||
--> $DIR/field-implied-unsizing-wfcheck.rs:6:12
|
||||
--> $DIR/field-implied-unsizing-wfcheck.rs:19:12
|
||||
|
|
||||
LL | struct Bar<T>(T);
|
||||
| ^ required by the implicit `Sized` requirement on this type parameter in `Bar`
|
||||
help: you could relax the implicit `Sized` bound on `T` if it were used through indirection like `&T` or `Box<T>`
|
||||
--> $DIR/field-implied-unsizing-wfcheck.rs:6:12
|
||||
--> $DIR/field-implied-unsizing-wfcheck.rs:19:12
|
||||
|
|
||||
LL | struct Bar<T>(T);
|
||||
| ^ - ...if indirection were used here: `Box<T>`
|
||||
| |
|
||||
| this could be changed to `T: ?Sized`...
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error[E0277]: the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time
|
||||
--> $DIR/field-implied-unsizing-wfcheck.rs:10:22
|
||||
|
|
||||
LL | Struct { nested: &'static Bar<dyn std::fmt::Debug> },
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
= help: the trait `Sized` is not implemented for `(dyn Debug + 'static)`
|
||||
note: required by an implicit `Sized` bound in `Bar`
|
||||
--> $DIR/field-implied-unsizing-wfcheck.rs:19:12
|
||||
|
|
||||
LL | struct Bar<T>(T);
|
||||
| ^ required by the implicit `Sized` requirement on this type parameter in `Bar`
|
||||
help: you could relax the implicit `Sized` bound on `T` if it were used through indirection like `&T` or `Box<T>`
|
||||
--> $DIR/field-implied-unsizing-wfcheck.rs:19:12
|
||||
|
|
||||
LL | struct Bar<T>(T);
|
||||
| ^ - ...if indirection were used here: `Box<T>`
|
||||
| |
|
||||
| this could be changed to `T: ?Sized`...
|
||||
|
||||
error[E0277]: the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time
|
||||
--> $DIR/field-implied-unsizing-wfcheck.rs:15:11
|
||||
|
|
||||
LL | Tuple(&'static Bar<dyn std::fmt::Debug>),
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
= help: the trait `Sized` is not implemented for `(dyn Debug + 'static)`
|
||||
note: required by an implicit `Sized` bound in `Bar`
|
||||
--> $DIR/field-implied-unsizing-wfcheck.rs:19:12
|
||||
|
|
||||
LL | struct Bar<T>(T);
|
||||
| ^ required by the implicit `Sized` requirement on this type parameter in `Bar`
|
||||
help: you could relax the implicit `Sized` bound on `T` if it were used through indirection like `&T` or `Box<T>`
|
||||
--> $DIR/field-implied-unsizing-wfcheck.rs:19:12
|
||||
|
|
||||
LL | struct Bar<T>(T);
|
||||
| ^ - ...if indirection were used here: `Box<T>`
|
||||
| |
|
||||
| this could be changed to `T: ?Sized`...
|
||||
|
||||
error[E0277]: the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time
|
||||
--> $DIR/field-implied-unsizing-wfcheck.rs:24:25
|
||||
|
|
||||
LL | FooStruct { nested: &Bar(4) };
|
||||
| ^^^^^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
= help: the trait `Sized` is not implemented for `(dyn Debug + 'static)`
|
||||
note: required by an implicit `Sized` bound in `Bar`
|
||||
--> $DIR/field-implied-unsizing-wfcheck.rs:19:12
|
||||
|
|
||||
LL | struct Bar<T>(T);
|
||||
| ^ required by the implicit `Sized` requirement on this type parameter in `Bar`
|
||||
help: you could relax the implicit `Sized` bound on `T` if it were used through indirection like `&T` or `Box<T>`
|
||||
--> $DIR/field-implied-unsizing-wfcheck.rs:19:12
|
||||
|
|
||||
LL | struct Bar<T>(T);
|
||||
| ^ - ...if indirection were used here: `Box<T>`
|
||||
| |
|
||||
| this could be changed to `T: ?Sized`...
|
||||
|
||||
error[E0277]: the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time
|
||||
--> $DIR/field-implied-unsizing-wfcheck.rs:26:14
|
||||
|
|
||||
LL | FooTuple(&Bar(4));
|
||||
| ^^^^^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
= help: the trait `Sized` is not implemented for `(dyn Debug + 'static)`
|
||||
note: required by an implicit `Sized` bound in `Bar`
|
||||
--> $DIR/field-implied-unsizing-wfcheck.rs:19:12
|
||||
|
|
||||
LL | struct Bar<T>(T);
|
||||
| ^ required by the implicit `Sized` requirement on this type parameter in `Bar`
|
||||
help: you could relax the implicit `Sized` bound on `T` if it were used through indirection like `&T` or `Box<T>`
|
||||
--> $DIR/field-implied-unsizing-wfcheck.rs:19:12
|
||||
|
|
||||
LL | struct Bar<T>(T);
|
||||
| ^ - ...if indirection were used here: `Box<T>`
|
||||
| |
|
||||
| this could be changed to `T: ?Sized`...
|
||||
|
||||
error[E0277]: the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time
|
||||
--> $DIR/field-implied-unsizing-wfcheck.rs:28:32
|
||||
|
|
||||
LL | FooEnum1::Struct { nested: &Bar(4) };
|
||||
| ^^^^^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
= help: the trait `Sized` is not implemented for `(dyn Debug + 'static)`
|
||||
note: required by an implicit `Sized` bound in `Bar`
|
||||
--> $DIR/field-implied-unsizing-wfcheck.rs:19:12
|
||||
|
|
||||
LL | struct Bar<T>(T);
|
||||
| ^ required by the implicit `Sized` requirement on this type parameter in `Bar`
|
||||
help: you could relax the implicit `Sized` bound on `T` if it were used through indirection like `&T` or `Box<T>`
|
||||
--> $DIR/field-implied-unsizing-wfcheck.rs:19:12
|
||||
|
|
||||
LL | struct Bar<T>(T);
|
||||
| ^ - ...if indirection were used here: `Box<T>`
|
||||
| |
|
||||
| this could be changed to `T: ?Sized`...
|
||||
|
||||
error[E0277]: the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time
|
||||
--> $DIR/field-implied-unsizing-wfcheck.rs:30:21
|
||||
|
|
||||
LL | FooEnum2::Tuple(&Bar(4));
|
||||
| ^^^^^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
= help: the trait `Sized` is not implemented for `(dyn Debug + 'static)`
|
||||
note: required by an implicit `Sized` bound in `Bar`
|
||||
--> $DIR/field-implied-unsizing-wfcheck.rs:19:12
|
||||
|
|
||||
LL | struct Bar<T>(T);
|
||||
| ^ required by the implicit `Sized` requirement on this type parameter in `Bar`
|
||||
help: you could relax the implicit `Sized` bound on `T` if it were used through indirection like `&T` or `Box<T>`
|
||||
--> $DIR/field-implied-unsizing-wfcheck.rs:19:12
|
||||
|
|
||||
LL | struct Bar<T>(T);
|
||||
| ^ - ...if indirection were used here: `Box<T>`
|
||||
| |
|
||||
| this could be changed to `T: ?Sized`...
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
Loading…
Reference in New Issue
Block a user