auto merge of #16811 : nick29581/rust/dst-bug-2, r=nikomatsakis
closes #16800 r? @nikomatsakis - I'm not 100% sure this is the right approach, it is kind of ad-hoc. The trouble is we don't have any intrinsic notion of which types are sized and which are not, we only have the Sized bound, so I have nothing to validate the Sized bound against.
This commit is contained in:
commit
9b81a4eef8
@ -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;
|
||||
@ -587,7 +586,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();
|
||||
@ -595,7 +594,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -668,7 +667,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.
|
||||
|
@ -2410,7 +2410,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) => {
|
||||
|
25
src/test/compile-fail/bad-sized.rs
Normal file
25
src/test/compile-fail/bad-sized.rs
Normal file
@ -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 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<Trait + Sized> = 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<Box<RefCell<Trait + Sized>>> = 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`
|
||||
}
|
Loading…
Reference in New Issue
Block a user