rust/tests/ui/sized-hierarchy/default-bound.stderr
León Orell Valerian Liehr 879f62bb3c
Reword diagnostic about relaxing non-Sized bound
* The phrasing "only does something for" made sense back when this
  diagnostic was a (hard) warning. Now however, it's simply a hard
  error and thus completely rules out "doing something".
* The primary message was way too long
* The new wording more closely mirrors the wording we use for applying
  other bound modifiers (like `const` and `async`) to incompatible
  traits.
* "all other traits are not bound by default" is no longer accurate
  under Sized Hierarchy. E.g., traits and assoc tys are (currently)
  bounded by `MetaSized` by default but can't be relaxed using
  `?MetaSized` (instead, you relax it by adding `PointeeSized`).
* I've decided against adding any diagnositic notes or suggestions
  for now like "trait `Trait` can't be relaxed as it's not bound by
  default" which would be incorrect for `MetaSized` and assoc tys
  as mentioned above) or "consider changing `?MetaSized` to
  `PointeeSized`" as the Sized Hierarchy impl is still WIP)
2025-07-18 12:13:30 +02:00

89 lines
2.9 KiB
Plaintext

error: bound modifier `?` can only be applied to `Sized`
--> $DIR/default-bound.rs:16:21
|
LL | fn neg_metasized<T: ?MetaSized>() {}
| ^^^^^^^^^^
error: bound modifier `?` can only be applied to `Sized`
--> $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`.