rollup merge of #17008 : nick29581/impl2
This commit is contained in:
commit
f48b701213
@ -55,6 +55,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
use kinds::Sized;
|
||||
|
||||
/**
|
||||
*
|
||||
* The `Drop` trait is used to run some code when a value goes out of scope. This
|
||||
@ -700,7 +702,7 @@ pub trait IndexMut<Index,Result> {
|
||||
* ```
|
||||
*/
|
||||
#[lang="deref"]
|
||||
pub trait Deref<Result> {
|
||||
pub trait Deref<Sized? Result> {
|
||||
/// The method called to dereference a value
|
||||
fn deref<'a>(&'a self) -> &'a Result;
|
||||
}
|
||||
@ -740,7 +742,7 @@ pub trait Deref<Result> {
|
||||
* ```
|
||||
*/
|
||||
#[lang="deref_mut"]
|
||||
pub trait DerefMut<Result>: Deref<Result> {
|
||||
pub trait DerefMut<Sized? Result>: Deref<Result> {
|
||||
/// The method called to mutably dereference a value
|
||||
fn deref_mut<'a>(&'a mut self) -> &'a mut Result;
|
||||
}
|
||||
|
@ -199,6 +199,15 @@ fn check_item(cx: &mut Context, item: &Item) {
|
||||
cx,
|
||||
item.span,
|
||||
&*trait_ref);
|
||||
|
||||
let trait_def = ty::lookup_trait_def(cx.tcx, trait_ref.def_id);
|
||||
for (ty, type_param_def) in trait_ref.substs.types
|
||||
.iter()
|
||||
.zip(trait_def.generics
|
||||
.types
|
||||
.iter()) {
|
||||
check_typaram_bounds(cx, item.span, *ty, type_param_def);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -57,20 +57,18 @@ fn f9<Sized? X>(x1: Box<S<X>>, x2: Box<E<X>>) {
|
||||
//~^ ERROR instantiating a type parameter with an incompatible type
|
||||
}
|
||||
|
||||
// I would like these to fail eventually.
|
||||
/*
|
||||
// impl - bounded
|
||||
trait T1<Z: T> {
|
||||
}
|
||||
struct S3<Sized? Y>;
|
||||
impl<Sized? X: T> T1<X> for S3<X> { //ERROR instantiating a type parameter with an incompatible type
|
||||
impl<Sized? X: T> T1<X> for S3<X> { //~ ERROR instantiating a type parameter with an incompatible
|
||||
}
|
||||
|
||||
// impl - unbounded
|
||||
trait T2<Z> {
|
||||
}
|
||||
impl<Sized? X> T2<X> for S3<X> { //ERROR instantiating a type parameter with an incompatible type `X
|
||||
*/
|
||||
impl<Sized? X> T2<X> for S3<X> { //~ ERROR instantiating a type parameter with an incompatible type
|
||||
}
|
||||
|
||||
// impl - struct
|
||||
trait T3<Sized? Z> {
|
||||
|
Loading…
Reference in New Issue
Block a user