Skip to content

Commit 58a0b8d

Browse files
committed
---
yaml --- r: 59031 b: refs/heads/incoming c: c8e93ed h: refs/heads/master i: 59029: 99d1c4f 59027: 92a3e76 59023: b0d60ab v: v3
1 parent 579d350 commit 58a0b8d

File tree

31 files changed

+557
-256
lines changed

31 files changed

+557
-256
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: 923450d00c142f4f9baed042eedbe88e7004b661
9+
refs/heads/incoming: c8e93edf55d3913212922864034fae8443f92f2a
1010
refs/heads/dist-snap: 00dbbd01c2aee72982b3e0f9511ae1d4428c3ba9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/libcore/condition.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
use prelude::*;
1414
use task;
15-
use task::local_data::{local_data_pop, local_data_set};
15+
use local_data::{local_data_pop, local_data_set};
1616

1717
// helper for transmutation, shown below.
1818
type RustClosure = (int, int);
@@ -24,14 +24,14 @@ pub struct Handler<T, U> {
2424

2525
pub struct Condition<'self, T, U> {
2626
name: &'static str,
27-
key: task::local_data::LocalDataKey<'self, Handler<T, U>>
27+
key: local_data::LocalDataKey<'self, Handler<T, U>>
2828
}
2929

3030
pub impl<'self, T, U> Condition<'self, T, U> {
3131
fn trap(&'self self, h: &'self fn(T) -> U) -> Trap<'self, T, U> {
3232
unsafe {
3333
let p : *RustClosure = ::cast::transmute(&h);
34-
let prev = task::local_data::local_data_get(self.key);
34+
let prev = local_data::local_data_get(self.key);
3535
let h = @Handler { handle: *p, prev: prev };
3636
Trap { cond: self, handler: h }
3737
}

branches/incoming/src/libcore/core.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ pub mod trie;
215215
pub mod task;
216216
pub mod comm;
217217
pub mod pipes;
218+
pub mod local_data;
218219

219220

220221
/* Runtime and platform support */

branches/incoming/src/libcore/os.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,7 @@ fn overridden_arg_key(_v: @OverriddenArgs) {}
12081208
12091209
pub fn args() -> ~[~str] {
12101210
unsafe {
1211-
match task::local_data::local_data_get(overridden_arg_key) {
1211+
match local_data::local_data_get(overridden_arg_key) {
12121212
None => real_args(),
12131213
Some(args) => copy args.val
12141214
}
@@ -1218,7 +1218,7 @@ pub fn args() -> ~[~str] {
12181218
pub fn set_args(new_args: ~[~str]) {
12191219
unsafe {
12201220
let overridden_args = @OverriddenArgs { val: copy new_args };
1221-
task::local_data::local_data_set(overridden_arg_key, overridden_args);
1221+
local_data::local_data_set(overridden_arg_key, overridden_args);
12221222
}
12231223
}
12241224

branches/incoming/src/libcore/prelude.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ pub use io;
8181
pub use iter;
8282
pub use old_iter;
8383
pub use libc;
84+
pub use local_data;
8485
pub use num;
8586
pub use ops;
8687
pub use option;

branches/incoming/src/libcore/rand.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -836,13 +836,13 @@ fn tls_rng_state(_v: @@mut IsaacRng) {}
836836
pub fn task_rng() -> @@mut IsaacRng {
837837
let r : Option<@@mut IsaacRng>;
838838
unsafe {
839-
r = task::local_data::local_data_get(tls_rng_state);
839+
r = local_data::local_data_get(tls_rng_state);
840840
}
841841
match r {
842842
None => {
843843
unsafe {
844844
let rng = @@mut IsaacRng::new_seeded(seed());
845-
task::local_data::local_data_set(tls_rng_state, rng);
845+
local_data::local_data_set(tls_rng_state, rng);
846846
rng
847847
}
848848
}

branches/incoming/src/libcore/rt/local_services.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ mod test {
198198
199199
#[test]
200200
fn tls() {
201-
use task::local_data::*;
201+
use local_data::*;
202202
do run_in_newsched_task() {
203203
unsafe {
204204
fn key(_x: @~str) { }

branches/incoming/src/libcore/task/local_data_priv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use cmp::Eq;
1515
use libc;
1616
use prelude::*;
1717
use task::rt;
18-
use task::local_data::LocalDataKey;
18+
use local_data::LocalDataKey;
1919

2020
use super::rt::rust_task;
2121
use rt::local_services::LocalStorage;

branches/incoming/src/libcore/task/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ use unstable::finally::Finally;
4747
#[cfg(test)] use comm::SharedChan;
4848

4949
mod local_data_priv;
50-
pub mod local_data;
5150
pub mod rt;
5251
pub mod spawn;
5352

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

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -555,18 +555,34 @@ 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::param_bound] {
559-
let mut bounds = ~[];
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+
};
560563
loop {
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-
});
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+
}
570587
}
571-
@bounds
572588
}

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

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -396,19 +396,21 @@ 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::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-
}
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'),
410406
}
411407
}
408+
409+
for bs.trait_bounds.each |&tp| {
410+
w.write_char('I');
411+
enc_trait_ref(w, cx, tp);
412+
}
413+
412414
w.write_char('.');
413415
}
414416

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

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ 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;
1718

1819
use syntax::ast::*;
1920
use syntax::attr::attrs_contains_name;
@@ -338,46 +339,19 @@ pub fn check_bounds(cx: Context,
338339
type_param_def: &ty::TypeParameterDef)
339340
{
340341
let kind = ty::type_contents(cx.tcx, ty);
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-
}
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);
371346
}
372347
}
373-
374348
if !missing.is_empty() {
375349
cx.tcx.sess.span_err(
376350
sp,
377351
fmt!("instantiating a type parameter with an incompatible type \
378352
`%s`, which does not fulfill `%s`",
379353
ty_to_str(cx.tcx, ty),
380-
str::connect_slices(missing, " ")));
354+
missing.user_string(cx.tcx)));
381355
}
382356
}
383357

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

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

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

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,11 @@ 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-
@(**self).subst(tcx, substs)
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+
}
8486
}
8587
}
8688

@@ -115,19 +117,11 @@ impl Subst for ty::BareFnTy {
115117
}
116118
}
117119

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-
}
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)
131125
}
132126
}
133127
}

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

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -968,10 +968,7 @@ 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 {
972-
// For external constants, we don't inline.
973-
let extern_const_values =
974-
&mut *bcx.ccx().extern_const_values;
971+
-> ValueRef {
975972
if did.crate == ast::local_crate {
976973
// The LLVM global has the type of its initializer,
977974
// which may not be equal to the enum's type for
@@ -980,24 +977,25 @@ fn trans_lvalue_unadjusted(bcx: block, expr: @ast::expr) -> DatumBlock {
980977
base::get_item_val(bcx.ccx(), did.node),
981978
T_ptr(type_of(bcx.ccx(), const_ty)))
982979
} else {
983-
match extern_const_values.find(&did) {
984-
None => {} // Continue.
985-
Some(llval) => {
986-
return *llval;
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+
}
987997
}
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
998+
Some(llval) => *llval
1001999
}
10021000
}
10031001
}

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -348,14 +348,9 @@ 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.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-
}
351+
for type_param_def.bounds.trait_bounds.each |_bound| {
352+
v.push(meth::vtable_id(ccx, /*bad*/copy vts[i]));
353+
i += 1;
359354
}
360355
(*subst, if !v.is_empty() { Some(v) } else { None })
361356
})

0 commit comments

Comments
 (0)