Files
rust/tests/ui/sized-hierarchy/default-bound.stderr
David Wood 86ab2b60cd hir_analysis: add {Meta,Pointee}Sized bounds
Opting-out of `Sized` with `?Sized` is now equivalent to adding a
`MetaSized` bound, and adding a `MetaSized` or `PointeeSized` bound
is equivalent to removing the default `Sized` bound - this commit
implements this change in `rustc_hir_analysis::hir_ty_lowering`.

`MetaSized` is also added as a supertrait of all traits, as this is
necessary to preserve backwards compatibility.

Unfortunately, non-global where clauses being preferred over item bounds
(where `PointeeSized` bounds would be proven) - which can result in
errors when a `PointeeSized` supertrait/bound/predicate is added to some
items. Rather than `PointeeSized` being a bound on everything, it can
be the absence of a bound on everything, as `?Sized` was.
2025-06-16 23:04:33 +00:00

89 lines
3.0 KiB
Plaintext

error: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
--> $DIR/default-bound.rs:16:21
|
LL | fn neg_metasized<T: ?MetaSized>() {}
| ^^^^^^^^^^
error: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
--> $DIR/default-bound.rs:22:24
|
LL | fn neg_pointeesized<T: ?PointeeSized>() { }
| ^^^^^^^^^^^^^
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
--> $DIR/default-bound.rs:29:12
|
LL | bare::<[u8]>();
| ^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[u8]`
note: required by an implicit `Sized` bound in `bare`
--> $DIR/default-bound.rs:6:9
|
LL | fn bare<T>() {}
| ^ required by the implicit `Sized` requirement on this type parameter in `bare`
help: consider relaxing the implicit `Sized` restriction
|
LL | fn bare<T: ?Sized>() {}
| ++++++++
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
--> $DIR/default-bound.rs:31:13
|
LL | sized::<[u8]>();
| ^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[u8]`
note: required by a bound in `sized`
--> $DIR/default-bound.rs:9:13
|
LL | fn sized<T: Sized>() {}
| ^^^^^ required by this bound in `sized`
error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time
--> $DIR/default-bound.rs:42:12
|
LL | bare::<Foo>();
| ^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `main::Foo`
note: required by an implicit `Sized` bound in `bare`
--> $DIR/default-bound.rs:6:9
|
LL | fn bare<T>() {}
| ^ required by the implicit `Sized` requirement on this type parameter in `bare`
help: consider relaxing the implicit `Sized` restriction
|
LL | fn bare<T: ?Sized>() {}
| ++++++++
error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time
--> $DIR/default-bound.rs:44:13
|
LL | sized::<Foo>();
| ^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `main::Foo`
note: required by a bound in `sized`
--> $DIR/default-bound.rs:9:13
|
LL | fn sized<T: Sized>() {}
| ^^^^^ required by this bound in `sized`
error[E0277]: the size for values of type `main::Foo` cannot be known
--> $DIR/default-bound.rs:46:17
|
LL | metasized::<Foo>();
| ^^^ doesn't have a known size
|
= help: the trait `MetaSized` is not implemented for `main::Foo`
note: required by a bound in `metasized`
--> $DIR/default-bound.rs:14:17
|
LL | fn metasized<T: MetaSized>() {}
| ^^^^^^^^^ required by this bound in `metasized`
error: aborting due to 7 previous errors
For more information about this error, try `rustc --explain E0277`.