mirror of
https://github.com/rust-lang/rust.git
synced 2025-11-25 16:27:31 +00:00
Having multiple relaxed bounds like `?Sized + ?Iterator` is actually *fine*. We actually want to reject *duplicate* relaxed bounds like `?Sized + ?Sized` because these most certainly represent a user error. Note that this doesn't mean that we accept more code because a bound like `?Iterator` is still invalid as it's not relaxing a *default* trait and the only way to define / use more default bounds is under the experimental and internal feature `more_maybe_bounds` plus `lang_items` plus unstable flag `-Zexperimental-default-bounds` (historical context: for the longest time, bounds like `?Iterator` were actually allowed and lead to a hard warning). Ultimately, this simply *reframes* the diagnostic. The scope of `more_maybe_bounds` / `-Zexperimental-default-bounds` remains unchanged as well.
197 lines
7.0 KiB
Plaintext
197 lines
7.0 KiB
Plaintext
error[E0203]: duplicate relaxed `Sized` bounds
|
|
--> $DIR/fix-dyn-sized-fn-param-sugg.rs:11:12
|
|
|
|
|
LL | fn foo2<T: ?Sized + ?Sized>(a: T) {}
|
|
| ^^^^^^ ^^^^^^
|
|
|
|
error[E0203]: duplicate relaxed `Sized` bounds
|
|
--> $DIR/fix-dyn-sized-fn-param-sugg.rs:15:12
|
|
|
|
|
LL | fn foo3<T: ?Sized + ?Sized + Debug>(a: T) {}
|
|
| ^^^^^^ ^^^^^^
|
|
|
|
error[E0203]: duplicate relaxed `Sized` bounds
|
|
--> $DIR/fix-dyn-sized-fn-param-sugg.rs:19:12
|
|
|
|
|
LL | fn foo4<T: ?Sized + Debug + ?Sized >(a: T) {}
|
|
| ^^^^^^ ^^^^^^
|
|
|
|
error[E0203]: duplicate relaxed `Sized` bounds
|
|
--> $DIR/fix-dyn-sized-fn-param-sugg.rs:26:17
|
|
|
|
|
LL | fn foo6(_: impl ?Sized + ?Sized) {}
|
|
| ^^^^^^ ^^^^^^
|
|
|
|
error[E0203]: duplicate relaxed `Sized` bounds
|
|
--> $DIR/fix-dyn-sized-fn-param-sugg.rs:30:17
|
|
|
|
|
LL | fn foo7(_: impl ?Sized + ?Sized + Debug) {}
|
|
| ^^^^^^ ^^^^^^
|
|
|
|
error[E0203]: duplicate relaxed `Sized` bounds
|
|
--> $DIR/fix-dyn-sized-fn-param-sugg.rs:34:17
|
|
|
|
|
LL | fn foo8(_: impl ?Sized + Debug + ?Sized ) {}
|
|
| ^^^^^^ ^^^^^^
|
|
|
|
error[E0277]: the size for values of type `T` cannot be known at compilation time
|
|
--> $DIR/fix-dyn-sized-fn-param-sugg.rs:8:23
|
|
|
|
|
LL | fn foo1<T: ?Sized>(a: T) {}
|
|
| - ^ doesn't have a size known at compile-time
|
|
| |
|
|
| this type parameter needs to be `Sized`
|
|
|
|
|
= help: unsized fn params are gated as an unstable feature
|
|
help: consider removing the `?Sized` bound to make the type parameter `Sized`
|
|
|
|
|
LL - fn foo1<T: ?Sized>(a: T) {}
|
|
LL + fn foo1<T>(a: T) {}
|
|
|
|
|
help: function arguments must have a statically known size, borrowed types always have a known size
|
|
|
|
|
LL | fn foo1<T: ?Sized>(a: &T) {}
|
|
| +
|
|
|
|
error[E0277]: the size for values of type `T` cannot be known at compilation time
|
|
--> $DIR/fix-dyn-sized-fn-param-sugg.rs:11:32
|
|
|
|
|
LL | fn foo2<T: ?Sized + ?Sized>(a: T) {}
|
|
| - ^ doesn't have a size known at compile-time
|
|
| |
|
|
| this type parameter needs to be `Sized`
|
|
|
|
|
= help: unsized fn params are gated as an unstable feature
|
|
help: consider removing the `?Sized` bound to make the type parameter `Sized`
|
|
|
|
|
LL - fn foo2<T: ?Sized + ?Sized>(a: T) {}
|
|
LL + fn foo2<T>(a: T) {}
|
|
|
|
|
help: function arguments must have a statically known size, borrowed types always have a known size
|
|
|
|
|
LL | fn foo2<T: ?Sized + ?Sized>(a: &T) {}
|
|
| +
|
|
|
|
error[E0277]: the size for values of type `T` cannot be known at compilation time
|
|
--> $DIR/fix-dyn-sized-fn-param-sugg.rs:15:40
|
|
|
|
|
LL | fn foo3<T: ?Sized + ?Sized + Debug>(a: T) {}
|
|
| - ^ doesn't have a size known at compile-time
|
|
| |
|
|
| this type parameter needs to be `Sized`
|
|
|
|
|
= help: unsized fn params are gated as an unstable feature
|
|
help: consider restricting type parameters
|
|
|
|
|
LL - fn foo3<T: ?Sized + ?Sized + Debug>(a: T) {}
|
|
LL + fn foo3<T: Debug>(a: T) {}
|
|
|
|
|
help: function arguments must have a statically known size, borrowed types always have a known size
|
|
|
|
|
LL | fn foo3<T: ?Sized + ?Sized + Debug>(a: &T) {}
|
|
| +
|
|
|
|
error[E0277]: the size for values of type `T` cannot be known at compilation time
|
|
--> $DIR/fix-dyn-sized-fn-param-sugg.rs:19:41
|
|
|
|
|
LL | fn foo4<T: ?Sized + Debug + ?Sized >(a: T) {}
|
|
| - ^ doesn't have a size known at compile-time
|
|
| |
|
|
| this type parameter needs to be `Sized`
|
|
|
|
|
= help: unsized fn params are gated as an unstable feature
|
|
help: consider restricting type parameters
|
|
|
|
|
LL - fn foo4<T: ?Sized + Debug + ?Sized >(a: T) {}
|
|
LL + fn foo4<T: Debug >(a: T) {}
|
|
|
|
|
help: function arguments must have a statically known size, borrowed types always have a known size
|
|
|
|
|
LL | fn foo4<T: ?Sized + Debug + ?Sized >(a: &T) {}
|
|
| +
|
|
|
|
error[E0277]: the size for values of type `impl ?Sized` cannot be known at compilation time
|
|
--> $DIR/fix-dyn-sized-fn-param-sugg.rs:23:12
|
|
|
|
|
LL | fn foo5(_: impl ?Sized) {}
|
|
| ^^^^^^^^^^^
|
|
| |
|
|
| doesn't have a size known at compile-time
|
|
| this type parameter needs to be `Sized`
|
|
|
|
|
= help: unsized fn params are gated as an unstable feature
|
|
help: consider replacing `?Sized` with `Sized`
|
|
|
|
|
LL - fn foo5(_: impl ?Sized) {}
|
|
LL + fn foo5(_: impl Sized) {}
|
|
|
|
|
help: function arguments must have a statically known size, borrowed types always have a known size
|
|
|
|
|
LL | fn foo5(_: &impl ?Sized) {}
|
|
| +
|
|
|
|
error[E0277]: the size for values of type `impl ?Sized + ?Sized` cannot be known at compilation time
|
|
--> $DIR/fix-dyn-sized-fn-param-sugg.rs:26:12
|
|
|
|
|
LL | fn foo6(_: impl ?Sized + ?Sized) {}
|
|
| ^^^^^^^^^^^^^^^^^^^^
|
|
| |
|
|
| doesn't have a size known at compile-time
|
|
| this type parameter needs to be `Sized`
|
|
|
|
|
= help: unsized fn params are gated as an unstable feature
|
|
help: consider restricting type parameters
|
|
|
|
|
LL - fn foo6(_: impl ?Sized + ?Sized) {}
|
|
LL + fn foo6(_: impl Sized) {}
|
|
|
|
|
help: function arguments must have a statically known size, borrowed types always have a known size
|
|
|
|
|
LL | fn foo6(_: &impl ?Sized + ?Sized) {}
|
|
| +
|
|
|
|
error[E0277]: the size for values of type `impl ?Sized + ?Sized + Debug` cannot be known at compilation time
|
|
--> $DIR/fix-dyn-sized-fn-param-sugg.rs:30:12
|
|
|
|
|
LL | fn foo7(_: impl ?Sized + ?Sized + Debug) {}
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
| |
|
|
| doesn't have a size known at compile-time
|
|
| this type parameter needs to be `Sized`
|
|
|
|
|
= help: unsized fn params are gated as an unstable feature
|
|
help: consider restricting type parameters
|
|
|
|
|
LL - fn foo7(_: impl ?Sized + ?Sized + Debug) {}
|
|
LL + fn foo7(_: impl Debug) {}
|
|
|
|
|
help: function arguments must have a statically known size, borrowed types always have a known size
|
|
|
|
|
LL | fn foo7(_: &impl ?Sized + ?Sized + Debug) {}
|
|
| +
|
|
|
|
error[E0277]: the size for values of type `impl ?Sized + Debug + ?Sized` cannot be known at compilation time
|
|
--> $DIR/fix-dyn-sized-fn-param-sugg.rs:34:12
|
|
|
|
|
LL | fn foo8(_: impl ?Sized + Debug + ?Sized ) {}
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
| |
|
|
| doesn't have a size known at compile-time
|
|
| this type parameter needs to be `Sized`
|
|
|
|
|
= help: unsized fn params are gated as an unstable feature
|
|
help: consider restricting type parameters
|
|
|
|
|
LL - fn foo8(_: impl ?Sized + Debug + ?Sized ) {}
|
|
LL + fn foo8(_: impl Debug ) {}
|
|
|
|
|
help: function arguments must have a statically known size, borrowed types always have a known size
|
|
|
|
|
LL | fn foo8(_: &impl ?Sized + Debug + ?Sized ) {}
|
|
| +
|
|
|
|
error: aborting due to 14 previous errors
|
|
|
|
Some errors have detailed explanations: E0203, E0277.
|
|
For more information about an error, try `rustc --explain E0203`.
|