auto merge of #17003 : nick29581/rust/impl, r=pcwalton

closes #16955 

r? @pcwalton
This commit is contained in:
bors 2014-09-06 14:51:26 +00:00
commit 6eabd85265
3 changed files with 21 additions and 13 deletions

View File

@ -175,9 +175,7 @@ fn check_impl_of_trait(cx: &mut Context, it: &Item, trait_ref: &TraitRef, self_t
fn check_item(cx: &mut Context, item: &Item) { fn check_item(cx: &mut Context, item: &Item) {
if !attr::contains_name(item.attrs.as_slice(), "unsafe_destructor") { if !attr::contains_name(item.attrs.as_slice(), "unsafe_destructor") {
match item.node { match item.node {
ItemImpl(_, Some(ref trait_ref), ref self_type, _) => { ItemImpl(_, ref trait_ref, ref self_type, _) => {
check_impl_of_trait(cx, item, trait_ref, &**self_type);
let parameter_environment = let parameter_environment =
ParameterEnvironment::for_item(cx.tcx, item.id); ParameterEnvironment::for_item(cx.tcx, item.id);
cx.parameter_environments.push(parameter_environment); cx.parameter_environments.push(parameter_environment);
@ -188,16 +186,23 @@ fn check_item(cx: &mut Context, item: &Item) {
item.span, item.span,
ty::node_id_to_type(cx.tcx, item.id)); ty::node_id_to_type(cx.tcx, item.id));
// Check bounds on the trait ref. match trait_ref {
match ty::impl_trait_ref(cx.tcx, &Some(ref trait_ref) => {
ast_util::local_def(item.id)) { check_impl_of_trait(cx, item, trait_ref, &**self_type);
None => {}
Some(trait_ref) => { // Check bounds on the trait ref.
check_bounds_on_structs_or_enums_in_trait_ref( match ty::impl_trait_ref(cx.tcx,
cx, ast_util::local_def(item.id)) {
item.span, None => {}
&*trait_ref); Some(trait_ref) => {
check_bounds_on_structs_or_enums_in_trait_ref(
cx,
item.span,
&*trait_ref);
}
}
} }
&None => {}
} }
drop(cx.parameter_environments.pop()); drop(cx.parameter_environments.pop());

View File

@ -28,7 +28,8 @@ fn kaboom(y: Bar<f32>) {}
//~^ ERROR failed to find an implementation //~^ ERROR failed to find an implementation
//~^^ ERROR instantiating a type parameter with an incompatible type //~^^ ERROR instantiating a type parameter with an incompatible type
impl<T> Foo<T> { impl<T> Foo<T> { //~ ERROR failed to find an implementation
//~^ ERROR instantiating a type parameter with an incompatible type
fn uhoh() {} fn uhoh() {}
} }

View File

@ -76,6 +76,8 @@ trait T3<Sized? Z> {
struct S4<Y>; struct S4<Y>;
impl<Sized? X> T3<X> for S4<X> { //~ ERROR instantiating a type parameter with an incompatible type impl<Sized? X> T3<X> for S4<X> { //~ ERROR instantiating a type parameter with an incompatible type
} }
impl<Sized? X> S4<X> { //~ ERROR instantiating a type parameter with an incompatible type
}
pub fn main() { pub fn main() {