Default sizedness bounds were not being added to `explicit_super_predicates_of` and `explicit_implied_predicates_of` which meant that a trait bound added to a associated type projection would be missing the implied predicate of the default sizedness supertrait of that trait. An unexpected consequence of this change was that the check for multiple principals was now finding an additional `MetaSized` principal when eagerly expanding trait aliases. Instead of special-casing trait aliases as different from traits and not adding a `MetaSized` supertrait to trait aliases, filter out `MetaSized` when lowering `dyn Trait`.
64 lines
2.0 KiB
Rust
64 lines
2.0 KiB
Rust
//@ check-fail
|
|
#![feature(sized_hierarchy)]
|
|
|
|
use std::marker::{MetaSized, PointeeSized};
|
|
|
|
trait Sized_: Sized { }
|
|
|
|
trait NegSized: ?Sized { }
|
|
//~^ ERROR relaxed bounds are not permitted in supertrait bounds
|
|
|
|
trait MetaSized_: MetaSized { }
|
|
|
|
trait NegMetaSized: ?MetaSized { }
|
|
//~^ ERROR relaxed bounds are not permitted in supertrait bounds
|
|
//~| ERROR bound modifier `?` can only be applied to `Sized`
|
|
//~| ERROR bound modifier `?` can only be applied to `Sized`
|
|
//~| ERROR bound modifier `?` can only be applied to `Sized`
|
|
|
|
trait PointeeSized_: PointeeSized { }
|
|
|
|
trait NegPointeeSized: ?PointeeSized { }
|
|
//~^ ERROR relaxed bounds are not permitted in supertrait bounds
|
|
//~| ERROR bound modifier `?` can only be applied to `Sized`
|
|
//~| ERROR bound modifier `?` can only be applied to `Sized`
|
|
//~| ERROR bound modifier `?` can only be applied to `Sized`
|
|
|
|
trait Bare {}
|
|
|
|
fn requires_sized<T: Sized>() {}
|
|
fn requires_metasized<T: MetaSized>() {}
|
|
fn requires_pointeesized<T: PointeeSized>() {}
|
|
|
|
fn with_sized_supertrait<T: PointeeSized + Sized_>() {
|
|
requires_sized::<T>();
|
|
requires_metasized::<T>();
|
|
requires_pointeesized::<T>();
|
|
}
|
|
|
|
fn with_metasized_supertrait<T: PointeeSized + MetaSized_>() {
|
|
requires_sized::<T>();
|
|
//~^ ERROR the size for values of type `T` cannot be known at compilation time
|
|
requires_metasized::<T>();
|
|
requires_pointeesized::<T>();
|
|
}
|
|
|
|
// It isn't really possible to write this one..
|
|
fn with_pointeesized_supertrait<T: PointeeSized + PointeeSized_>() {
|
|
requires_sized::<T>();
|
|
//~^ ERROR the size for values of type `T` cannot be known
|
|
requires_metasized::<T>();
|
|
//~^ ERROR the size for values of type `T` cannot be known
|
|
requires_pointeesized::<T>();
|
|
}
|
|
|
|
// `T` inherits the `const MetaSized` implicit supertrait of `Bare`.
|
|
fn with_bare_trait<T: PointeeSized + Bare>() {
|
|
requires_sized::<T>();
|
|
//~^ ERROR the size for values of type `T` cannot be known
|
|
requires_metasized::<T>();
|
|
requires_pointeesized::<T>();
|
|
}
|
|
|
|
fn main() { }
|