forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#127681 - dingxiangfei2009:smart-ptr-bounds,…
… r=compiler-errors derive(SmartPointer): rewrite bounds in where and generic bounds Fix rust-lang#127647 Due to the `Unsize` bounds, we need to commute the bounds on the pointee type to the new self type. cc ``@Darksonn``
- Loading branch information
Showing
4 changed files
with
371 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//@ check-pass | ||
//@ compile-flags: -Zunpretty=expanded | ||
#![feature(derive_smart_pointer)] | ||
use std::marker::SmartPointer; | ||
|
||
pub trait MyTrait<T: ?Sized> {} | ||
|
||
#[derive(SmartPointer)] | ||
#[repr(transparent)] | ||
struct MyPointer<'a, #[pointee] T: ?Sized> { | ||
ptr: &'a T, | ||
} | ||
|
||
#[derive(core::marker::SmartPointer)] | ||
#[repr(transparent)] | ||
pub struct MyPointer2<'a, Y, Z: MyTrait<T>, #[pointee] T: ?Sized + MyTrait<T>, X: MyTrait<T> = ()> | ||
where | ||
Y: MyTrait<T>, | ||
{ | ||
data: &'a mut T, | ||
x: core::marker::PhantomData<X>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#![feature(prelude_import)] | ||
#![no_std] | ||
//@ check-pass | ||
//@ compile-flags: -Zunpretty=expanded | ||
#![feature(derive_smart_pointer)] | ||
#[prelude_import] | ||
use ::std::prelude::rust_2015::*; | ||
#[macro_use] | ||
extern crate std; | ||
use std::marker::SmartPointer; | ||
|
||
pub trait MyTrait<T: ?Sized> {} | ||
|
||
#[repr(transparent)] | ||
struct MyPointer<'a, #[pointee] T: ?Sized> { | ||
ptr: &'a T, | ||
} | ||
#[automatically_derived] | ||
impl<'a, T: ?Sized + ::core::marker::Unsize<__S>, __S: ?Sized> | ||
::core::ops::DispatchFromDyn<MyPointer<'a, __S>> for MyPointer<'a, T> { | ||
} | ||
#[automatically_derived] | ||
impl<'a, T: ?Sized + ::core::marker::Unsize<__S>, __S: ?Sized> | ||
::core::ops::CoerceUnsized<MyPointer<'a, __S>> for MyPointer<'a, T> { | ||
} | ||
|
||
#[repr(transparent)] | ||
pub struct MyPointer2<'a, Y, Z: MyTrait<T>, #[pointee] T: ?Sized + MyTrait<T>, | ||
X: MyTrait<T> = ()> where Y: MyTrait<T> { | ||
data: &'a mut T, | ||
x: core::marker::PhantomData<X>, | ||
} | ||
#[automatically_derived] | ||
impl<'a, Y, Z: MyTrait<T> + MyTrait<__S>, T: ?Sized + MyTrait<T> + | ||
::core::marker::Unsize<__S>, __S: ?Sized + MyTrait<__S>, X: MyTrait<T> + | ||
MyTrait<__S>> ::core::ops::DispatchFromDyn<MyPointer2<'a, Y, Z, __S, X>> | ||
for MyPointer2<'a, Y, Z, T, X> where Y: MyTrait<T>, Y: MyTrait<__S> { | ||
} | ||
#[automatically_derived] | ||
impl<'a, Y, Z: MyTrait<T> + MyTrait<__S>, T: ?Sized + MyTrait<T> + | ||
::core::marker::Unsize<__S>, __S: ?Sized + MyTrait<__S>, X: MyTrait<T> + | ||
MyTrait<__S>> ::core::ops::CoerceUnsized<MyPointer2<'a, Y, Z, __S, X>> for | ||
MyPointer2<'a, Y, Z, T, X> where Y: MyTrait<T>, Y: MyTrait<__S> { | ||
} |
Oops, something went wrong.