Skip to content

Commit 39c594f

Browse files
committed
---
yaml --- r: 93814 b: refs/heads/try c: efe9d74 h: refs/heads/master v: v3
1 parent a4da312 commit 39c594f

File tree

21 files changed

+481
-611
lines changed

21 files changed

+481
-611
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 0da105a8b7b6b1e0568e8ff20f6ff4b13cc7ecc2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d3e57dca68fde4effdda3e4ae2887aa535fcd6
5-
refs/heads/try: 09ed7913e43cf0234a1bbe3f29dcd52c6a166961
5+
refs/heads/try: efe9d744f986e762fe4d309298be38723ef260fb
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/doc/tutorial.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,8 +1320,7 @@ let z = x; // this moves `x` into `z`, rather than creating a new owner
13201320

13211321
assert_eq!(*z.borrow(), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
13221322

1323-
// the variable is mutable, but not the contents of the box
1324-
let mut a = Rc::new([10, 9, 8, 7, 6, 5, 4, 3, 2, 1]);
1323+
let mut a = Rc::new([10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); // the variable is mutable, but not the box
13251324
a = z;
13261325
~~~
13271326

branches/try/src/librustc/front/feature_gate.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,11 @@ impl Visitor<()> for Context {
141141
},
142142
ast::ty_box(_) => {
143143
self.gate_feature("managed_boxes", t.span,
144-
"The managed box syntax is being replaced by the `std::gc::Gc`
145-
and `std::rc::Rc` types. Equivalent functionality to managed
146-
trait objects will be implemented but is currently missing.");
144+
"The managed box syntax will be replaced \
145+
by a library type, and a garbage \
146+
collector is not yet implemented. \
147+
Consider using the `std::rc::Rc` type \
148+
for reference counted pointers.");
147149
}
148150
_ => {}
149151
}

branches/try/src/librustc/middle/privacy.rs

Lines changed: 356 additions & 397 deletions
Large diffs are not rendered by default.

branches/try/src/librustc/middle/reachable.rs

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use middle::privacy;
2222
use std::hashmap::HashSet;
2323
use syntax::ast;
2424
use syntax::ast_map;
25-
use syntax::ast_util::{def_id_of_def, is_local};
25+
use syntax::ast_util::{def_id_of_def, is_local, local_def};
2626
use syntax::attr;
2727
use syntax::parse::token;
2828
use syntax::visit::Visitor;
@@ -310,13 +310,47 @@ impl ReachableContext {
310310
}
311311
}
312312

313+
// Implementations of exported structs/enums need to get
314+
// added to the worklist (as all their methods should be
315+
// accessible)
316+
ast::item_struct(*) | ast::item_enum(*) => {
317+
let def = local_def(item.id);
318+
let impls = match self.tcx.inherent_impls.find(&def) {
319+
Some(&impls) => impls,
320+
None => return
321+
};
322+
for imp in impls.iter() {
323+
if is_local(imp.did) {
324+
self.worklist.push(imp.did.node);
325+
}
326+
}
327+
}
328+
329+
// Propagate through this impl
330+
ast::item_impl(_, _, _, ref methods) => {
331+
for method in methods.iter() {
332+
self.worklist.push(method.id);
333+
}
334+
}
335+
336+
// Default methods of exported traits need to all be
337+
// accessible.
338+
ast::item_trait(_, _, ref methods) => {
339+
for method in methods.iter() {
340+
match *method {
341+
ast::required(*) => {}
342+
ast::provided(ref method) => {
343+
self.worklist.push(method.id);
344+
}
345+
}
346+
}
347+
}
348+
313349
// These are normal, nothing reachable about these
314350
// inherently and their children are already in the
315-
// worklist, as determined by the privacy pass
351+
// worklist
316352
ast::item_static(*) | ast::item_ty(*) |
317-
ast::item_mod(*) | ast::item_foreign_mod(*) |
318-
ast::item_impl(*) | ast::item_trait(*) |
319-
ast::item_struct(*) | ast::item_enum(*) => {}
353+
ast::item_mod(*) | ast::item_foreign_mod(*) => {}
320354

321355
_ => {
322356
self.tcx.sess.span_bug(item.span,

branches/try/src/librustc/middle/trans/base.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2759,7 +2759,6 @@ pub fn declare_intrinsics(llmod: ModuleRef) -> HashMap<&'static str, ValueRef> {
27592759
[i8p, Type::i8(), Type::i64(), Type::i32(), Type::i1()], Type::void());
27602760

27612761
ifn!(intrinsics, "llvm.trap", [], Type::void());
2762-
ifn!(intrinsics, "llvm.debugtrap", [], Type::void());
27632762
ifn!(intrinsics, "llvm.frameaddress", [Type::i32()], i8p);
27642763

27652764
ifn!(intrinsics, "llvm.powi.f32", [Type::f32(), Type::i32()], Type::f32());

branches/try/src/librustc/middle/trans/intrinsic.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,6 @@ pub fn trans_intrinsic(ccx: @mut CrateContext,
228228
Call(bcx, llfn, [], []);
229229
Unreachable(bcx);
230230
}
231-
"breakpoint" => {
232-
let llfn = bcx.ccx().intrinsics.get_copy(&("llvm.debugtrap"));
233-
Call(bcx, llfn, [], []);
234-
RetVoid(bcx);
235-
}
236231
"size_of" => {
237232
let tp_ty = substs.tys[0];
238233
let lltp_ty = type_of::type_of(ccx, tp_ty);

branches/try/src/librustc/middle/typeck/check/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3968,8 +3968,7 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) {
39683968

39693969
} else {
39703970
match name {
3971-
"abort" => (0, ~[], ty::mk_bot()),
3972-
"breakpoint" => (0, ~[], ty::mk_nil()),
3971+
"abort" => (0, ~[], ty::mk_bot()),
39733972
"size_of" |
39743973
"pref_align_of" | "min_align_of" => (1u, ~[], ty::mk_uint()),
39753974
"init" => (1u, ~[], param(ccx, 0u)),

branches/try/src/libstd/rand/distributions/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -444,17 +444,17 @@ mod tests {
444444
fn test_rand_sample() {
445445
let mut rand_sample = RandSample::<ConstRand>;
446446

447-
assert_eq!(*rand_sample.sample(&mut task_rng()), 0);
448-
assert_eq!(*rand_sample.ind_sample(&mut task_rng()), 0);
447+
assert_eq!(*rand_sample.sample(task_rng()), 0);
448+
assert_eq!(*rand_sample.ind_sample(task_rng()), 0);
449449
}
450450

451451
#[test]
452452
fn test_normal() {
453453
let mut norm = Normal::new(10.0, 10.0);
454-
let mut rng = task_rng();
454+
let rng = task_rng();
455455
for _ in range(0, 1000) {
456-
norm.sample(&mut rng);
457-
norm.ind_sample(&mut rng);
456+
norm.sample(rng);
457+
norm.ind_sample(rng);
458458
}
459459
}
460460
#[test]
@@ -466,10 +466,10 @@ mod tests {
466466
#[test]
467467
fn test_exp() {
468468
let mut exp = Exp::new(10.0);
469-
let mut rng = task_rng();
469+
let rng = task_rng();
470470
for _ in range(0, 1000) {
471-
assert!(exp.sample(&mut rng) >= 0.0);
472-
assert!(exp.ind_sample(&mut rng) >= 0.0);
471+
assert!(exp.sample(rng) >= 0.0);
472+
assert!(exp.ind_sample(rng) >= 0.0);
473473
}
474474
}
475475
#[test]

branches/try/src/libstd/rand/distributions/range.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ mod tests {
183183

184184
#[test]
185185
fn test_integers() {
186-
let mut rng = task_rng();
186+
let rng = task_rng();
187187
macro_rules! t (
188188
($($ty:ty),*) => {{
189189
$(
@@ -193,9 +193,9 @@ mod tests {
193193
for &(low, high) in v.iter() {
194194
let mut sampler: Range<$ty> = Range::new(low, high);
195195
for _ in range(0, 1000) {
196-
let v = sampler.sample(&mut rng);
196+
let v = sampler.sample(rng);
197197
assert!(low <= v && v < high);
198-
let v = sampler.ind_sample(&mut rng);
198+
let v = sampler.ind_sample(rng);
199199
assert!(low <= v && v < high);
200200
}
201201
}
@@ -208,7 +208,7 @@ mod tests {
208208

209209
#[test]
210210
fn test_floats() {
211-
let mut rng = task_rng();
211+
let rng = task_rng();
212212
macro_rules! t (
213213
($($ty:ty),*) => {{
214214
$(
@@ -219,9 +219,9 @@ mod tests {
219219
for &(low, high) in v.iter() {
220220
let mut sampler: Range<$ty> = Range::new(low, high);
221221
for _ in range(0, 1000) {
222-
let v = sampler.sample(&mut rng);
222+
let v = sampler.sample(rng);
223223
assert!(low <= v && v < high);
224-
let v = sampler.ind_sample(&mut rng);
224+
let v = sampler.ind_sample(rng);
225225
assert!(low <= v && v < high);
226226
}
227227
}

branches/try/src/libstd/rand/mod.rs

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -577,24 +577,11 @@ impl reseeding::Reseeder<StdRng> for TaskRngReseeder {
577577
}
578578
}
579579
static TASK_RNG_RESEED_THRESHOLD: uint = 32_768;
580-
type TaskRngInner = reseeding::ReseedingRng<StdRng, TaskRngReseeder>;
581580
/// The task-local RNG.
582-
#[no_send]
583-
pub struct TaskRng {
584-
// This points into TLS (specifically, it points to the endpoint
585-
// of a ~ stored in TLS, to make it robust against TLS moving
586-
// things internally) and so this struct cannot be legally
587-
// transferred between tasks *and* it's unsafe to deallocate the
588-
// RNG other than when a task is finished.
589-
//
590-
// The use of unsafe code here is OK if the invariants above are
591-
// satisfied; and it allows us to avoid (unnecessarily) using a
592-
// GC'd or RC'd pointer.
593-
priv rng: *mut TaskRngInner
594-
}
581+
pub type TaskRng = reseeding::ReseedingRng<StdRng, TaskRngReseeder>;
595582

596583
// used to make space in TLS for a random number generator
597-
local_data_key!(TASK_RNG_KEY: ~TaskRngInner)
584+
local_data_key!(TASK_RNG_KEY: @mut TaskRng)
598585

599586
/// Retrieve the lazily-initialized task-local random number
600587
/// generator, seeded by the system. Intended to be used in method
@@ -607,34 +594,34 @@ local_data_key!(TASK_RNG_KEY: ~TaskRngInner)
607594
/// if the operating system random number generator is rigged to give
608595
/// the same sequence always. If absolute consistency is required,
609596
/// explicitly select an RNG, e.g. `IsaacRng` or `Isaac64Rng`.
610-
pub fn task_rng() -> TaskRng {
611-
local_data::get_mut(TASK_RNG_KEY, |rng| match rng {
597+
pub fn task_rng() -> @mut TaskRng {
598+
let r = local_data::get(TASK_RNG_KEY, |k| k.map(|k| *k));
599+
match r {
612600
None => {
613-
let mut rng = ~reseeding::ReseedingRng::new(StdRng::new(),
601+
let rng = @mut reseeding::ReseedingRng::new(StdRng::new(),
614602
TASK_RNG_RESEED_THRESHOLD,
615603
TaskRngReseeder);
616-
let ptr = &mut *rng as *mut TaskRngInner;
617-
618604
local_data::set(TASK_RNG_KEY, rng);
619-
620-
TaskRng { rng: ptr }
605+
rng
621606
}
622-
Some(rng) => TaskRng { rng: &mut **rng }
623-
})
607+
Some(rng) => rng
608+
}
624609
}
625610

626-
impl Rng for TaskRng {
611+
// Allow direct chaining with `task_rng`
612+
impl<R: Rng> Rng for @mut R {
613+
#[inline]
627614
fn next_u32(&mut self) -> u32 {
628-
unsafe { (*self.rng).next_u32() }
615+
(**self).next_u32()
629616
}
630-
617+
#[inline]
631618
fn next_u64(&mut self) -> u64 {
632-
unsafe { (*self.rng).next_u64() }
619+
(**self).next_u64()
633620
}
634621

635622
#[inline]
636623
fn fill_bytes(&mut self, bytes: &mut [u8]) {
637-
unsafe { (*self.rng).fill_bytes(bytes) }
624+
(**self).fill_bytes(bytes);
638625
}
639626
}
640627

branches/try/src/libstd/rt/global_heap.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ extern {
2020
#[inline]
2121
pub fn get_box_size(body_size: uint, body_align: uint) -> uint {
2222
let header_size = size_of::<raw::Box<()>>();
23+
// FIXME (#2699): This alignment calculation is suspicious. Is it right?
2324
let total_size = align_to(header_size, body_align) + body_size;
2425
total_size
2526
}

branches/try/src/libstd/unstable/intrinsics.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,6 @@ extern "rust-intrinsic" {
176176
/// Abort the execution of the process.
177177
pub fn abort() -> !;
178178

179-
/// Execute a breakpoint trap, for inspection by a debugger.
180-
#[cfg(not(stage0))]
181-
pub fn breakpoint();
182-
183179
/// Atomic compare and exchange, sequentially consistent.
184180
pub fn atomic_cxchg(dst: &mut int, old: int, src: int) -> int;
185181
/// Atomic compare and exchange, acquire ordering.

branches/try/src/libstd/vec.rs

Lines changed: 2 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -3862,10 +3862,10 @@ mod bench {
38623862
}
38633863

38643864
#[bench]
3865-
fn add(bh: &mut BenchHarness) {
3865+
fn add(b: &mut BenchHarness) {
38663866
let xs: &[int] = [5, ..10];
38673867
let ys: &[int] = [5, ..10];
3868-
do bh.iter() {
3868+
do b.iter() {
38693869
xs + ys;
38703870
}
38713871
}
@@ -3885,72 +3885,4 @@ mod bench {
38853885
xss.connect_vec(&0);
38863886
}
38873887
}
3888-
3889-
#[bench]
3890-
fn push(bh: &mut BenchHarness) {
3891-
let mut vec: ~[uint] = ~[0u];
3892-
do bh.iter() {
3893-
vec.push(0);
3894-
}
3895-
}
3896-
3897-
#[bench]
3898-
fn starts_with_same_vector(bh: &mut BenchHarness) {
3899-
let vec: ~[uint] = vec::from_fn(100, |i| i);
3900-
do bh.iter() {
3901-
vec.starts_with(vec);
3902-
}
3903-
}
3904-
3905-
#[bench]
3906-
fn starts_with_single_element(bh: &mut BenchHarness) {
3907-
let vec: ~[uint] = ~[0u];
3908-
do bh.iter() {
3909-
vec.starts_with(vec);
3910-
}
3911-
}
3912-
3913-
#[bench]
3914-
fn starts_with_diff_one_element_at_end(bh: &mut BenchHarness) {
3915-
let vec: ~[uint] = vec::from_fn(100, |i| i);
3916-
let mut match_vec: ~[uint] = vec::from_fn(99, |i| i);
3917-
match_vec.push(0);
3918-
do bh.iter() {
3919-
vec.starts_with(match_vec);
3920-
}
3921-
}
3922-
3923-
#[bench]
3924-
fn ends_with_same_vector(bh: &mut BenchHarness) {
3925-
let vec: ~[uint] = vec::from_fn(100, |i| i);
3926-
do bh.iter() {
3927-
vec.ends_with(vec);
3928-
}
3929-
}
3930-
3931-
#[bench]
3932-
fn ends_with_single_element(bh: &mut BenchHarness) {
3933-
let vec: ~[uint] = ~[0u];
3934-
do bh.iter() {
3935-
vec.ends_with(vec);
3936-
}
3937-
}
3938-
3939-
#[bench]
3940-
fn ends_with_diff_one_element_at_beginning(bh: &mut BenchHarness) {
3941-
let vec: ~[uint] = vec::from_fn(100, |i| i);
3942-
let mut match_vec: ~[uint] = vec::from_fn(100, |i| i);
3943-
match_vec[0] = 200;
3944-
do bh.iter() {
3945-
vec.starts_with(match_vec);
3946-
}
3947-
}
3948-
3949-
#[bench]
3950-
fn contains_last_element(bh: &mut BenchHarness) {
3951-
let vec: ~[uint] = vec::from_fn(100, |i| i);
3952-
do bh.iter() {
3953-
vec.contains(&99u);
3954-
}
3955-
}
39563888
}

0 commit comments

Comments
 (0)