mirror of
https://github.com/rust-lang/rust.git
synced 2025-10-02 18:27:37 +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.
48 lines
1.5 KiB
Plaintext
48 lines
1.5 KiB
Plaintext
error[E0203]: duplicate relaxed `Sized` bounds
|
|
--> $DIR/duplicate-relaxed-bounds.rs:1:13
|
|
|
|
|
LL | fn dupes<T: ?Sized + ?Sized + ?Iterator + ?Iterator>() {}
|
|
| ^^^^^^ ^^^^^^
|
|
|
|
error[E0203]: duplicate relaxed `Iterator` bounds
|
|
--> $DIR/duplicate-relaxed-bounds.rs:1:31
|
|
|
|
|
LL | fn dupes<T: ?Sized + ?Sized + ?Iterator + ?Iterator>() {}
|
|
| ^^^^^^^^^ ^^^^^^^^^
|
|
|
|
error: bound modifier `?` can only be applied to `Sized`
|
|
--> $DIR/duplicate-relaxed-bounds.rs:1:31
|
|
|
|
|
LL | fn dupes<T: ?Sized + ?Sized + ?Iterator + ?Iterator>() {}
|
|
| ^^^^^^^^^
|
|
|
|
error: bound modifier `?` can only be applied to `Sized`
|
|
--> $DIR/duplicate-relaxed-bounds.rs:1:43
|
|
|
|
|
LL | fn dupes<T: ?Sized + ?Sized + ?Iterator + ?Iterator>() {}
|
|
| ^^^^^^^^^
|
|
|
|
error: bound modifier `?` can only be applied to `Sized`
|
|
--> $DIR/duplicate-relaxed-bounds.rs:19:26
|
|
|
|
|
LL | fn not_dupes<T: ?Sized + ?Iterator>() {}
|
|
| ^^^^^^^^^
|
|
|
|
error[E0203]: duplicate relaxed `Sized` bounds
|
|
--> $DIR/duplicate-relaxed-bounds.rs:10:16
|
|
|
|
|
LL | type Type: ?Sized + ?Sized;
|
|
| ^^^^^^ ^^^^^^
|
|
|
|
error[E0203]: duplicate relaxed `Sized` bounds
|
|
--> $DIR/duplicate-relaxed-bounds.rs:10:16
|
|
|
|
|
LL | type Type: ?Sized + ?Sized;
|
|
| ^^^^^^ ^^^^^^
|
|
|
|
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
|
|
|
error: aborting due to 7 previous errors
|
|
|
|
For more information about this error, try `rustc --explain E0203`.
|