Skip to content

Commit 9e4e882

Browse files
committed
Use ty::type_is_sized() so that we handle projection types properly.
1 parent 6300a97 commit 9e4e882

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

src/librustc/middle/infer/freshen.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
135135
t
136136
}
137137

138-
ty::ty_open(..) => {
139-
self.tcx().sess.bug("Cannot freshen an open existential type");
140-
}
141-
138+
ty::ty_open(..) |
142139
ty::ty_bool |
143140
ty::ty_char |
144141
ty::ty_int(..) |

src/librustc/middle/traits/select.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1457,11 +1457,26 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
14571457
Ok(AmbiguousBuiltin)
14581458
}
14591459

1460+
ty::ty_open(ty) => {
1461+
// these only crop up in trans, and represent an
1462+
// "opened" unsized/existential type (one that has
1463+
// been dereferenced)
1464+
match bound {
1465+
ty::BoundCopy |
1466+
ty::BoundSync |
1467+
ty::BoundSend => {
1468+
Ok(If(vec!(ty)))
1469+
}
1470+
1471+
ty::BoundSized => {
1472+
Err(Unimplemented)
1473+
}
1474+
}
1475+
}
14601476
ty::ty_err => {
14611477
Ok(If(Vec::new()))
14621478
}
14631479

1464-
ty::ty_open(_) |
14651480
ty::ty_infer(ty::FreshTy(_)) |
14661481
ty::ty_infer(ty::FreshIntTy(_)) => {
14671482
self.tcx().sess.bug(

src/librustc_trans/trans/common.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ use std::vec::Vec;
5050
use syntax::ast::Ident;
5151
use syntax::ast;
5252
use syntax::ast_map::{PathElem, PathName};
53-
use syntax::codemap::Span;
53+
use syntax::codemap::{DUMMY_SP, Span};
5454
use syntax::parse::token::InternedString;
5555
use syntax::parse::token;
5656
use util::common::memoized;
@@ -114,8 +114,9 @@ pub fn normalize_ty<'tcx>(cx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
114114
}
115115

116116
// Is the type's representation size known at compile time?
117-
pub fn type_is_sized<'tcx>(cx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
118-
ty::type_contents(cx, ty).is_sized(cx)
117+
pub fn type_is_sized<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
118+
let param_env = ty::empty_parameter_environment(tcx);
119+
ty::type_is_sized(&param_env, DUMMY_SP, ty)
119120
}
120121

121122
pub fn lltype_is_sized<'tcx>(cx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {

0 commit comments

Comments
 (0)