mirror of
				https://github.com/rust-lang/rust.git
				synced 2025-10-31 04:57:19 +00:00 
			
		
		
		
	 86ab2b60cd
			
		
	
	
		86ab2b60cd
		
			
		
	
	
	
	
		
			
			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
		
	
	
		
			660 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			660 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
| //@ check-pass
 | |
| #![feature(sized_hierarchy)]
 | |
| 
 | |
| // This is a reduction of some code in `library/core/src/cmp.rs` that would ICE if a default
 | |
| // `Pointee` bound is added - motivating the current status quo of `PointeeSized` being syntactic
 | |
| // sugar for an absense of any bounds whatsoever.
 | |
| 
 | |
| use std::marker::PhantomData;
 | |
| 
 | |
| pub trait Bar<'a> {
 | |
|     type Foo;
 | |
| }
 | |
| 
 | |
| pub struct Foo<'a, T: Bar<'a>> {
 | |
|     phantom: PhantomData<&'a T>,
 | |
| }
 | |
| 
 | |
| impl<'a, 'b, T> PartialEq<Foo<'b, T>> for Foo<'a, T>
 | |
|     where
 | |
|         T: for<'c> Bar<'c>,
 | |
|         <T as Bar<'a>>::Foo: PartialEq<<T as Bar<'b>>::Foo>,
 | |
| {
 | |
|     fn eq(&self, _: &Foo<'b, T>) -> bool {
 | |
|         loop {}
 | |
|     }
 | |
| }
 | |
| 
 | |
| fn main() { }
 |