Skip to content

Commit 579d350

Browse files
committed
---
yaml --- r: 59030 b: refs/heads/incoming c: 923450d h: refs/heads/master v: v3
1 parent 99d1c4f commit 579d350

File tree

16 files changed

+235
-535
lines changed

16 files changed

+235
-535
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: c50a9d5b664478e533ba1d1d353213d70c8ad589
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/incoming: ad8e236f32fccf6ec99025e2ba77f79b4c98d399
9+
refs/heads/incoming: 923450d00c142f4f9baed042eedbe88e7004b661
1010
refs/heads/dist-snap: 00dbbd01c2aee72982b3e0f9511ae1d4428c3ba9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/librustc/metadata/tydecode.rs

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -555,34 +555,18 @@ fn parse_type_param_def(st: @mut PState, conv: conv_did) -> ty::TypeParameterDef
555555
bounds: parse_bounds(st, conv)}
556556
}
557557
558-
fn parse_bounds(st: @mut PState, conv: conv_did) -> @ty::ParamBounds {
559-
let mut param_bounds = ty::ParamBounds {
560-
builtin_bounds: ty::EmptyBuiltinBounds(),
561-
trait_bounds: ~[]
562-
};
558+
fn parse_bounds(st: @mut PState, conv: conv_did) -> @~[ty::param_bound] {
559+
let mut bounds = ~[];
563560
loop {
564-
match next(st) {
565-
'S' => {
566-
param_bounds.builtin_bounds.add(ty::BoundOwned);
567-
}
568-
'C' => {
569-
param_bounds.builtin_bounds.add(ty::BoundCopy);
570-
}
571-
'K' => {
572-
param_bounds.builtin_bounds.add(ty::BoundConst);
573-
}
574-
'O' => {
575-
param_bounds.builtin_bounds.add(ty::BoundStatic);
576-
}
577-
'I' => {
578-
param_bounds.trait_bounds.push(@parse_trait_ref(st, conv));
579-
}
580-
'.' => {
581-
return @param_bounds;
582-
}
583-
_ => {
584-
fail!(~"parse_bounds: bad bounds")
585-
}
586-
}
561+
bounds.push(match next(st) {
562+
'S' => ty::bound_owned,
563+
'C' => ty::bound_copy,
564+
'K' => ty::bound_const,
565+
'O' => ty::bound_durable,
566+
'I' => ty::bound_trait(@parse_trait_ref(st, conv)),
567+
'.' => break,
568+
_ => fail!(~"parse_bounds: bad bounds")
569+
});
587570
}
571+
@bounds
588572
}

branches/incoming/src/librustc/metadata/tyencode.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -396,21 +396,19 @@ fn enc_fn_sig(w: @io::Writer, cx: @ctxt, fsig: &ty::FnSig) {
396396
enc_ty(w, cx, fsig.output);
397397
}
398398

399-
fn enc_bounds(w: @io::Writer, cx: @ctxt, bs: @ty::ParamBounds) {
400-
for bs.builtin_bounds.each |bound| {
401-
match bound {
402-
ty::BoundOwned => w.write_char('S'),
403-
ty::BoundCopy => w.write_char('C'),
404-
ty::BoundConst => w.write_char('K'),
405-
ty::BoundStatic => w.write_char('O'),
399+
fn enc_bounds(w: @io::Writer, cx: @ctxt, bs: @~[ty::param_bound]) {
400+
for (*bs).each |bound| {
401+
match *bound {
402+
ty::bound_owned => w.write_char('S'),
403+
ty::bound_copy => w.write_char('C'),
404+
ty::bound_const => w.write_char('K'),
405+
ty::bound_durable => w.write_char('O'),
406+
ty::bound_trait(tp) => {
407+
w.write_char('I');
408+
enc_trait_ref(w, cx, tp);
409+
}
406410
}
407411
}
408-
409-
for bs.trait_bounds.each |&tp| {
410-
w.write_char('I');
411-
enc_trait_ref(w, cx, tp);
412-
}
413-
414412
w.write_char('.');
415413
}
416414

branches/incoming/src/librustc/middle/kind.rs

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use middle::pat_util;
1414
use middle::ty;
1515
use middle::typeck;
1616
use util::ppaux::{Repr, ty_to_str};
17-
use util::ppaux::UserString;
1817

1918
use syntax::ast::*;
2019
use syntax::attr::attrs_contains_name;
@@ -339,19 +338,46 @@ pub fn check_bounds(cx: Context,
339338
type_param_def: &ty::TypeParameterDef)
340339
{
341340
let kind = ty::type_contents(cx.tcx, ty);
342-
let mut missing = ty::EmptyBuiltinBounds();
343-
for type_param_def.bounds.builtin_bounds.each |bound| {
344-
if !kind.meets_bound(cx.tcx, bound) {
345-
missing.add(bound);
341+
let mut missing = ~[];
342+
for type_param_def.bounds.each |bound| {
343+
match *bound {
344+
ty::bound_trait(_) => {
345+
/* Not our job, checking in typeck */
346+
}
347+
348+
ty::bound_copy => {
349+
if !kind.is_copy(cx.tcx) {
350+
missing.push("Copy");
351+
}
352+
}
353+
354+
ty::bound_durable => {
355+
if !kind.is_durable(cx.tcx) {
356+
missing.push("'static");
357+
}
358+
}
359+
360+
ty::bound_owned => {
361+
if !kind.is_owned(cx.tcx) {
362+
missing.push("Owned");
363+
}
364+
}
365+
366+
ty::bound_const => {
367+
if !kind.is_const(cx.tcx) {
368+
missing.push("Const");
369+
}
370+
}
346371
}
347372
}
373+
348374
if !missing.is_empty() {
349375
cx.tcx.sess.span_err(
350376
sp,
351377
fmt!("instantiating a type parameter with an incompatible type \
352378
`%s`, which does not fulfill `%s`",
353379
ty_to_str(cx.tcx, ty),
354-
missing.user_string(cx.tcx)));
380+
str::connect_slices(missing, " ")));
355381
}
356382
}
357383

@@ -414,7 +440,7 @@ pub fn check_owned(cx: Context, ty: ty::t, sp: span) -> bool {
414440

415441
// note: also used from middle::typeck::regionck!
416442
pub fn check_durable(tcx: ty::ctxt, ty: ty::t, sp: span) -> bool {
417-
if !ty::type_is_static(tcx, ty) {
443+
if !ty::type_is_durable(tcx, ty) {
418444
match ty::get(ty).sty {
419445
ty::ty_param(*) => {
420446
tcx.sess.span_err(sp, "value may contain borrowed \

branches/incoming/src/librustc/middle/subst.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,9 @@ impl<T:Subst> Subst for ~[T] {
7878
}
7979
}
8080

81-
impl<T:Subst> Subst for @T {
82-
fn subst(&self, tcx: ty::ctxt, substs: &ty::substs) -> @T {
83-
match self {
84-
&@ref t => @t.subst(tcx, substs)
85-
}
81+
impl<T:Subst> Subst for @~[T] {
82+
fn subst(&self, tcx: ty::ctxt, substs: &ty::substs) -> @~[T] {
83+
@(**self).subst(tcx, substs)
8684
}
8785
}
8886

@@ -117,11 +115,19 @@ impl Subst for ty::BareFnTy {
117115
}
118116
}
119117

120-
impl Subst for ty::ParamBounds {
121-
fn subst(&self, tcx: ty::ctxt, substs: &ty::substs) -> ty::ParamBounds {
122-
ty::ParamBounds {
123-
builtin_bounds: self.builtin_bounds,
124-
trait_bounds: self.trait_bounds.subst(tcx, substs)
118+
impl Subst for ty::param_bound {
119+
fn subst(&self, tcx: ty::ctxt, substs: &ty::substs) -> ty::param_bound {
120+
match self {
121+
&ty::bound_copy |
122+
&ty::bound_durable |
123+
&ty::bound_owned |
124+
&ty::bound_const => {
125+
*self
126+
}
127+
128+
&ty::bound_trait(tref) => {
129+
ty::bound_trait(@tref.subst(tcx, substs))
130+
}
125131
}
126132
}
127133
}

branches/incoming/src/librustc/middle/trans/expr.rs

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,10 @@ fn trans_lvalue_unadjusted(bcx: block, expr: @ast::expr) -> DatumBlock {
968968
}
969969

970970
fn get_val(bcx: block, did: ast::def_id, const_ty: ty::t)
971-
-> ValueRef {
971+
-> ValueRef {
972+
// For external constants, we don't inline.
973+
let extern_const_values =
974+
&mut *bcx.ccx().extern_const_values;
972975
if did.crate == ast::local_crate {
973976
// The LLVM global has the type of its initializer,
974977
// which may not be equal to the enum's type for
@@ -977,25 +980,24 @@ fn trans_lvalue_unadjusted(bcx: block, expr: @ast::expr) -> DatumBlock {
977980
base::get_item_val(bcx.ccx(), did.node),
978981
T_ptr(type_of(bcx.ccx(), const_ty)))
979982
} else {
980-
// For external constants, we don't inline.
981-
match bcx.ccx().extern_const_values.find(&did) {
982-
None => {
983-
unsafe {
984-
let llty = type_of(bcx.ccx(), const_ty);
985-
let symbol = csearch::get_symbol(
986-
bcx.ccx().sess.cstore,
987-
did);
988-
let llval = llvm::LLVMAddGlobal(
989-
bcx.ccx().llmod,
990-
llty,
991-
transmute::<&u8,*i8>(&symbol[0]));
992-
bcx.ccx().extern_const_values.insert(
993-
did,
994-
llval);
995-
llval
996-
}
983+
match extern_const_values.find(&did) {
984+
None => {} // Continue.
985+
Some(llval) => {
986+
return *llval;
997987
}
998-
Some(llval) => *llval
988+
}
989+
990+
unsafe {
991+
let llty = type_of(bcx.ccx(), const_ty);
992+
let symbol = csearch::get_symbol(
993+
bcx.ccx().sess.cstore,
994+
did);
995+
let llval = llvm::LLVMAddGlobal(
996+
bcx.ccx().llmod,
997+
llty,
998+
transmute::<&u8,*i8>(&symbol[0]));
999+
extern_const_values.insert(did, llval);
1000+
llval
9991001
}
10001002
}
10011003
}

branches/incoming/src/librustc/middle/trans/monomorphize.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,14 @@ pub fn make_mono_id(ccx: @CrateContext,
348348
let mut i = 0;
349349
vec::map_zip(*item_ty.generics.type_param_defs, substs, |type_param_def, subst| {
350350
let mut v = ~[];
351-
for type_param_def.bounds.trait_bounds.each |_bound| {
352-
v.push(meth::vtable_id(ccx, /*bad*/copy vts[i]));
353-
i += 1;
351+
for type_param_def.bounds.each |bound| {
352+
match *bound {
353+
ty::bound_trait(_) => {
354+
v.push(meth::vtable_id(ccx, /*bad*/copy vts[i]));
355+
i += 1;
356+
}
357+
_ => ()
358+
}
354359
}
355360
(*subst, if !v.is_empty() { Some(v) } else { None })
356361
})

0 commit comments

Comments
 (0)