mirror of
https://github.com/rust-lang/rust.git
synced 2025-09-30 16:26:10 +00:00

Opting-out of `Sized` with `?Sized` is now equivalent to adding a `MetaSized` bound, and adding a `MetaSized` or `PointeeSized` bound is equivalent to removing the default `Sized` bound - this commit implements this change in `rustc_hir_analysis::hir_ty_lowering`. `MetaSized` is also added as a supertrait of all traits, as this is necessary to preserve backwards compatibility. Unfortunately, non-global where clauses being preferred over item bounds (where `PointeeSized` bounds would be proven) - which can result in errors when a `PointeeSized` supertrait/bound/predicate is added to some items. Rather than `PointeeSized` being a bound on everything, it can be the absence of a bound on everything, as `?Sized` was.
30 lines
771 B
Rust
30 lines
771 B
Rust
#![feature(extern_types)]
|
|
#![feature(sized_hierarchy)]
|
|
|
|
use std::marker::{MetaSized, PointeeSized};
|
|
|
|
fn needs_pointeesized<T: PointeeSized>() {}
|
|
fn needs_metasized<T: MetaSized>() {}
|
|
fn needs_sized<T: Sized>() {}
|
|
|
|
fn main() {
|
|
needs_pointeesized::<u8>();
|
|
needs_metasized::<u8>();
|
|
needs_sized::<u8>();
|
|
|
|
needs_pointeesized::<str>();
|
|
needs_metasized::<str>();
|
|
needs_sized::<str>();
|
|
//~^ ERROR the size for values of type `str` cannot be known at compilation time
|
|
|
|
extern "C" {
|
|
type Foo;
|
|
}
|
|
|
|
needs_pointeesized::<Foo>();
|
|
needs_metasized::<Foo>();
|
|
//~^ ERROR the size for values of type `main::Foo` cannot be known
|
|
needs_sized::<Foo>();
|
|
//~^ ERROR the size for values of type `main::Foo` cannot be known at compilation time
|
|
}
|