mirror of
https://github.com/rust-lang/rust.git
synced 2025-10-03 18:57:19 +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.
29 lines
642 B
Rust
29 lines
642 B
Rust
//@ check-pass
|
|
//@ compile-flags: --crate-type=lib
|
|
//@ revisions: old next
|
|
//@[next] compile-flags: -Znext-solver
|
|
#![feature(sized_hierarchy)]
|
|
|
|
use std::marker::{PointeeSized, MetaSized};
|
|
|
|
trait Id: PointeeSized {
|
|
type This: PointeeSized;
|
|
}
|
|
|
|
impl<T: PointeeSized> Id for T {
|
|
type This = T;
|
|
}
|
|
|
|
fn requires_metasized<T: MetaSized>() {}
|
|
|
|
fn foo<T>()
|
|
where
|
|
T: PointeeSized,
|
|
<T as Id>::This: Sized
|
|
{
|
|
// `T: Sized` from where bounds (`T: PointeeSized` removes any default bounds and
|
|
// `<T as Id>::This: Sized` normalizes to `T: Sized`). This should trivially satisfy
|
|
// `T: MetaSized`.
|
|
requires_metasized::<T>();
|
|
}
|