Use ty::type_is_sized() so that we handle projection types properly.

This commit is contained in:
Niko Matsakis
2015-01-07 12:49:52 -05:00
parent 6300a97216
commit 9e4e8823c7
3 changed files with 21 additions and 8 deletions
+1 -4
View File
@@ -135,10 +135,7 @@ fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
t
}
ty::ty_open(..) => {
self.tcx().sess.bug("Cannot freshen an open existential type");
}
ty::ty_open(..) |
ty::ty_bool |
ty::ty_char |
ty::ty_int(..) |
+16 -1
View File
@@ -1457,11 +1457,26 @@ fn builtin_bound(&mut self,
Ok(AmbiguousBuiltin)
}
ty::ty_open(ty) => {
// these only crop up in trans, and represent an
// "opened" unsized/existential type (one that has
// been dereferenced)
match bound {
ty::BoundCopy |
ty::BoundSync |
ty::BoundSend => {
Ok(If(vec!(ty)))
}
ty::BoundSized => {
Err(Unimplemented)
}
}
}
ty::ty_err => {
Ok(If(Vec::new()))
}
ty::ty_open(_) |
ty::ty_infer(ty::FreshTy(_)) |
ty::ty_infer(ty::FreshIntTy(_)) => {
self.tcx().sess.bug(
+4 -3
View File
@@ -50,7 +50,7 @@
use syntax::ast::Ident;
use syntax::ast;
use syntax::ast_map::{PathElem, PathName};
use syntax::codemap::Span;
use syntax::codemap::{DUMMY_SP, Span};
use syntax::parse::token::InternedString;
use syntax::parse::token;
use util::common::memoized;
@@ -114,8 +114,9 @@ fn fold_substs(&mut self,
}
// Is the type's representation size known at compile time?
pub fn type_is_sized<'tcx>(cx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
ty::type_contents(cx, ty).is_sized(cx)
pub fn type_is_sized<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
let param_env = ty::empty_parameter_environment(tcx);
ty::type_is_sized(&param_env, DUMMY_SP, ty)
}
pub fn lltype_is_sized<'tcx>(cx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {