diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index b96a75cba9480..c3a001116b34c 100644 --- a/src/librustc/middle/kind.rs +++ b/src/librustc/middle/kind.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - use middle::freevars::freevar_entry; use middle::freevars; use middle::subst; @@ -593,7 +592,7 @@ fn check_ty(cx: &mut Context, aty: &Ty) { match aty.node { TyPath(_, _, id) => { match cx.tcx.item_substs.borrow().find(&id) { - None => { } + None => {} Some(ref item_substs) => { let def_map = cx.tcx.def_map.borrow(); let did = def_map.get_copy(&id).def_id(); @@ -601,7 +600,7 @@ fn check_ty(cx: &mut Context, aty: &Ty) { for def in generics.types.iter() { let ty = *item_substs.substs.types.get(def.space, def.index); - check_typaram_bounds(cx, aty.span, ty, def) + check_typaram_bounds(cx, aty.span, ty, def); } } } @@ -674,7 +673,7 @@ fn check_bounds_on_structs_or_enums_in_type_if_possible(cx: &mut Context, .zip(polytype.generics .types .iter()) { - check_typaram_bounds(cx, span, *ty, type_param_def) + check_typaram_bounds(cx, span, *ty, type_param_def); } // Check trait bounds. diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 2d3096d13eae0..2cd76404ecbac 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -2362,7 +2362,7 @@ pub fn type_contents(cx: &ctxt, ty: t) -> TypeContents { } ty_trait(box ty::TyTrait { bounds, .. }) => { - object_contents(cx, bounds) | TC::ReachesFfiUnsafe + object_contents(cx, bounds) | TC::ReachesFfiUnsafe | TC::Nonsized } ty_ptr(ref mt) => { diff --git a/src/test/compile-fail/bad-sized.rs b/src/test/compile-fail/bad-sized.rs new file mode 100644 index 0000000000000..fb9a060cb602a --- /dev/null +++ b/src/test/compile-fail/bad-sized.rs @@ -0,0 +1,25 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-tidy-linelength + +use std::cell::RefCell; + +trait Trait {} + +pub fn main() { + let x: Vec = Vec::new(); + //~^ ERROR instantiating a type parameter with an incompatible type `Trait+Sized`, which does not fulfill `Sized` + //~^^ ERROR instantiating a type parameter with an incompatible type `Trait+Sized`, which does not fulfill `Sized` + //~^^^ ERROR instantiating a type parameter with an incompatible type `Trait+Sized`, which does not fulfill `Sized` + let x: Vec>> = Vec::new(); + //~^ ERROR instantiating a type parameter with an incompatible type `Trait+Sized`, which does not fulfill `Sized` + //~^^ ERROR instantiating a type parameter with an incompatible type `Trait+Sized`, which does not fulfill `Sized` +}