From 94be14516968501306f1ed95774a3f227956e809 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Mon, 3 Dec 2012 17:45:19 -0800 Subject: [PATCH] core: rename box to managed. Close #4079. --- src/libcore/core.rc | 14 +++++++------- src/libcore/dlist.rs | 18 ++++++++++-------- src/libcore/iter-trait/dlist.rs | 4 ++-- src/libcore/{box.rs => managed.rs} | 0 src/libcore/repr.rs | 10 +++++----- src/libcore/vec.rs | 2 +- src/librustc/middle/resolve.rs | 2 +- src/libsyntax/ext/simplext.rs | 2 +- 8 files changed, 27 insertions(+), 25 deletions(-) rename src/libcore/{box.rs => managed.rs} (100%) diff --git a/src/libcore/core.rc b/src/libcore/core.rc index 13735d4fa97..5f313244e27 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -19,12 +19,12 @@ used features. `core` includes modules corresponding to each of the integer types, each of the floating point types, the `bool` type, tuples, characters, strings, -vectors (`vec`), shared boxes (`box`), and unsafe and borrowed pointers -(`ptr`). Additionally, `core` provides task management and creation (`task`), -communication primitives (`comm` and `pipes`), an efficient vector builder -(`dvec`), platform abstractions (`os` and `path`), basic I/O abstractions -(`io`), common traits (`cmp`, `num`, `to_str`), and complete bindings -to the C standard library (`libc`). +vectors (`vec`), managed boxes (`managed`), owned boxes (`owned`), and unsafe +and borrowed pointers (`ptr`). Additionally, `core` provides task management +and creation (`task`), communication primitives (`comm` and `pipes`), an +efficient vector builder (`dvec`), platform abstractions (`os` and `path`), +basic I/O abstractions (`io`), common traits (`cmp`, `num`, `to_str`), and +complete bindings to the C standard library (`libc`). `core` is linked to all crates by default and its contents imported. Implicitly, all crates behave as if they included the following prologue: @@ -92,7 +92,7 @@ pub mod at_vec; pub mod str; pub mod ptr; -pub mod box; // FIXME #4079 Rename to 'managed' to match 'owned' +pub mod managed; pub mod owned; diff --git a/src/libcore/dlist.rs b/src/libcore/dlist.rs index 5f37607b85a..35ff98ac17d 100644 --- a/src/libcore/dlist.rs +++ b/src/libcore/dlist.rs @@ -43,7 +43,7 @@ priv impl DListNode { pure fn assert_links() { match self.next { Some(neighbour) => match neighbour.prev { - Some(me) => if !box::ptr_eq(*self, *me) { + Some(me) => if !managed::ptr_eq(*self, *me) { fail ~"Asymmetric next-link in dlist node." }, None => fail ~"One-way next-link in dlist node." @@ -52,7 +52,7 @@ priv impl DListNode { } match self.prev { Some(neighbour) => match neighbour.next { - Some(me) => if !box::ptr_eq(*me, *self) { + Some(me) => if !managed::ptr_eq(*me, *self) { fail ~"Asymmetric prev-link in dlist node." }, None => fail ~"One-way prev-link in dlist node." @@ -137,9 +137,11 @@ priv impl DList { } if !nobe.linked { fail ~"That node isn't linked to any dlist." } if !((nobe.prev.is_some() - || box::ptr_eq(*self.hd.expect(~"headless dlist?"), *nobe)) && + || managed::ptr_eq(*self.hd.expect(~"headless dlist?"), + *nobe)) && (nobe.next.is_some() - || box::ptr_eq(*self.tl.expect(~"tailless dlist?"), *nobe))) { + || managed::ptr_eq(*self.tl.expect(~"tailless dlist?"), + *nobe))) { fail ~"That node isn't on this dlist." } } @@ -322,7 +324,7 @@ impl DList { * to the other list's head. O(1). */ fn append(them: DList) { - if box::ptr_eq(*self, *them) { + if managed::ptr_eq(*self, *them) { fail ~"Cannot append a dlist to itself!" } if them.len() > 0 { @@ -339,7 +341,7 @@ impl DList { * list's tail to this list's head. O(1). */ fn prepend(them: DList) { - if box::ptr_eq(*self, *them) { + if managed::ptr_eq(*self, *them) { fail ~"Cannot prepend a dlist to itself!" } if them.len() > 0 { @@ -405,7 +407,7 @@ impl DList { rabbit = option::get(rabbit).next; } if option::is_some(&rabbit) { - assert !box::ptr_eq(*option::get(rabbit), *nobe); + assert !managed::ptr_eq(*option::get(rabbit), *nobe); } // advance link = nobe.next_link(); @@ -426,7 +428,7 @@ impl DList { rabbit = option::get(rabbit).prev; } if option::is_some(&rabbit) { - assert !box::ptr_eq(*option::get(rabbit), *nobe); + assert !managed::ptr_eq(*option::get(rabbit), *nobe); } // advance link = nobe.prev_link(); diff --git a/src/libcore/iter-trait/dlist.rs b/src/libcore/iter-trait/dlist.rs index 2b9d3ad7da3..ce5f775878c 100644 --- a/src/libcore/iter-trait/dlist.rs +++ b/src/libcore/iter-trait/dlist.rs @@ -31,10 +31,10 @@ mod inst { } if !nobe.linked || (!((nobe.prev.is_some() - || box::ptr_eq(*self.hd.expect(~"headless dlist?"), + || managed::ptr_eq(*self.hd.expect(~"headless dlist?"), *nobe)) && (nobe.next.is_some() - || box::ptr_eq(*self.tl.expect(~"tailless dlist?"), + || managed::ptr_eq(*self.tl.expect(~"tailless dlist?"), *nobe)))) { fail ~"Removing a dlist node during iteration is forbidden!" } diff --git a/src/libcore/box.rs b/src/libcore/managed.rs similarity index 100% rename from src/libcore/box.rs rename to src/libcore/managed.rs diff --git a/src/libcore/repr.rs b/src/libcore/repr.rs index d8f9c6d243f..9a0cfeefd60 100644 --- a/src/libcore/repr.rs +++ b/src/libcore/repr.rs @@ -27,8 +27,8 @@ use intrinsic::{TyDesc, TyVisitor, visit_tydesc}; use reflect::{MovePtr, MovePtrAdaptor}; use vec::UnboxedVecRepr; use vec::raw::{VecRepr, SliceRepr}; -pub use box::raw::BoxRepr; -use box::raw::BoxHeaderRepr; +pub use managed::raw::BoxRepr; +use managed::raw::BoxHeaderRepr; /// Helpers @@ -279,7 +279,7 @@ impl ReprVisitor : TyVisitor { fn visit_box(mtbl: uint, inner: *TyDesc) -> bool { self.writer.write_char('@'); self.write_mut_qualifier(mtbl); - do self.get::<&box::raw::BoxRepr> |b| { + do self.get::<&managed::raw::BoxRepr> |b| { let p = ptr::to_unsafe_ptr(&b.data) as *c_void; self.visit_ptr_inner(p, inner); } @@ -288,7 +288,7 @@ impl ReprVisitor : TyVisitor { fn visit_uniq(mtbl: uint, inner: *TyDesc) -> bool { self.writer.write_char('~'); self.write_mut_qualifier(mtbl); - do self.get::<&box::raw::BoxRepr> |b| { + do self.get::<&managed::raw::BoxRepr> |b| { let p = ptr::to_unsafe_ptr(&b.data) as *c_void; self.visit_ptr_inner(p, inner); } @@ -446,7 +446,7 @@ impl ReprVisitor : TyVisitor { fn visit_opaque_box() -> bool { self.writer.write_char('@'); - do self.get::<&box::raw::BoxRepr> |b| { + do self.get::<&managed::raw::BoxRepr> |b| { let p = ptr::to_unsafe_ptr(&b.data) as *c_void; self.visit_ptr_inner(p, b.header.type_desc); } diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index fc6bd8f1d91..ceb169c2e6e 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -1763,7 +1763,7 @@ mod raw { /// The internal representation of a (boxed) vector pub struct VecRepr { - box_header: box::raw::BoxHeaderRepr, + box_header: managed::raw::BoxHeaderRepr, unboxed: UnboxedVecRepr } diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 547cad2e05d..21bd01b6f91 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -63,7 +63,7 @@ use syntax::visit::{visit_crate, visit_expr, visit_expr_opt, visit_fn}; use syntax::visit::{visit_foreign_item, visit_item, visit_method_helper}; use syntax::visit::{visit_mod, visit_ty, vt}; -use box::ptr_eq; +use managed::ptr_eq; use dvec::DVec; use option::{Some, get, is_some, is_none}; use str::{connect, split_str}; diff --git a/src/libsyntax/ext/simplext.rs b/src/libsyntax/ext/simplext.rs index d32f982de8a..5e47dee548f 100644 --- a/src/libsyntax/ext/simplext.rs +++ b/src/libsyntax/ext/simplext.rs @@ -476,7 +476,7 @@ fn p_t_s_rec(cx: ext_ctxt, m: matchable, s: selector, b: binders) { match_result { return match m { match_expr(e) => { - if box::ptr_eq(e, pat) { + if managed::ptr_eq(e, pat) { // XXX: Is this right? Some(leaf(match_exact)) } else {