mirror of
https://github.com/rust-lang/rust.git
synced 2025-09-30 00:03:49 +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.
15 lines
521 B
Rust
15 lines
521 B
Rust
#![feature(auto_traits)]
|
|
|
|
trait Trait1 {}
|
|
auto trait Trait2 {}
|
|
trait Trait3: ?Trait1 {} //~ ERROR relaxed bounds are not permitted in supertrait bounds
|
|
trait Trait4 where Self: ?Trait1 {} //~ ERROR this relaxed bound is not permitted here
|
|
|
|
fn foo(_: Box<dyn Trait1 + ?Trait2>) {}
|
|
//~^ ERROR relaxed bounds are not permitted in trait object types
|
|
fn bar<T: ?Trait1 + ?Trait2>(_: T) {}
|
|
//~^ ERROR bound modifier `?` can only be applied to `Sized`
|
|
//~| ERROR bound modifier `?` can only be applied to `Sized`
|
|
|
|
fn main() {}
|