From 107bf96ff0dcc427c1842ffb232d29afaea53ca5 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 26 Feb 2013 17:47:41 -0800 Subject: librustc: Mark all type implementations public. rs=impl-publicity --- src/libstd/arc.rs | 12 ++++++------ src/libstd/arena.rs | 2 +- src/libstd/bitv.rs | 8 ++++---- src/libstd/deque.rs | 2 +- src/libstd/ebml.rs | 6 +++--- src/libstd/future.rs | 4 ++-- src/libstd/net_tcp.rs | 2 +- src/libstd/oldmap.rs | 6 +++--- src/libstd/priority_queue.rs | 2 +- src/libstd/sort.rs | 2 +- src/libstd/sync.rs | 20 ++++++++++---------- src/libstd/time.rs | 4 ++-- src/libstd/treemap.rs | 8 ++++---- src/libstd/workcache.rs | 10 +++++----- 14 files changed, 44 insertions(+), 44 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index f258e649122..1e2abbe0287 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -30,7 +30,7 @@ use core::util; /// As sync::condvar, a mechanism for unlock-and-descheduling and signalling. pub struct Condvar { is_mutex: bool, failed: &mut bool, cond: &sync::Condvar } -impl &Condvar { +pub impl &Condvar { /// Atomically exit the associated ARC and block until a signal is sent. #[inline(always)] fn wait() { self.wait_on(0) } @@ -158,7 +158,7 @@ impl Clone for MutexARC { } } -impl &MutexARC { +pub impl &MutexARC { /** * Access the underlying mutable data with mutual exclusion from other @@ -301,7 +301,7 @@ pub fn rw_arc_with_condvars( RWARC { x: unsafe { shared_mutable_state(data) }, cant_nest: () } } -impl RWARC { +pub impl RWARC { /// Duplicate a rwlock-protected ARC, as arc::clone. fn clone(&self) -> RWARC { RWARC { x: unsafe { clone_shared_mutable_state(&self.x) }, @@ -310,7 +310,7 @@ impl RWARC { } -impl &RWARC { +pub impl &RWARC { /** * Access the underlying data mutably. Locks the rwlock in write mode; * other readers and writers will block. @@ -445,7 +445,7 @@ pub enum RWWriteMode = /// The "read permission" token used for RWARC.write_downgrade(). pub enum RWReadMode = (&T, sync::RWlockReadMode); -impl &RWWriteMode { +pub impl &RWWriteMode { /// Access the pre-downgrade RWARC in write mode. fn write(blk: fn(x: &mut T) -> U) -> U { match *self { @@ -475,7 +475,7 @@ impl &RWWriteMode { } } -impl &RWReadMode { +pub impl &RWReadMode { /// Access the post-downgrade rwlock in read mode. fn read(blk: fn(x: &T) -> U) -> U { match *self { diff --git a/src/libstd/arena.rs b/src/libstd/arena.rs index 177932aa072..a30ee94a42b 100644 --- a/src/libstd/arena.rs +++ b/src/libstd/arena.rs @@ -161,7 +161,7 @@ unsafe fn un_bitpack_tydesc_ptr(p: uint) -> (*TypeDesc, bool) { (reinterpret_cast(&(p & !1)), p & 1 == 1) } -impl &Arena { +pub impl &Arena { // Functions for the POD part of the arena fn alloc_pod_grow(n_bytes: uint, align: uint) -> *u8 { // Allocate a new chunk. diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index 30d7b825add..cf278b07c9d 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -27,7 +27,7 @@ fn small_mask(nbits: uint) -> uint { (1 << nbits) - 1 } -impl SmallBitv { +pub impl SmallBitv { static fn new(bits: uint) -> SmallBitv { SmallBitv {bits: bits} } @@ -124,7 +124,7 @@ fn big_mask(nbits: uint, elem: uint) -> uint { } } -impl BigBitv { +pub impl BigBitv { static fn new(storage: ~[uint]) -> BigBitv { BigBitv {storage: storage} } @@ -256,7 +256,7 @@ priv impl Bitv { } -impl Bitv { +pub impl Bitv { static fn new(nbits: uint, init: bool) -> Bitv { let rep = if nbits <= uint::bits { Small(~SmallBitv::new(if init {!0} else {0})) @@ -591,7 +591,7 @@ pub struct BitvSet { priv bitv: BigBitv } -impl BitvSet { +pub impl BitvSet { /// Creates a new bit vector set with initially no contents static fn new() -> BitvSet { BitvSet{ size: 0, bitv: BigBitv::new(~[0]) } diff --git a/src/libstd/deque.rs b/src/libstd/deque.rs index 0ac76cefd6b..4d8c60a6614 100644 --- a/src/libstd/deque.rs +++ b/src/libstd/deque.rs @@ -37,7 +37,7 @@ impl Mutable for Deque { } } -impl Deque { +pub impl Deque { static pure fn new() -> Deque { Deque{nelts: 0, lo: 0, hi: 0, elts: vec::from_fn(initial_capacity, |_| None)} diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index 84df1785503..7d04f676079 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -279,7 +279,7 @@ pub mod reader { } } - impl Decoder { + pub impl Decoder { fn read_opaque(&self, op: fn(Doc) -> R) -> R { do self.push_doc(self.next_doc(EsOpaque)) { op(copy self.parent) @@ -451,7 +451,7 @@ pub mod writer { } // FIXME (#2741): Provide a function to write the standard ebml header. - impl Encoder { + pub impl Encoder { fn start_tag(tag_id: uint) { debug!("Start tag %u", tag_id); @@ -571,7 +571,7 @@ pub mod writer { } } - impl Encoder { + pub impl Encoder { fn emit_opaque(&self, f: fn()) { do self.wr_tag(EsOpaque as uint) { f() diff --git a/src/libstd/future.rs b/src/libstd/future.rs index 7f48466ed0a..b9c7c9f3a13 100644 --- a/src/libstd/future.rs +++ b/src/libstd/future.rs @@ -49,14 +49,14 @@ priv enum FutureState { } /// Methods on the `future` type -impl Future { +pub impl Future { fn get() -> A { //! Get the value of the future *(self.get_ref()) } } -impl Future { +pub impl Future { pure fn get_ref(&self) -> &self/A { /*! diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index 8835cdfb105..dcbf7e60d89 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -820,7 +820,7 @@ pub fn socket_buf(sock: TcpSocket) -> TcpSocketBuf { } /// Convenience methods extending `net::tcp::tcp_socket` -impl TcpSocket { +pub impl TcpSocket { pub fn read_start() -> result::Result<@Port< result::Result<~[u8], TcpErrData>>, TcpErrData> { read_start(&self) diff --git a/src/libstd/oldmap.rs b/src/libstd/oldmap.rs index 53692cd3be5..c1227f6b077 100644 --- a/src/libstd/oldmap.rs +++ b/src/libstd/oldmap.rs @@ -168,7 +168,7 @@ pub mod chained { } } - impl T { + pub impl T { pure fn contains_key(&self, k: &K) -> bool { let hash = k.hash_keyed(0,0) as uint; match self.search_tbl(k, hash) { @@ -252,7 +252,7 @@ pub mod chained { } } - impl T { + pub impl T { pure fn find(&self, k: &K) -> Option { match self.search_tbl(k, k.hash_keyed(0,0) as uint) { NotFound => None, @@ -325,7 +325,7 @@ pub mod chained { } } - impl T { + pub impl T { fn to_writer(wr: io::Writer) { if self.count == 0u { wr.write_str(~"{}"); diff --git a/src/libstd/priority_queue.rs b/src/libstd/priority_queue.rs index f642bf52f65..4b92bd7543a 100644 --- a/src/libstd/priority_queue.rs +++ b/src/libstd/priority_queue.rs @@ -48,7 +48,7 @@ impl Mutable for PriorityQueue { fn clear(&mut self) { self.data.truncate(0) } } -impl PriorityQueue { +pub impl PriorityQueue { /// Returns the greatest item in the queue - fails if empty pure fn top(&self) -> &self/T { &self.data[0] } diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 75f38da5a19..43fab9df163 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -404,7 +404,7 @@ fn MergeState() -> MergeState { } } -impl MergeState { +pub impl MergeState { fn push_run(&self, run_base: uint, run_len: uint) { let tmp = RunState{base: run_base, len: run_len}; self.runs.push(tmp); diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index 1ff51e8bff0..22325e6a83c 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -100,7 +100,7 @@ fn new_sem_and_signal(count: int, num_condvars: uint) } #[doc(hidden)] -impl &Sem { +pub impl &Sem { fn acquire() { let mut waiter_nobe = None; unsafe { @@ -136,7 +136,7 @@ impl &Sem { } // FIXME(#3154) move both copies of this into Sem, and unify the 2 structs #[doc(hidden)] -impl &Sem<()> { +pub impl &Sem<()> { fn access(blk: fn() -> U) -> U { let mut release = None; unsafe { @@ -149,7 +149,7 @@ impl &Sem<()> { } } #[doc(hidden)] -impl &Sem<~[Waitqueue]> { +pub impl &Sem<~[Waitqueue]> { fn access(blk: fn() -> U) -> U { let mut release = None; unsafe { @@ -192,7 +192,7 @@ pub struct Condvar { priv sem: &Sem<~[Waitqueue]> } impl Drop for Condvar { fn finalize(&self) {} } -impl &Condvar { +pub impl &Condvar { /** * Atomically drop the associated lock, and block until a signal is sent. * @@ -344,7 +344,7 @@ fn check_cvar_bounds(out_of_bounds: Option, id: uint, act: &str, } #[doc(hidden)] -impl &Sem<~[Waitqueue]> { +pub impl &Sem<~[Waitqueue]> { // The only other place that condvars get built is rwlock_write_mode. fn access_cond(blk: fn(c: &Condvar) -> U) -> U { do self.access { blk(&Condvar { sem: self }) } @@ -370,7 +370,7 @@ impl Clone for Semaphore { } } -impl &Semaphore { +pub impl &Semaphore { /** * Acquire a resource represented by the semaphore. Blocks if necessary * until resource(s) become available. @@ -418,7 +418,7 @@ impl Clone for Mutex { fn clone(&self) -> Mutex { Mutex { sem: Sem((*self.sem).clone()) } } } -impl &Mutex { +pub impl &Mutex { /// Run a function with ownership of the mutex. fn lock(blk: fn() -> U) -> U { (&self.sem).access(blk) } @@ -467,7 +467,7 @@ pub fn rwlock_with_condvars(num_condvars: uint) -> RWlock { read_count: 0 }) } } -impl &RWlock { +pub impl &RWlock { /// Create a new handle to the rwlock. fn clone() -> RWlock { RWlock { order_lock: (&(self.order_lock)).clone(), @@ -688,7 +688,7 @@ impl Drop for RWlockWriteMode { fn finalize(&self) {} } pub struct RWlockReadMode { priv lock: &RWlock } impl Drop for RWlockReadMode { fn finalize(&self) {} } -impl &RWlockWriteMode { +pub impl &RWlockWriteMode { /// Access the pre-downgrade rwlock in write mode. fn write(blk: fn() -> U) -> U { blk() } /// Access the pre-downgrade rwlock in write mode with a condvar. @@ -696,7 +696,7 @@ impl &RWlockWriteMode { blk(&Condvar { sem: &self.lock.access_lock }) } } -impl &RWlockReadMode { +pub impl &RWlockReadMode { /// Access the post-downgrade rwlock in read mode. fn read(blk: fn() -> U) -> U { blk() } } diff --git a/src/libstd/time.rs b/src/libstd/time.rs index c8379d3ef44..15dea83815b 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -47,7 +47,7 @@ pub struct Timespec { sec: i64, nsec: i32 } * -1.2 seconds before the epoch is represented by `Timespec { sec: -2_i64, * nsec: 800_000_000_i32 }`. */ -impl Timespec { +pub impl Timespec { static pure fn new(sec: i64, nsec: i32) -> Timespec { assert nsec >= 0 && nsec < NSEC_PER_SEC; Timespec { sec: sec, nsec: nsec } @@ -208,7 +208,7 @@ pub pure fn strftime(format: &str, tm: &Tm) -> ~str { unsafe { do_strftime(format, tm) } } -impl Tm { +pub impl Tm { /// Convert time to the seconds from January 1, 1970 fn to_timespec() -> Timespec { unsafe { diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index 0e593ba42d1..cf863217deb 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -177,7 +177,7 @@ impl Map for TreeMap { } } -impl TreeMap { +pub impl TreeMap { /// Create an empty TreeMap static pure fn new() -> TreeMap { TreeMap{root: None, length: 0} } @@ -208,7 +208,7 @@ pub struct TreeMapIterator { /// tuple with a reference to the key and value. If there are no /// more nodes, return `None`. fn map_next(iter: &mut TreeMapIterator/&r) - -> Option<(&r/K, &r/V)> { + -> Option<(&r/K, &r/V)> { while !iter.stack.is_empty() || iter.node.is_some() { match *iter.node { Some(ref x) => { @@ -480,7 +480,7 @@ impl Set for TreeSet { } } -impl TreeSet { +pub impl TreeSet { /// Create an empty TreeSet static pure fn new() -> TreeSet { TreeSet{map: TreeMap::new()} } @@ -518,7 +518,7 @@ struct TreeNode { level: uint } -impl TreeNode { +pub impl TreeNode { #[inline(always)] static pure fn new(key: K, value: V) -> TreeNode { TreeNode{key: key, value: value, left: None, right: None, level: 1} diff --git a/src/libstd/workcache.rs b/src/libstd/workcache.rs index c85aa78d983..592ac40e082 100644 --- a/src/libstd/workcache.rs +++ b/src/libstd/workcache.rs @@ -132,7 +132,7 @@ impl cmp::Ord for WorkKey { } } -impl WorkKey { +pub impl WorkKey { static fn new(kind: &str, name: &str) -> WorkKey { WorkKey { kind: kind.to_owned(), name: name.to_owned() } } @@ -168,7 +168,7 @@ struct Database { mut db_dirty: bool } -impl Database { +pub impl Database { fn prepare(&mut self, fn_name: &str, declared_inputs: &WorkMap) -> Option<(WorkMap, WorkMap, ~str)> { @@ -199,7 +199,7 @@ struct Logger { a: () } -impl Logger { +pub impl Logger { fn info(i: &str) { io::println(~"workcache: " + i.to_owned()); } @@ -254,7 +254,7 @@ fn digest_file(path: &Path) -> ~str { sha.result_str() } -impl Context { +pub impl Context { static fn new(db: @Mut, lg: @Mut, @@ -356,7 +356,7 @@ impl TPrep for @Mut { } } -impl + Decodable> Work { +pub impl+Decodable> Work { static fn new(p: @Mut, e: Either>) -> Work { Work { prep: p, res: Some(e) } } -- cgit 1.4.1-3-g733a5 From 2859c1ac6d760876282471ae57fee2e5731f85d5 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Wed, 27 Feb 2013 13:45:37 -0800 Subject: librustc: Enforce cross-crate method privacy --- doc/tutorial.md | 3 +- src/librustc/metadata/common.rs | 1 + src/librustc/metadata/csearch.rs | 8 +++ src/librustc/metadata/decoder.rs | 19 ++++++- src/librustc/metadata/encoder.rs | 63 ++++++++++++++++++---- src/librustc/middle/privacy.rs | 35 ++++++++---- src/libstd/oldmap.rs | 2 + src/test/auxiliary/cci_class_5.rs | 4 +- .../compile-fail/private-method-cross-crate.rs | 4 +- 9 files changed, 112 insertions(+), 27 deletions(-) (limited to 'src/libstd') diff --git a/doc/tutorial.md b/doc/tutorial.md index f9408761877..d31fbbb0c07 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -2304,11 +2304,10 @@ mod farm { farmer: Human } - // Note - visibility modifiers on impls currently have no effect impl Farm { priv fn feed_chickens(&self) { ... } priv fn feed_cows(&self) { ... } - fn add_chicken(&self, c: Chicken) { ... } + pub fn add_chicken(&self, c: Chicken) { ... } } pub fn feed_animals(farm: &Farm) { diff --git a/src/librustc/metadata/common.rs b/src/librustc/metadata/common.rs index 877098ed49f..90d8dcdc235 100644 --- a/src/librustc/metadata/common.rs +++ b/src/librustc/metadata/common.rs @@ -155,6 +155,7 @@ pub const tag_lang_items_item_node_id: uint = 0x75; pub const tag_item_unnamed_field: uint = 0x76; pub const tag_items_data_item_struct_ctor: uint = 0x77; +pub const tag_items_data_item_visibility: uint = 0x78; pub struct LinkMeta { name: @str, diff --git a/src/librustc/metadata/csearch.rs b/src/librustc/metadata/csearch.rs index eda7362b9c1..ae4a223c1ae 100644 --- a/src/librustc/metadata/csearch.rs +++ b/src/librustc/metadata/csearch.rs @@ -234,6 +234,14 @@ pub fn struct_dtor(cstore: @mut cstore::CStore, def: ast::def_id) let cdata = cstore::get_crate_data(cstore, def.crate); decoder::struct_dtor(cdata, def.node) } + +pub fn get_method_visibility(cstore: @mut cstore::CStore, + def_id: ast::def_id) + -> ast::visibility { + let cdata = cstore::get_crate_data(cstore, def_id.crate); + decoder::get_method_visibility(cdata, def_id.node) +} + // Local Variables: // mode: rust // fill-column: 78; diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index ca55c8a4072..5963d878060 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -151,6 +151,16 @@ fn item_family(item: ebml::Doc) -> Family { } } +fn item_visibility(item: ebml::Doc) -> ast::visibility { + let visibility = reader::get_doc(item, tag_items_data_item_visibility); + match reader::doc_as_u8(visibility) as char { + 'y' => ast::public, + 'n' => ast::private, + 'i' => ast::inherited, + _ => fail!(~"unknown visibility character"), + } +} + fn item_method_sort(item: ebml::Doc) -> char { for reader::tagged_docs(item, tag_item_trait_method_sort) |doc| { return str::from_bytes(reader::doc_data(doc))[0] as char; @@ -860,7 +870,7 @@ pub fn get_item_attrs(cdata: cmd, } } -pure fn family_to_visibility(family: Family) -> ast::visibility { +pure fn struct_field_family_to_visibility(family: Family) -> ast::visibility { match family { PublicField => ast::public, PrivateField => ast::private, @@ -883,7 +893,7 @@ pub fn get_struct_fields(intr: @ident_interner, cdata: cmd, id: ast::node_id) result.push(ty::field_ty { ident: name, id: did, vis: - family_to_visibility(f), + struct_field_family_to_visibility(f), mutability: mt, }); } @@ -900,6 +910,11 @@ pub fn get_struct_fields(intr: @ident_interner, cdata: cmd, id: ast::node_id) result } +pub fn get_method_visibility(cdata: cmd, id: ast::node_id) + -> ast::visibility { + item_visibility(lookup_item(id, cdata.data)) +} + fn family_has_type_params(fam: Family) -> bool { match fam { Const | ForeignType | Mod | ForeignMod | PublicField | PrivateField diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 95973aaaf90..a950cd04d67 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -383,7 +383,8 @@ fn encode_info_for_mod(ecx: @EncodeContext, ebml_w: writer::Encoder, ebml_w.end_tag(); } -fn encode_visibility(ebml_w: writer::Encoder, visibility: visibility) { +fn encode_struct_field_family(ebml_w: writer::Encoder, + visibility: visibility) { encode_family(ebml_w, match visibility { public => 'g', private => 'j', @@ -391,6 +392,17 @@ fn encode_visibility(ebml_w: writer::Encoder, visibility: visibility) { }); } +fn encode_visibility(ebml_w: writer::Encoder, visibility: visibility) { + ebml_w.start_tag(tag_items_data_item_visibility); + let ch = match visibility { + public => 'y', + private => 'n', + inherited => 'i', + }; + ebml_w.wr_str(str::from_char(ch)); + ebml_w.end_tag(); +} + fn encode_self_type(ebml_w: writer::Encoder, self_type: ast::self_ty_) { ebml_w.start_tag(tag_item_trait_method_self_ty); @@ -456,7 +468,7 @@ fn encode_info_for_struct(ecx: @EncodeContext, ebml_w: writer::Encoder, ebml_w.start_tag(tag_items_data_item); debug!("encode_info_for_struct: doing %s %d", *tcx.sess.str_of(nm), id); - encode_visibility(ebml_w, vis); + encode_struct_field_family(ebml_w, vis); encode_name(ecx, ebml_w, nm); encode_path(ecx, ebml_w, path, ast_map::path_name(nm)); encode_type(ecx, ebml_w, node_id_to_type(tcx, id)); @@ -525,6 +537,7 @@ fn encode_info_for_method(ecx: @EncodeContext, should_inline: bool, parent_id: node_id, m: @method, + parent_visibility: ast::visibility, owner_generics: &ast::Generics, method_generics: &ast::Generics) { debug!("encode_info_for_method: %d %s %u %u", m.id, @@ -533,6 +546,7 @@ fn encode_info_for_method(ecx: @EncodeContext, method_generics.ty_params.len()); ebml_w.start_tag(tag_items_data_item); encode_def_id(ebml_w, local_def(m.id)); + match m.self_ty.node { ast::sty_static => { encode_family(ebml_w, purity_static_method_family(m.purity)); @@ -550,6 +564,14 @@ fn encode_info_for_method(ecx: @EncodeContext, encode_name(ecx, ebml_w, m.ident); encode_path(ecx, ebml_w, impl_path, ast_map::path_name(m.ident)); encode_self_type(ebml_w, m.self_ty.node); + + // Combine parent visibility and this visibility. + let visibility = match m.vis { + ast::inherited => parent_visibility, + vis => vis, + }; + encode_visibility(ebml_w, visibility); + if len > 0u || should_inline { (ecx.encode_inlined_item)( ecx, ebml_w, impl_path, @@ -568,6 +590,7 @@ fn purity_fn_family(p: purity) -> char { extern_fn => 'e' } } + fn purity_static_method_family(p: purity) -> char { match p { unsafe_fn => 'U', @@ -757,7 +780,7 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder, match f.node.kind { named_field(ident, _, vis) => { ebml_w.start_tag(tag_item_field); - encode_visibility(ebml_w, vis); + encode_struct_field_family(ebml_w, vis); encode_name(ecx, ebml_w, ident); encode_def_id(ebml_w, local_def(f.node.id)); ebml_w.end_tag(); @@ -808,12 +831,28 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder, let mut impl_path = vec::append(~[], path); impl_path += ~[ast_map::path_name(item.ident)]; + // If there is a trait reference, treat the methods as always public. + // This is to work around some incorrect behavior in privacy checking: + // when the method belongs to a trait, it should acquire the privacy + // from the trait, not the impl. Forcing the visibility to be public + // makes things sorta work. + let parent_visibility = if opt_trait.is_some() { + ast::public + } else { + item.vis + }; + for methods.each |m| { index.push(entry {val: m.id, pos: ebml_w.writer.tell()}); - encode_info_for_method(ecx, ebml_w, impl_path, + encode_info_for_method(ecx, + ebml_w, + impl_path, should_inline(m.attrs), - item.id, *m, - generics, &m.generics); + item.id, + *m, + parent_visibility, + generics, + &m.generics); } } item_trait(ref generics, ref traits, ref ms) => { @@ -902,9 +941,15 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder, // of provided methods. I am not sure why this is. -ndm let owner_generics = ast_util::empty_generics(); - encode_info_for_method(ecx, ebml_w, /*bad*/copy path, - true, item.id, *m, - &owner_generics, &m.generics); + encode_info_for_method(ecx, + ebml_w, + /*bad*/copy path, + true, + item.id, + *m, + item.vis, + &owner_generics, + &m.generics); } } item_mac(*) => fail!(~"item macros unimplemented") diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs index 712037720d5..e60069e05da 100644 --- a/src/librustc/middle/privacy.rs +++ b/src/librustc/middle/privacy.rs @@ -14,10 +14,11 @@ use core::prelude::*; +use metadata::csearch; use middle::ty::{ty_struct, ty_enum}; use middle::ty; -use middle::typeck::{method_map, method_origin, method_param, method_self, - method_super}; +use middle::typeck::{method_map, method_origin, method_param, method_self}; +use middle::typeck::{method_super}; use middle::typeck::{method_static, method_trait}; use core::dvec::DVec; @@ -100,8 +101,10 @@ pub fn check_crate(tcx: ty::ctxt, }; // Checks that a private method is in scope. - let check_method: @fn(span: span, origin: &method_origin) = - |span, origin| { + let check_method: @fn(span: span, + origin: &method_origin, + ident: ast::ident) = + |span, origin, ident| { match *origin { method_static(method_id) => { if method_id.crate == local_crate { @@ -110,6 +113,8 @@ pub fn check_crate(tcx: ty::ctxt, let mut is_private = false; if method.vis == private { is_private = true; + } else if method.vis == public { + is_private = false; } else { // Look up the enclosing impl. if impl_id.crate != local_crate { @@ -121,7 +126,7 @@ pub fn check_crate(tcx: ty::ctxt, match tcx.items.find(&impl_id.node) { Some(node_item(item, _)) => { match item.node { - item_impl(_, None, _, _) + item_impl(_, None, _, _) if item.vis != public => { is_private = true; } @@ -165,7 +170,15 @@ pub fn check_crate(tcx: ty::ctxt, } } } else { - // FIXME #4732: External crates. + let visibility = + csearch::get_method_visibility(tcx.sess.cstore, + method_id); + if visibility != public { + tcx.sess.span_err(span, + fmt!("method `%s` is private", + *tcx.sess.parse_sess.interner + .get(ident))); + } } } method_param(method_param { @@ -264,14 +277,16 @@ pub fn check_crate(tcx: ty::ctxt, Some(ref entry) => { debug!("(privacy checking) checking \ impl method"); - check_method(expr.span, &(*entry).origin); + check_method(expr.span, + &entry.origin, + ident); } } } _ => {} } } - expr_method_call(base, _, _, _, _) => { + expr_method_call(base, ident, _, _, _) => { // Ditto match ty::get(ty::type_autoderef(tcx, ty::expr_ty(tcx, base))).sty { @@ -287,7 +302,9 @@ pub fn check_crate(tcx: ty::ctxt, Some(ref entry) => { debug!("(privacy checking) checking \ impl method"); - check_method(expr.span, &(*entry).origin); + check_method(expr.span, + &entry.origin, + ident); } } } diff --git a/src/libstd/oldmap.rs b/src/libstd/oldmap.rs index c1227f6b077..1d21f749b32 100644 --- a/src/libstd/oldmap.rs +++ b/src/libstd/oldmap.rs @@ -134,7 +134,9 @@ pub mod chained { } self.chains = new_chains; } + } + pub impl T { pure fn each_entry(blk: fn(@Entry) -> bool) { // n.b. we can't use vec::iter() here because self.chains // is stored in a mutable location. diff --git a/src/test/auxiliary/cci_class_5.rs b/src/test/auxiliary/cci_class_5.rs index e2564a55279..c04cdbcab1a 100644 --- a/src/test/auxiliary/cci_class_5.rs +++ b/src/test/auxiliary/cci_class_5.rs @@ -10,12 +10,12 @@ pub mod kitties { pub struct cat { - priv mut meows : uint, + priv meows : uint, how_hungry : int, } pub impl cat { - priv fn nap() { for uint::range(1, 10000u) |_i|{}} + priv fn nap(&self) { for uint::range(1, 10000u) |_i|{}} } pub fn cat(in_x : uint, in_y : int) -> cat { diff --git a/src/test/compile-fail/private-method-cross-crate.rs b/src/test/compile-fail/private-method-cross-crate.rs index 7897ccb23e6..7414dc57216 100644 --- a/src/test/compile-fail/private-method-cross-crate.rs +++ b/src/test/compile-fail/private-method-cross-crate.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:attempted access of field `nap` on type -// xfail-test Cross-crate impl method privacy doesn't work // xfail-fast // aux-build:cci_class_5.rs extern mod cci_class_5; @@ -17,5 +15,5 @@ use cci_class_5::kitties::*; fn main() { let nyan : cat = cat(52, 99); - nyan.nap(); + nyan.nap(); //~ ERROR method `nap` is private } -- cgit 1.4.1-3-g733a5 From 2df07ddc250b64151401e9b8569a6c7ad5c9b34f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 25 Feb 2013 14:11:21 -0500 Subject: Fix implicit leaks of imports throughout libraries Also touch up use of 'pub' and move some tests around so the tested functions don't have to be 'pub' --- src/libcore/hashmap.rs | 13 +- src/libcore/os.rs | 20 +-- src/libcore/str.rs | 1 + src/libcore/vec.rs | 3 +- src/librustc/middle/borrowck/mod.rs | 2 + src/librustc/middle/trans/_match.rs | 15 +- src/librustc/middle/trans/base.rs | 5 + src/librustc/middle/trans/build.rs | 4 + src/librustc/middle/trans/cabi.rs | 8 +- src/librustc/middle/trans/cabi_x86_64.rs | 8 ++ src/librustc/middle/trans/callee.rs | 18 ++- src/librustc/middle/trans/closure.rs | 9 +- src/librustc/middle/trans/common.rs | 2 +- src/librustc/middle/trans/consts.rs | 4 + src/librustc/middle/trans/controlflow.rs | 17 ++- src/librustc/middle/trans/datum.rs | 14 +- src/librustc/middle/trans/expr.rs | 14 +- src/librustc/middle/trans/foreign.rs | 3 + src/librustc/middle/trans/glue.rs | 25 +++- src/librustc/middle/trans/inline.rs | 3 + src/librustc/middle/trans/machine.rs | 5 +- src/librustc/middle/trans/meth.rs | 13 +- src/librustc/middle/trans/monomorphize.rs | 5 + src/librustc/middle/trans/reachable.rs | 4 +- src/librustc/middle/trans/reflect.rs | 7 +- src/librustc/middle/trans/shape.rs | 1 + src/librustc/middle/trans/tvec.rs | 23 +-- src/librustc/middle/trans/type_of.rs | 6 +- src/librustc/middle/trans/type_use.rs | 4 + src/librustc/middle/trans/uniq.rs | 1 + src/librustc/middle/typeck/infer/combine.rs | 2 +- src/librustc/middle/typeck/infer/glb.rs | 5 + src/librustc/middle/typeck/infer/lattice.rs | 3 +- src/librustc/middle/typeck/infer/lub.rs | 5 + src/librustc/middle/typeck/infer/sub.rs | 6 +- src/libstd/arc.rs | 1 + src/libstd/deque.rs | 3 + src/libstd/flatpipes.rs | 3 +- src/libstd/future.rs | 2 +- src/libstd/getopts.rs | 2 +- src/libstd/json.rs | 1 + src/libstd/net_url.rs | 168 +++++++++++----------- src/libstd/sync.rs | 5 +- src/libstd/time.rs | 15 +- src/libstd/treemap.rs | 10 +- src/libstd/uv_global_loop.rs | 2 + src/libstd/uv_iotask.rs | 214 ++++++++++++++-------------- src/libstd/uv_ll.rs | 3 +- src/libsyntax/ast_map.rs | 1 + src/libsyntax/ast_util.rs | 2 +- src/libsyntax/ext/auto_encode.rs | 1 + src/libsyntax/ext/base.rs | 5 +- src/libsyntax/ext/concat_idents.rs | 3 + src/libsyntax/ext/env.rs | 2 + src/libsyntax/ext/expand.rs | 13 +- src/libsyntax/ext/fmt.rs | 1 + src/libsyntax/ext/log_syntax.rs | 1 + src/libsyntax/ext/pipes/ast_builder.rs | 2 +- src/libsyntax/ext/pipes/parse_proto.rs | 2 + src/libsyntax/ext/pipes/pipec.rs | 3 +- src/libsyntax/ext/quote.rs | 8 +- src/libsyntax/ext/source_util.rs | 2 + src/libsyntax/ext/tt/macro_parser.rs | 2 + src/libsyntax/fold.rs | 3 +- src/libsyntax/parse/attr.rs | 1 + src/libsyntax/parse/lexer.rs | 8 +- src/libsyntax/parse/mod.rs | 2 + src/libsyntax/parse/prec.rs | 1 + src/libsyntax/print/pprust.rs | 7 +- src/libsyntax/visit.rs | 1 + 70 files changed, 489 insertions(+), 289 deletions(-) (limited to 'src/libstd') diff --git a/src/libcore/hashmap.rs b/src/libcore/hashmap.rs index 07c7780898f..c2a39cfdcc3 100644 --- a/src/libcore/hashmap.rs +++ b/src/libcore/hashmap.rs @@ -10,14 +10,12 @@ //! Sendable hash maps. -use container::{Container, Mutable, Map, Set}; -use cmp::Eq; -use hash::Hash; -use to_bytes::IterBytes; - /// Open addressing with linear probing. pub mod linear { - use super::*; + use container::{Container, Mutable, Map, Set}; + use cmp::Eq; + use hash::Hash; + use to_bytes::IterBytes; use iter::BaseIter; use hash::Hash; use iter; @@ -752,7 +750,8 @@ mod test_map { #[test] mod test_set { - use super::*; + use hashmap::linear; + use container::{Container, Mutable, Map, Set}; use vec; #[test] diff --git a/src/libcore/os.rs b/src/libcore/os.rs index 2522e9c2cda..8b6d27496d9 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -1021,10 +1021,10 @@ extern { pub mod consts { #[cfg(unix)] - use os::consts::unix::*; + pub use os::consts::unix::*; #[cfg(windows)] - use os::consts::windows::*; + pub use os::consts::windows::*; pub mod unix { pub const FAMILY: &str = "unix"; @@ -1035,19 +1035,19 @@ pub mod consts { } #[cfg(target_os = "macos")] - use os::consts::macos::*; + pub use os::consts::macos::*; #[cfg(target_os = "freebsd")] - use os::consts::freebsd::*; + pub use os::consts::freebsd::*; #[cfg(target_os = "linux")] - use os::consts::linux::*; + pub use os::consts::linux::*; #[cfg(target_os = "android")] - use os::consts::android::*; + pub use os::consts::android::*; #[cfg(target_os = "win32")] - use os::consts::win32::*; + pub use os::consts::win32::*; pub mod macos { pub const SYSNAME: &str = "macos"; @@ -1086,13 +1086,13 @@ pub mod consts { #[cfg(target_arch = "x86")] - use os::consts::x86::*; + pub use os::consts::x86::*; #[cfg(target_arch = "x86_64")] - use os::consts::x86_64::*; + pub use os::consts::x86_64::*; #[cfg(target_arch = "arm")] - use os::consts::arm::*; + pub use os::consts::arm::*; pub mod x86 { pub const ARCH: &str = "x86"; diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 66be5481819..6ee6d282841 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -2375,6 +2375,7 @@ impl OwnedStr for ~str { #[cfg(test)] mod tests { use char; + use option::Some; use debug; use libc::c_char; use libc; diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 687ad2f7938..4d28c769b18 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -1444,7 +1444,7 @@ pub fn each2(v1: &[U], v2: &[T], f: fn(u: &U, t: &T) -> bool) { * The total number of permutations produced is `len(v)!`. If `v` contains * repeated elements, then some permutations are repeated. */ -pure fn each_permutation(v: &[T], put: fn(ts: &[T]) -> bool) { +pub pure fn each_permutation(v: &[T], put: fn(ts: &[T]) -> bool) { let ln = len(v); if ln <= 1 { put(v); @@ -2427,6 +2427,7 @@ impl iter::CopyableNonstrictIter for @[A] { mod tests { use option::{None, Option, Some}; use option; + use sys; use vec::*; fn square(n: uint) -> uint { return n * n; } diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index b432d5a399a..9bdf69f4c88 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -230,6 +230,7 @@ use middle::liveness; use middle::mem_categorization::*; use middle::region; use middle::ty; +use middle::typeck; use middle::moves; use util::common::{indenter, stmt_set}; use util::ppaux::{expr_repr, note_and_explain_region}; @@ -239,6 +240,7 @@ use core::cmp; use core::dvec::DVec; use core::io; use core::result::{Result, Ok, Err}; +use core::to_bytes; use std::list::{List, Cons, Nil}; use std::list; use std::oldmap::{HashMap, Set}; diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 8ed85b8f421..2f920378087 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -145,9 +145,10 @@ use core::prelude::*; use back::abi; -use lib::llvm::llvm; -use lib::llvm::{ValueRef, BasicBlockRef}; +use lib; +use lib::llvm::{llvm, ValueRef, BasicBlockRef}; use middle::const_eval; +use middle::borrowck::root_map_key; use middle::pat_util::*; use middle::resolve::DefMap; use middle::trans::base::*; @@ -156,20 +157,26 @@ use middle::trans::callee; use middle::trans::common::*; use middle::trans::consts; use middle::trans::controlflow; +use middle::trans::datum; use middle::trans::datum::*; use middle::trans::expr::Dest; use middle::trans::expr; use middle::trans::glue; +use middle::trans::tvec; +use middle::trans::type_of; +use middle::ty; use util::common::indenter; use core::dvec::DVec; use core::dvec; +use core::libc::c_ulonglong; use std::oldmap::HashMap; use syntax::ast::def_id; use syntax::ast; -use syntax::ast_util::{dummy_sp, path_to_ident}; +use syntax::ast::ident; +use syntax::ast_util::path_to_ident; use syntax::ast_util; -use syntax::codemap::span; +use syntax::codemap::{span, dummy_sp}; use syntax::print::pprust::pat_to_str; // An option identifying a literal: either a unit-like struct or an diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 0e0b382869d..47c0021fd79 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -44,6 +44,7 @@ use middle::borrowck::RootInfo; use middle::pat_util::*; use middle::resolve; use middle::trans::_match; +use middle::trans::base; use middle::trans::build::*; use middle::trans::callee; use middle::trans::common::*; @@ -56,12 +57,15 @@ use middle::trans::foreign; use middle::trans::glue; use middle::trans::inline; use middle::trans::machine; +use middle::trans::machine::llsize_of; use middle::trans::meth; use middle::trans::monomorphize; use middle::trans::reachable; use middle::trans::shape::*; use middle::trans::tvec; +use middle::trans::type_of; use middle::trans::type_of::*; +use middle::ty; use middle::ty::arg; use util::common::indenter; use util::ppaux::{ty_to_str, ty_to_short_str}; @@ -77,6 +81,7 @@ use core::option; use core::uint; use std::oldmap::HashMap; use std::{oldmap, time, list}; +use syntax::ast::ident; use syntax::ast_map::{path, path_elt_to_str, path_mod, path_name}; use syntax::ast_util::{def_id_of_def, local_def, path_to_ident}; use syntax::attr; diff --git a/src/librustc/middle/trans/build.rs b/src/librustc/middle/trans/build.rs index 85e8be09878..7ac54518d37 100644 --- a/src/librustc/middle/trans/build.rs +++ b/src/librustc/middle/trans/build.rs @@ -10,6 +10,7 @@ use codemap::span; +use lib; use lib::llvm::llvm; use lib::llvm::{CallConv, TypeKind, AtomicBinOp, AtomicOrdering}; use lib::llvm::{Opcode, IntPredicate, RealPredicate, True, False}; @@ -18,9 +19,12 @@ use libc::{c_uint, c_int, c_ulonglong}; use middle::trans::common::*; use middle::trans::machine::llsize_of_real; +use core::prelude::*; use core::cast::transmute; use core::cast; use core::libc; +use core::option::Some; +use core::ptr; use core::str; use core::vec; use std::oldmap::HashMap; diff --git a/src/librustc/middle/trans/cabi.rs b/src/librustc/middle/trans/cabi.rs index bc48519ffda..269fe344fea 100644 --- a/src/librustc/middle/trans/cabi.rs +++ b/src/librustc/middle/trans/cabi.rs @@ -13,6 +13,10 @@ use middle::trans::base::*; use middle::trans::build::*; use middle::trans::common::*; +use core::libc::c_uint; +use core::option; +use core::vec; + pub trait ABIInfo { fn compute_info(&self, atys: &[TypeRef], @@ -28,7 +32,7 @@ pub struct LLVMType { pub struct FnType { arg_tys: ~[LLVMType], ret_ty: LLVMType, - attrs: ~[Option], + attrs: ~[option::Option], sret: bool } @@ -93,7 +97,7 @@ pub impl FnType { llargbundle: ValueRef, llretval: ValueRef) { for vec::eachi(self.attrs) |i, a| { match *a { - Some(attr) => { + option::Some(attr) => { unsafe { llvm::LLVMAddInstrAttribute( llretval, (i + 1u) as c_uint, diff --git a/src/librustc/middle/trans/cabi_x86_64.rs b/src/librustc/middle/trans/cabi_x86_64.rs index df0f11eedae..1dc70596994 100644 --- a/src/librustc/middle/trans/cabi_x86_64.rs +++ b/src/librustc/middle/trans/cabi_x86_64.rs @@ -18,6 +18,14 @@ use lib::llvm::struct_tys; use middle::trans::common::*; use middle::trans::cabi::*; +use core::cmp; +use core::libc::c_uint; +use core::option; +use core::option::Option; +use core::ptr; +use core::uint; +use core::vec; + enum x86_64_reg_class { no_class, integer_class, diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index 42542d79f39..11f1eaba825 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -18,21 +18,33 @@ use core::prelude::*; -use lib::llvm::ValueRef; -use middle::trans::base::{get_item_val, trans_external_path}; +use back::abi; +use driver::session; +use lib; +use lib::llvm::{ValueRef, TypeRef}; +use lib::llvm::llvm; +use metadata::csearch; +use middle::trans::base; +use middle::trans::base::*; use middle::trans::build::*; use middle::trans::callee; use middle::trans::closure; -use middle::trans::common::{block, node_id_type_params}; +use middle::trans::common; +use middle::trans::common::*; use middle::trans::datum::*; use middle::trans::datum::Datum; +use middle::trans::expr; +use middle::trans::glue; use middle::trans::inline; use middle::trans::meth; use middle::trans::monomorphize; +use middle::trans::type_of; +use middle::ty; use middle::typeck; use util::common::indenter; use syntax::ast; +use syntax::ast_map; use syntax::print::pprust::{expr_to_str, stmt_to_str, path_to_str}; use syntax::visit; diff --git a/src/librustc/middle/trans/closure.rs b/src/librustc/middle/trans/closure.rs index 40407fbf52b..949318d1723 100644 --- a/src/librustc/middle/trans/closure.rs +++ b/src/librustc/middle/trans/closure.rs @@ -13,8 +13,7 @@ use core::prelude::*; use back::abi; use back::link::{mangle_internal_name_by_path_and_seq}; use back::link::{mangle_internal_name_by_path}; -use lib::llvm::llvm; -use lib::llvm::{ValueRef, TypeRef}; +use lib::llvm::{llvm, ValueRef, TypeRef}; use middle::moves; use middle::trans::base::*; use middle::trans::build::*; @@ -25,6 +24,7 @@ use middle::trans::expr; use middle::trans::glue; use middle::trans::machine; use middle::trans::type_of::*; +use middle::ty; use util::ppaux::ty_to_str; use core::libc::c_uint; @@ -33,6 +33,7 @@ use syntax::ast; use syntax::ast_map::{path, path_mod, path_name}; use syntax::ast_util; use syntax::codemap::span; +use syntax::parse::token::special_idents; use syntax::print::pprust::expr_to_str; // ___Good to know (tm)__________________________________________________ @@ -185,7 +186,7 @@ pub fn allocate_cbox(bcx: block, sigil: ast::Sigil, cdata_ty: ty::t) } ast::BorrowedSigil => { let cbox_ty = tuplify_box_ty(tcx, cdata_ty); - let llbox = base::alloc_ty(bcx, cbox_ty); + let llbox = alloc_ty(bcx, cbox_ty); nuke_ref_count(bcx, llbox); rslt(bcx, llbox) } @@ -342,7 +343,7 @@ pub fn load_environment(fcx: fn_ctxt, let bcx = raw_block(fcx, false, llloadenv); // Load a pointer to the closure data, skipping over the box header: - let llcdata = base::opaque_box_body(bcx, cdata_ty, fcx.llenv); + let llcdata = opaque_box_body(bcx, cdata_ty, fcx.llenv); // Populate the upvars from the environment. let mut i = 0u; diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index 566b2689f2e..5ce20ac23bc 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -157,7 +157,7 @@ pub fn BuilderRef_res(B: BuilderRef) -> BuilderRef_res { } } -type ExternMap = HashMap<@str, ValueRef>; +pub type ExternMap = HashMap<@str, ValueRef>; // Crate context. Every crate we compile has one of these. pub struct CrateContext { diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index ab85da304cb..36cda3dfbe9 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -10,14 +10,18 @@ use core::prelude::*; +use lib::llvm::{llvm, ValueRef, True, TypeRef, False}; use middle::const_eval; +use middle::trans::base; use middle::trans::base::get_insn_ctxt; use middle::trans::common::*; use middle::trans::consts; use middle::trans::expr; use middle::trans::machine; +use middle::trans::type_of; use middle::ty; +use core::libc::c_uint; use syntax::{ast, ast_util, codemap, ast_map}; pub fn const_lit(cx: @CrateContext, e: @ast::expr, lit: ast::lit) diff --git a/src/librustc/middle/trans/controlflow.rs b/src/librustc/middle/trans/controlflow.rs index 70321d50f3f..9b282e71b3e 100644 --- a/src/librustc/middle/trans/controlflow.rs +++ b/src/librustc/middle/trans/controlflow.rs @@ -10,13 +10,28 @@ use core::prelude::*; -use lib::llvm::ValueRef; +use back::link; +use lib; +use lib::llvm::*; use middle::trans::base::*; +use middle::trans::build::*; use middle::trans::callee; use middle::trans::common::*; use middle::trans::datum::*; +use middle::trans::debuginfo; +use middle::trans::expr; +use middle::trans::type_of::*; +use middle::ty; +use util::common::indenter; +use util::ppaux; use core::str; +use syntax::ast; +use syntax::ast::ident; +use syntax::ast_map::path_mod; +use syntax::ast_util; +use syntax::codemap::span; +use syntax::print::pprust::expr_to_str; pub fn trans_block(bcx: block, b: &ast::blk, dest: expr::Dest) -> block { let _icx = bcx.insn_ctxt("trans_block"); diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs index c93ab056de0..94c90aaad6d 100644 --- a/src/librustc/middle/trans/datum.rs +++ b/src/librustc/middle/trans/datum.rs @@ -87,21 +87,29 @@ use core::prelude::*; +use lib; use lib::llvm::ValueRef; use middle::borrowck::{RootInfo, root_map_key}; use middle::trans::base::*; use middle::trans::build::*; +use middle::trans::callee; use middle::trans::common::*; use middle::trans::common; +use middle::trans::expr; +use middle::trans::glue; use middle::trans::tvec; +use middle::trans::type_of; +use middle::ty; use middle::typeck; use util::common::indenter; use util::ppaux::ty_to_str; use core::cmp; use core::option; +use core::to_bytes; use core::uint; use core::vec; +use syntax::ast; use syntax::parse::token::special_idents; #[deriving_eq] @@ -326,7 +334,7 @@ pub impl Datum { Store(bcx, self.val, dst); } ByRef => { - base::memcpy_ty(bcx, dst, self.val, self.ty); + memcpy_ty(bcx, dst, self.val, self.ty); } } @@ -354,7 +362,7 @@ pub impl Datum { match self.mode { ByRef => { - base::memcpy_ty(bcx, dst, self.val, self.ty); + memcpy_ty(bcx, dst, self.val, self.ty); } ByValue => { Store(bcx, self.val, dst); @@ -540,7 +548,7 @@ pub impl Datum { let scratch = scratch_datum(bcx, self.ty, true); self.copy_to_datum(bcx, INIT, scratch); - base::add_root_cleanup(bcx, root_info, scratch.val, scratch.ty); + add_root_cleanup(bcx, root_info, scratch.val, scratch.ty); // If we need to freeze the box, do that now. if root_info.freezes { diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index 0dd30af4b71..c6ed190c7c3 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -121,10 +121,15 @@ lvalues are *never* stored by value. use core::prelude::*; -use lib::llvm::ValueRef; +use back::abi; +use lib; +use lib::llvm::{ValueRef, TypeRef, llvm, True}; use middle::borrowck::root_map_key; use middle::resolve; +use middle::trans::_match; +use middle::trans::base; use middle::trans::base::*; +use middle::trans::build::*; use middle::trans::callee::{AutorefArg, DoAutorefArg, DontAutorefArg}; use middle::trans::callee; use middle::trans::closure; @@ -132,16 +137,21 @@ use middle::trans::common::*; use middle::trans::consts; use middle::trans::controlflow; use middle::trans::datum::*; +use middle::trans::debuginfo; use middle::trans::machine; use middle::trans::meth; use middle::trans::tvec; +use middle::trans::type_of; +use middle::ty; use middle::ty::struct_mutable_fields; use middle::ty::{AutoPtr, AutoBorrowVec, AutoBorrowVecRef, AutoBorrowFn}; use util::common::indenter; use util::ppaux::ty_to_str; +use std::oldmap::HashMap; use syntax::print::pprust::{expr_to_str}; use syntax::ast; +use syntax::codemap; use syntax::codemap::spanned; // Destinations @@ -1128,7 +1138,7 @@ fn trans_rec_or_struct(bcx: block, let fields = ty::struct_mutable_fields( tcx, variant_id, substs); let field_lltys = do fields.map |field| { - type_of(bcx.ccx(), + type_of::type_of(bcx.ccx(), ty::subst_tps( tcx, substs.tps, None, field.mt.ty)) }; diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs index ef9cc89eb90..aa44e8b1fe9 100644 --- a/src/librustc/middle/trans/foreign.rs +++ b/src/librustc/middle/trans/foreign.rs @@ -11,6 +11,7 @@ use core::prelude::*; use back::{link, abi}; +use driver::session; use driver::session::arch_x86_64; use driver::session::arch_arm; use lib::llvm::{SequentiallyConsistent, Acquire, Release, Xchg}; @@ -27,11 +28,13 @@ use middle::trans::callee::*; use middle::trans::common::*; use middle::trans::datum::*; use middle::trans::expr::{Dest, Ignore}; +use middle::trans::machine::llsize_of; use middle::trans::glue; use middle::trans::machine; use middle::trans::shape; use middle::trans::type_of::*; use middle::trans::type_of; +use middle::ty; use middle::ty::{FnSig, arg}; use util::ppaux::ty_to_str; diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs index bcb22022d46..96deb2906eb 100644 --- a/src/librustc/middle/trans/glue.rs +++ b/src/librustc/middle/trans/glue.rs @@ -14,19 +14,32 @@ use core::prelude::*; -use lib::llvm::{ValueRef, TypeRef}; +use back::abi; +use back::link::*; +use driver::session; +use lib; +use lib::llvm::{llvm, ValueRef, TypeRef, True}; use middle::trans::base::*; use middle::trans::callee; use middle::trans::closure; use middle::trans::common::*; use middle::trans::build::*; +use middle::trans::expr; +use middle::trans::machine::*; use middle::trans::reflect; use middle::trans::tvec; -use middle::trans::type_of::type_of; +use middle::trans::type_of::{type_of, type_of_glue_fn}; use middle::trans::uniq; +use middle::ty; +use util::ppaux; +use util::ppaux::ty_to_short_str; use core::io; +use core::libc::c_uint; use core::str; +use std::time; +use syntax::ast; +use syntax::parse::token::special_idents; pub fn trans_free(cx: block, v: ValueRef) -> block { let _icx = cx.insn_ctxt("trans_free"); @@ -218,7 +231,7 @@ pub fn lazily_emit_simplified_tydesc_glue(ccx: @CrateContext, let _icx = ccx.insn_ctxt("lazily_emit_simplified_tydesc_glue"); let simpl = simplified_glue_type(ccx.tcx, field, ti.ty); if simpl != ti.ty { - let simpl_ti = base::get_tydesc(ccx, simpl); + let simpl_ti = get_tydesc(ccx, simpl); lazily_emit_tydesc_glue(ccx, field, simpl_ti); if field == abi::tydesc_field_take_glue { ti.take_glue = @@ -661,7 +674,7 @@ pub fn declare_tydesc(ccx: @CrateContext, t: ty::t) -> @mut tydesc_info { if ccx.sess.count_type_sizes() { io::println(fmt!("%u\t%s", llsize_of_real(ccx, llty), - ty_to_str(ccx.tcx, t))); + ppaux::ty_to_str(ccx.tcx, t))); } let llsize = llsize_of(ccx, llty); @@ -675,7 +688,7 @@ pub fn declare_tydesc(ccx: @CrateContext, t: ty::t) -> @mut tydesc_info { }; // XXX: Bad copy. note_unique_llvm_symbol(ccx, copy name); - log(debug, fmt!("+++ declare_tydesc %s %s", ty_to_str(ccx.tcx, t), name)); + debug!("+++ declare_tydesc %s %s", ppaux::ty_to_str(ccx.tcx, t), name); let gvar = str::as_c_str(name, |buf| { unsafe { llvm::LLVMAddGlobal(ccx.llmod, ccx.tydesc_type, buf) @@ -709,7 +722,7 @@ pub fn declare_generic_glue(ccx: @CrateContext, t: ty::t, llfnty: TypeRef, } else { fn_nm = mangle_internal_name_by_seq(ccx, (~"glue_" + name)); } - debug!("%s is for type %s", fn_nm, ty_to_str(ccx.tcx, t)); + debug!("%s is for type %s", fn_nm, ppaux::ty_to_str(ccx.tcx, t)); // XXX: Bad copy. note_unique_llvm_symbol(ccx, copy fn_nm); let llfn = decl_cdecl_fn(ccx.llmod, fn_nm, llfnty); diff --git a/src/librustc/middle/trans/inline.rs b/src/librustc/middle/trans/inline.rs index b352b078a47..7ce36c2b1e2 100644 --- a/src/librustc/middle/trans/inline.rs +++ b/src/librustc/middle/trans/inline.rs @@ -10,6 +10,7 @@ use core::prelude::*; +use metadata::csearch; use middle::astencode; use middle::trans::base::{get_insn_ctxt}; use middle::trans::base::{impl_owned_self, impl_self, no_self}; @@ -18,6 +19,8 @@ use middle::trans::common::*; use middle::trans::common; use middle::trans::inline; use middle::trans::monomorphize; +use middle::ty; +use util::ppaux::ty_to_str; use core::vec; use syntax::ast; diff --git a/src/librustc/middle/trans/machine.rs b/src/librustc/middle/trans/machine.rs index bfada859bc2..8d447f54c20 100644 --- a/src/librustc/middle/trans/machine.rs +++ b/src/librustc/middle/trans/machine.rs @@ -11,6 +11,9 @@ // Information concerning the machine representation of various types. +use lib::llvm::{ModuleRef, ValueRef, TypeRef, BasicBlockRef, BuilderRef}; +use lib::llvm::{True, False, Bool}; +use lib::llvm::llvm; use middle::trans::common::*; use middle::trans::type_of; use middle::ty; @@ -122,7 +125,7 @@ pub fn llalign_of_min(cx: @CrateContext, t: TypeRef) -> uint { pub fn llalign_of(cx: @CrateContext, t: TypeRef) -> ValueRef { unsafe { return llvm::LLVMConstIntCast( - lib::llvm::llvm::LLVMAlignOf(t), cx.int_type, False); + llvm::LLVMAlignOf(t), cx.int_type, False); } } diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs index 777711889c7..5e7d13c3ad3 100644 --- a/src/librustc/middle/trans/meth.rs +++ b/src/librustc/middle/trans/meth.rs @@ -28,14 +28,16 @@ use middle::trans::glue; use middle::trans::inline; use middle::trans::monomorphize; use middle::trans::type_of::*; +use middle::ty; use middle::ty::arg; use middle::typeck; +use util::common::indenter; use util::ppaux::{ty_to_str, tys_to_str}; use core::libc::c_uint; use std::oldmap::HashMap; use syntax::ast_map::{path, path_mod, path_name, node_id_to_str}; -use syntax::ast_util::local_def; +use syntax::ast_util; use syntax::print::pprust::expr_to_str; use syntax::{ast, ast_map}; @@ -351,7 +353,7 @@ pub fn trans_static_method_callee(bcx: block, pub fn method_from_methods(ms: ~[@ast::method], name: ast::ident) -> Option { - ms.find(|m| m.ident == name).map(|m| local_def(m.id)) + ms.find(|m| m.ident == name).map(|m| ast_util::local_def(m.id)) } pub fn method_with_name(ccx: @CrateContext, impl_id: ast::def_id, @@ -725,7 +727,7 @@ pub fn trans_trait_callee_from_llval(bcx: block, // Load the function from the vtable and cast it to the expected type. debug!("(translating trait callee) loading method"); - let llcallee_ty = type_of::type_of_fn_from_ty(ccx, callee_ty); + let llcallee_ty = type_of_fn_from_ty(ccx, callee_ty); let mptr = Load(bcx, GEPi(bcx, llvtable, [0u, n_method])); let mptr = PointerCast(bcx, mptr, T_ptr(llcallee_ty)); @@ -885,8 +887,7 @@ pub fn trans_trait_cast(bcx: block, // Just store the pointer into the pair. llboxdest = PointerCast(bcx, llboxdest, - T_ptr(type_of::type_of(bcx.ccx(), - v_ty))); + T_ptr(type_of(bcx.ccx(), v_ty))); bcx = expr::trans_into(bcx, val, SaveIn(llboxdest)); } } @@ -896,7 +897,7 @@ pub fn trans_trait_cast(bcx: block, let mut llvaldest = GEPi(bcx, lldest, [0, 1]); llvaldest = PointerCast(bcx, llvaldest, - T_ptr(type_of::type_of(bcx.ccx(), v_ty))); + T_ptr(type_of(bcx.ccx(), v_ty))); bcx = expr::trans_into(bcx, val, SaveIn(llvaldest)); // Get the type descriptor of the wrapped value and store it into diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc/middle/trans/monomorphize.rs index 9be316b3022..30a42210a13 100644 --- a/src/librustc/middle/trans/monomorphize.rs +++ b/src/librustc/middle/trans/monomorphize.rs @@ -11,6 +11,8 @@ use core::prelude::*; use back::link::mangle_exported_name; +use driver::session; +use lib::llvm::ValueRef; use middle::trans::base::{get_insn_ctxt}; use middle::trans::base::{set_inline_hint_if_appr, set_inline_hint}; use middle::trans::base::{trans_enum_variant, trans_struct_dtor}; @@ -26,12 +28,15 @@ use middle::trans::shape; use middle::trans::type_of::type_of_fn_from_ty; use middle::trans::type_of; use middle::trans::type_use; +use middle::ty; use middle::ty::{FnSig}; use middle::typeck; +use util::ppaux::ty_to_str; use core::option; use core::vec; use syntax::ast; +use syntax::ast_map; use syntax::ast_map::{path, path_mod, path_name}; use syntax::ast_util::local_def; use syntax::parse::token::special_idents; diff --git a/src/librustc/middle/trans/reachable.rs b/src/librustc/middle/trans/reachable.rs index a235322532b..a8fb909a5a0 100644 --- a/src/librustc/middle/trans/reachable.rs +++ b/src/librustc/middle/trans/reachable.rs @@ -21,11 +21,13 @@ use middle::resolve; use middle::ty; use middle::typeck; -use core::vec; +use core::prelude::*; use std::oldmap::HashMap; +use syntax::ast; use syntax::ast::*; use syntax::ast_util::def_id_of_def; use syntax::attr; +use syntax::codemap; use syntax::print::pprust::expr_to_str; use syntax::{visit, ast_util, ast_map}; diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs index 1fa97325313..dcfa897ab60 100644 --- a/src/librustc/middle/trans/reflect.rs +++ b/src/librustc/middle/trans/reflect.rs @@ -22,8 +22,11 @@ use middle::trans::glue; use middle::trans::machine; use middle::trans::meth; use middle::trans::type_of::*; +use middle::ty; use util::ppaux::ty_to_str; +use core::option::None; +use core::vec; use std::oldmap::HashMap; use syntax::ast::def_id; use syntax::ast; @@ -60,7 +63,7 @@ pub impl Reflector { } fn c_size_and_align(&mut self, t: ty::t) -> ~[ValueRef] { - let tr = type_of::type_of(self.bcx.ccx(), t); + let tr = type_of(self.bcx.ccx(), t); let s = machine::llsize_of_real(self.bcx.ccx(), tr); let a = machine::llalign_of_min(self.bcx.ccx(), tr); return ~[self.c_uint(s), @@ -351,7 +354,7 @@ pub fn emit_calls_to_trait_visit_ty(bcx: block, let final = sub_block(bcx, ~"final"); assert bcx.ccx().tcx.intrinsic_defs.contains_key(&tydesc); let (_, tydesc_ty) = bcx.ccx().tcx.intrinsic_defs.get(&tydesc); - let tydesc_ty = type_of::type_of(bcx.ccx(), tydesc_ty); + let tydesc_ty = type_of(bcx.ccx(), tydesc_ty); let mut r = Reflector { visitor_val: visitor_val, visitor_methods: ty::trait_methods(bcx.tcx(), visitor_trait_id), diff --git a/src/librustc/middle/trans/shape.rs b/src/librustc/middle/trans/shape.rs index 72e2369111d..72e4fa2f4eb 100644 --- a/src/librustc/middle/trans/shape.rs +++ b/src/librustc/middle/trans/shape.rs @@ -25,6 +25,7 @@ use util::ppaux::ty_to_str; use core::dvec::DVec; use core::option::is_some; +use core::str; use core::vec; use std::oldmap::HashMap; use syntax::ast; diff --git a/src/librustc/middle/trans/tvec.rs b/src/librustc/middle/trans/tvec.rs index dc004c81b11..4ce60daf60f 100644 --- a/src/librustc/middle/trans/tvec.rs +++ b/src/librustc/middle/trans/tvec.rs @@ -10,20 +10,27 @@ use back::abi; -use lib::llvm::{ValueRef, TypeRef}; +use lib; +use lib::llvm::{llvm, ValueRef, TypeRef}; +use middle::trans::base; +use middle::trans::base::*; use middle::trans::build::*; +use middle::trans::callee; use middle::trans::common::*; use middle::trans::datum::*; use middle::trans::expr::{Dest, Ignore, SaveIn}; use middle::trans::expr; use middle::trans::glue; -use middle::trans::shape::{llsize_of, nonzero_llsize_of}; +use middle::trans::machine::{llsize_of, nonzero_llsize_of}; use middle::trans::type_of; use middle::ty; use util::common::indenter; use util::ppaux::ty_to_str; +use core::uint; +use core::vec; use syntax::ast; +use syntax::codemap; use syntax::codemap::span; use syntax::print::pprust::{expr_to_str}; @@ -81,7 +88,7 @@ pub fn alloc_raw(bcx: block, unit_ty: ty::t, let vecbodyty = ty::mk_mut_unboxed_vec(bcx.tcx(), unit_ty); let vecsize = Add(bcx, alloc, llsize_of(ccx, ccx.opaque_vec_type)); - let MallocResult {bcx, box: bx, body} = + let base::MallocResult {bcx, box: bx, body} = base::malloc_general_dyn(bcx, vecbodyty, heap, vecsize); Store(bcx, fill, GEPi(bcx, body, [0u, abi::vec_elt_fill])); Store(bcx, alloc, GEPi(bcx, body, [0u, abi::vec_elt_alloc])); @@ -91,7 +98,7 @@ pub fn alloc_raw(bcx: block, unit_ty: ty::t, pub fn alloc_uniq_raw(bcx: block, unit_ty: ty::t, fill: ValueRef, alloc: ValueRef) -> Result { - alloc_raw(bcx, unit_ty, fill, alloc, heap_for_unique(bcx, unit_ty)) + alloc_raw(bcx, unit_ty, fill, alloc, base::heap_for_unique(bcx, unit_ty)) } pub fn alloc_vec(bcx: block, @@ -305,13 +312,13 @@ pub fn trans_uniq_or_managed_vstore(bcx: block, let llptrval = PointerCast(bcx, llptrval, T_ptr(T_i8())); let llsizeval = C_uint(bcx.ccx(), s.len()); let typ = ty::mk_estr(bcx.tcx(), ty::vstore_uniq); - let lldestval = datum::scratch_datum(bcx, typ, false); + let lldestval = scratch_datum(bcx, typ, false); let bcx = callee::trans_lang_call( bcx, bcx.tcx().lang_items.strdup_uniq_fn(), ~[ llptrval, llsizeval ], expr::SaveIn(lldestval.to_ref_llval(bcx))); - return datum::DatumBlock { + return DatumBlock { bcx: bcx, datum: lldestval }; @@ -508,8 +515,8 @@ pub fn get_base_and_len(bcx: block, (base, len) } ty::vstore_uniq | ty::vstore_box => { - let body = tvec::get_bodyptr(bcx, llval); - (tvec::get_dataptr(bcx, body), tvec::get_fill(bcx, body)) + let body = get_bodyptr(bcx, llval); + (get_dataptr(bcx, body), get_fill(bcx, body)) } } } diff --git a/src/librustc/middle/trans/type_of.rs b/src/librustc/middle/trans/type_of.rs index 8275db8cdb2..7d3aa4c24f4 100644 --- a/src/librustc/middle/trans/type_of.rs +++ b/src/librustc/middle/trans/type_of.rs @@ -11,12 +11,16 @@ use lib::llvm::llvm; use lib::llvm::{TypeRef}; +use middle::trans::base; use middle::trans::common::*; use middle::trans::common; use middle::trans::expr; use middle::trans::machine; +use middle::ty; use util::ppaux; +use core::option::None; +use core::vec; use std::oldmap::HashMap; use syntax::ast; @@ -387,7 +391,7 @@ pub fn type_of_dtor(ccx: @CrateContext, self_ty: ty::t) -> TypeRef { pub fn type_of_rooted(ccx: @CrateContext, t: ty::t) -> TypeRef { let addrspace = base::get_tydesc(ccx, t).addrspace; debug!("type_of_rooted %s in addrspace %u", - ty_to_str(ccx.tcx, t), addrspace as uint); + ppaux::ty_to_str(ccx.tcx, t), addrspace as uint); return T_root(type_of(ccx, t), addrspace); } diff --git a/src/librustc/middle/trans/type_use.rs b/src/librustc/middle/trans/type_use.rs index 2fc7497f5e3..734b4ea53da 100644 --- a/src/librustc/middle/trans/type_use.rs +++ b/src/librustc/middle/trans/type_use.rs @@ -32,13 +32,17 @@ use metadata::csearch; use middle::freevars; use middle::trans::common::*; use middle::trans::inline; +use middle::ty; +use middle::typeck; use core::option; +use core::option::{Some, None, Option}; use core::uint; use core::vec; use std::list::{List, Cons, Nil}; use std::list; use std::oldmap::HashMap; +use syntax::ast; use syntax::ast::*; use syntax::ast_map; use syntax::ast_util; diff --git a/src/librustc/middle/trans/uniq.rs b/src/librustc/middle/trans/uniq.rs index aa02cc4bf5d..7db76258404 100644 --- a/src/librustc/middle/trans/uniq.rs +++ b/src/librustc/middle/trans/uniq.rs @@ -17,6 +17,7 @@ use middle::trans::common::*; use middle::trans::datum::immediate_rvalue; use middle::trans::datum; use middle::trans::glue; +use middle::ty; use syntax::ast; diff --git a/src/librustc/middle/typeck/infer/combine.rs b/src/librustc/middle/typeck/infer/combine.rs index f63dac4c5ae..e140bcad11c 100644 --- a/src/librustc/middle/typeck/infer/combine.rs +++ b/src/librustc/middle/typeck/infer/combine.rs @@ -316,7 +316,7 @@ pub fn super_modes( ty::unify_mode(tcx, expected_found(self, a, b)) } -fn super_args( +pub fn super_args( self: &C, a: ty::arg, b: ty::arg) -> cres { diff --git a/src/librustc/middle/typeck/infer/glb.rs b/src/librustc/middle/typeck/infer/glb.rs index 936ca1e8297..981d7be3d5f 100644 --- a/src/librustc/middle/typeck/infer/glb.rs +++ b/src/librustc/middle/typeck/infer/glb.rs @@ -18,9 +18,14 @@ use middle::typeck::infer::lattice::*; use middle::typeck::infer::lub::Lub; use middle::typeck::infer::sub::Sub; use middle::typeck::infer::to_str::InferStr; +use middle::typeck::infer::{cres, InferCtxt}; use middle::typeck::isr_alist; +use syntax::ast; use syntax::ast::{Many, Once, extern_fn, impure_fn, m_const, m_imm, m_mutbl}; use syntax::ast::{noreturn, pure_fn, ret_style, return_val, unsafe_fn}; +use syntax::ast::{Onceness, purity}; +use syntax::codemap::span; +use util::common::{indent, indenter}; use util::ppaux::mt_to_str; use std::list; diff --git a/src/librustc/middle/typeck/infer/lattice.rs b/src/librustc/middle/typeck/infer/lattice.rs index 8fa887fca0b..fe12af52d26 100644 --- a/src/librustc/middle/typeck/infer/lattice.rs +++ b/src/librustc/middle/typeck/infer/lattice.rs @@ -34,7 +34,7 @@ use core::prelude::*; -use middle::ty::{RegionVid, TyVar}; +use middle::ty::{RegionVid, TyVar, Vid}; use middle::ty; use middle::typeck::isr_alist; use middle::typeck::infer::*; @@ -46,6 +46,7 @@ use middle::typeck::infer::sub::Sub; use middle::typeck::infer::lub::Lub; use middle::typeck::infer::glb::Glb; use middle::typeck::infer::to_str::InferStr; +use util::common::indenter; use std::list; diff --git a/src/librustc/middle/typeck/infer/lub.rs b/src/librustc/middle/typeck/infer/lub.rs index 2c4fd9f01ee..83cbd4c745c 100644 --- a/src/librustc/middle/typeck/infer/lub.rs +++ b/src/librustc/middle/typeck/infer/lub.rs @@ -17,12 +17,17 @@ use middle::typeck::infer::glb::Glb; use middle::typeck::infer::lattice::*; use middle::typeck::infer::sub::Sub; use middle::typeck::infer::to_str::InferStr; +use middle::typeck::infer::{cres, InferCtxt}; use middle::typeck::isr_alist; +use util::common::indent; use util::ppaux::mt_to_str; use std::list; +use syntax::ast; use syntax::ast::{Many, Once, extern_fn, m_const, impure_fn, noreturn}; use syntax::ast::{pure_fn, ret_style, return_val, unsafe_fn}; +use syntax::ast::{Onceness, purity}; +use syntax::codemap::span; pub enum Lub = CombineFields; // least-upper-bound: common supertype diff --git a/src/librustc/middle/typeck/infer/sub.rs b/src/librustc/middle/typeck/infer/sub.rs index 5552b71d0d7..aaaf3b425c2 100644 --- a/src/librustc/middle/typeck/infer/sub.rs +++ b/src/librustc/middle/typeck/infer/sub.rs @@ -11,6 +11,7 @@ use core::prelude::*; use middle::ty; +use middle::ty::TyVar; use middle::typeck::check::regionmanip::replace_bound_regions_in_fn_sig; use middle::typeck::infer::combine::*; use middle::typeck::infer::cres; @@ -19,11 +20,14 @@ use middle::typeck::infer::InferCtxt; use middle::typeck::infer::lub::Lub; use middle::typeck::infer::to_str::InferStr; use middle::typeck::infer::unify::*; +use util::common::{indent, indenter}; use util::ppaux::bound_region_to_str; use std::list::Nil; use std::list; -use syntax::ast::{m_const, purity, ret_style}; +use syntax::ast; +use syntax::ast::{Onceness, m_const, purity, ret_style}; +use syntax::codemap::span; pub enum Sub = CombineFields; // "subtype", "subregion" etc diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index 1e2abbe0287..11eb388f9aa 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -497,6 +497,7 @@ mod tests { use arc::*; use arc; + use core::cell::Cell; use core::option::{Some, None}; use core::option; use core::pipes; diff --git a/src/libstd/deque.rs b/src/libstd/deque.rs index 4d8c60a6614..f6fcf6c8d3b 100644 --- a/src/libstd/deque.rs +++ b/src/libstd/deque.rs @@ -116,6 +116,9 @@ fn get(elts: &r/[Option], i: uint) -> &r/T { #[cfg(test)] mod tests { use super::*; + use core::cmp::Eq; + use core::kinds::{Durable, Copy}; + use core::prelude::debug; #[test] fn test_simple() { diff --git a/src/libstd/flatpipes.rs b/src/libstd/flatpipes.rs index 2ee994bdf32..73dbe4bea57 100644 --- a/src/libstd/flatpipes.rs +++ b/src/libstd/flatpipes.rs @@ -636,6 +636,7 @@ mod test { use DefaultEncoder = json::Encoder; use DefaultDecoder = json::Decoder; + use flatpipes::{Flattener, Unflattener}; use flatpipes::flatteners::*; use flatpipes::bytepipes::*; use flatpipes::pod; @@ -647,7 +648,7 @@ mod test { use core::dvec::DVec; use core::int; - use core::io::BytesReader; + use core::io::{BytesReader, BytesWriter}; use core::io; use core::prelude::*; use core::result; diff --git a/src/libstd/future.rs b/src/libstd/future.rs index b9c7c9f3a13..c5775406125 100644 --- a/src/libstd/future.rs +++ b/src/libstd/future.rs @@ -150,7 +150,7 @@ pub mod test { use future::*; - use core::comm::oneshot; + use core::comm::{oneshot, send_one}; use core::task; #[test] diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index 3726943321c..dd205583259 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -445,7 +445,7 @@ pub fn opt_default(mm: &Matches, nm: &str, def: &str) -> Option<~str> { } #[deriving_eq] -enum FailType { +pub enum FailType { ArgumentMissing_, UnrecognizedOption_, OptionMissing_, diff --git a/src/libstd/json.rs b/src/libstd/json.rs index c6e76aa1a68..d1a65517aad 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -1208,6 +1208,7 @@ mod tests { use core::prelude::*; use json::*; + use serialize; use core::result; use core::hashmap::linear::LinearMap; diff --git a/src/libstd/net_url.rs b/src/libstd/net_url.rs index 29cb57c01be..08b7b3d6ae5 100644 --- a/src/libstd/net_url.rs +++ b/src/libstd/net_url.rs @@ -730,6 +730,91 @@ impl to_bytes::IterBytes for Url { } } +// Put a few tests outside of the 'test' module so they can test the internal +// functions and those functions don't need 'pub' + +#[test] +fn test_split_char_first() { + let (u,v) = split_char_first(~"hello, sweet world", ','); + assert u == ~"hello"; + assert v == ~" sweet world"; + + let (u,v) = split_char_first(~"hello sweet world", ','); + assert u == ~"hello sweet world"; + assert v == ~""; +} + +#[test] +fn test_get_authority() { + let (u, h, p, r) = get_authority( + "//user:pass@rust-lang.org/something").unwrap(); + assert u == Some(UserInfo::new(~"user", Some(~"pass"))); + assert h == ~"rust-lang.org"; + assert p.is_none(); + assert r == ~"/something"; + + let (u, h, p, r) = get_authority( + "//rust-lang.org:8000?something").unwrap(); + assert u.is_none(); + assert h == ~"rust-lang.org"; + assert p == Some(~"8000"); + assert r == ~"?something"; + + let (u, h, p, r) = get_authority( + "//rust-lang.org#blah").unwrap(); + assert u.is_none(); + assert h == ~"rust-lang.org"; + assert p.is_none(); + assert r == ~"#blah"; + + // ipv6 tests + let (_, h, _, _) = get_authority( + "//2001:0db8:85a3:0042:0000:8a2e:0370:7334#blah").unwrap(); + assert h == ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334"; + + let (_, h, p, _) = get_authority( + "//2001:0db8:85a3:0042:0000:8a2e:0370:7334:8000#blah").unwrap(); + assert h == ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334"; + assert p == Some(~"8000"); + + let (u, h, p, _) = get_authority( + "//us:p@2001:0db8:85a3:0042:0000:8a2e:0370:7334:8000#blah" + ).unwrap(); + assert u == Some(UserInfo::new(~"us", Some(~"p"))); + assert h == ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334"; + assert p == Some(~"8000"); + + // invalid authorities; + assert get_authority("//user:pass@rust-lang:something").is_err(); + assert get_authority("//user@rust-lang:something:/path").is_err(); + assert get_authority( + "//2001:0db8:85a3:0042:0000:8a2e:0370:7334:800a").is_err(); + assert get_authority( + "//2001:0db8:85a3:0042:0000:8a2e:0370:7334:8000:00").is_err(); + + // these parse as empty, because they don't start with '//' + let (_, h, _, _) = get_authority(~"user:pass@rust-lang").unwrap(); + assert h == ~""; + let (_, h, _, _) = get_authority(~"rust-lang.org").unwrap(); + assert h == ~""; +} + +#[test] +fn test_get_path() { + let (p, r) = get_path("/something+%20orother", true).unwrap(); + assert p == ~"/something+ orother"; + assert r == ~""; + let (p, r) = get_path("test@email.com#fragment", false).unwrap(); + assert p == ~"test@email.com"; + assert r == ~"#fragment"; + let (p, r) = get_path(~"/gen/:addr=?q=v", false).unwrap(); + assert p == ~"/gen/:addr="; + assert r == ~"?q=v"; + + //failure cases + assert get_path(~"something?q", true).is_err(); +} + #[cfg(test)] mod tests { use core::prelude::*; @@ -737,91 +822,10 @@ mod tests { use net_url::*; use net_url::UserInfo; + use core::hashmap::linear::LinearMap; use core::result; use core::str; - #[test] - pub fn test_split_char_first() { - let (u,v) = split_char_first(~"hello, sweet world", ','); - assert u == ~"hello"; - assert v == ~" sweet world"; - - let (u,v) = split_char_first(~"hello sweet world", ','); - assert u == ~"hello sweet world"; - assert v == ~""; - } - - #[test] - pub fn test_get_authority() { - let (u, h, p, r) = get_authority( - "//user:pass@rust-lang.org/something").unwrap(); - assert u == Some(UserInfo::new(~"user", Some(~"pass"))); - assert h == ~"rust-lang.org"; - assert p.is_none(); - assert r == ~"/something"; - - let (u, h, p, r) = get_authority( - "//rust-lang.org:8000?something").unwrap(); - assert u.is_none(); - assert h == ~"rust-lang.org"; - assert p == Some(~"8000"); - assert r == ~"?something"; - - let (u, h, p, r) = get_authority( - "//rust-lang.org#blah").unwrap(); - assert u.is_none(); - assert h == ~"rust-lang.org"; - assert p.is_none(); - assert r == ~"#blah"; - - // ipv6 tests - let (_, h, _, _) = get_authority( - "//2001:0db8:85a3:0042:0000:8a2e:0370:7334#blah").unwrap(); - assert h == ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334"; - - let (_, h, p, _) = get_authority( - "//2001:0db8:85a3:0042:0000:8a2e:0370:7334:8000#blah").unwrap(); - assert h == ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334"; - assert p == Some(~"8000"); - - let (u, h, p, _) = get_authority( - "//us:p@2001:0db8:85a3:0042:0000:8a2e:0370:7334:8000#blah" - ).unwrap(); - assert u == Some(UserInfo::new(~"us", Some(~"p"))); - assert h == ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334"; - assert p == Some(~"8000"); - - // invalid authorities; - assert get_authority("//user:pass@rust-lang:something").is_err(); - assert get_authority("//user@rust-lang:something:/path").is_err(); - assert get_authority( - "//2001:0db8:85a3:0042:0000:8a2e:0370:7334:800a").is_err(); - assert get_authority( - "//2001:0db8:85a3:0042:0000:8a2e:0370:7334:8000:00").is_err(); - - // these parse as empty, because they don't start with '//' - let (_, h, _, _) = get_authority(~"user:pass@rust-lang").unwrap(); - assert h == ~""; - let (_, h, _, _) = get_authority(~"rust-lang.org").unwrap(); - assert h == ~""; - } - - #[test] - pub fn test_get_path() { - let (p, r) = get_path("/something+%20orother", true).unwrap(); - assert p == ~"/something+ orother"; - assert r == ~""; - let (p, r) = get_path("test@email.com#fragment", false).unwrap(); - assert p == ~"test@email.com"; - assert r == ~"#fragment"; - let (p, r) = get_path(~"/gen/:addr=?q=v", false).unwrap(); - assert p == ~"/gen/:addr="; - assert r == ~"?q=v"; - - //failure cases - assert get_path(~"something?q", true).is_err(); - } - #[test] pub fn test_url_parse() { let url = ~"http://user:pass@rust-lang.org/doc?s=v#something"; diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index 22325e6a83c..39d3fd569a6 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -399,7 +399,7 @@ pub impl &Semaphore { * A task which fails while holding a mutex will unlock the mutex as it * unwinds. */ -struct Mutex { priv sem: Sem<~[Waitqueue]> } +pub struct Mutex { priv sem: Sem<~[Waitqueue]> } /// Create a new mutex, with one associated condvar. pub fn Mutex() -> Mutex { mutex_with_condvars(1) } @@ -447,7 +447,7 @@ struct RWlockInner { * A task which fails while holding an rwlock will unlock the rwlock as it * unwinds. */ -struct RWlock { +pub struct RWlock { priv order_lock: Semaphore, priv access_lock: Sem<~[Waitqueue]>, priv state: Exclusive @@ -712,6 +712,7 @@ mod tests { use sync::*; use core::cast; + use core::cell::Cell; use core::option; use core::pipes; use core::ptr; diff --git a/src/libstd/time.rs b/src/libstd/time.rs index 15dea83815b..6e80665d80e 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -892,6 +892,7 @@ mod tests { use core::float; use core::os; use core::result; + use core::result::{Err, Ok}; use core::str; use core::u64; use core::uint; @@ -902,15 +903,13 @@ mod tests { const some_future_date: i64 = 1577836800i64; // 2020-01-01T00:00:00Z let tv1 = get_time(); - log(debug, ~"tv1=" + uint::to_str(tv1.sec as uint) + ~" sec + " - + uint::to_str(tv1.nsec as uint) + ~" nsec"); + debug!("tv1=%? sec + %? nsec", tv1.sec as uint, tv1.nsec as uint); assert tv1.sec > some_recent_date; assert tv1.nsec < 1000000000i32; let tv2 = get_time(); - log(debug, ~"tv2=" + uint::to_str(tv2.sec as uint) + ~" sec + " - + uint::to_str(tv2.nsec as uint) + ~" nsec"); + debug!("tv2=%? sec + %? nsec", tv2.sec as uint, tv2.nsec as uint); assert tv2.sec >= tv1.sec; assert tv2.sec < some_future_date; @@ -924,16 +923,16 @@ mod tests { let s0 = precise_time_s(); let ns1 = precise_time_ns(); - log(debug, ~"s0=" + float::to_str_digits(s0, 9u) + ~" sec"); + debug!("s0=%s sec", float::to_str_digits(s0, 9u)); assert s0 > 0.; let ns0 = (s0 * 1000000000.) as u64; - log(debug, ~"ns0=" + u64::to_str(ns0) + ~" ns"); + debug!("ns0=%? ns", ns0); - log(debug, ~"ns1=" + u64::to_str(ns1) + ~" ns"); + debug!("ns1=%? ns", ns0); assert ns1 >= ns0; let ns2 = precise_time_ns(); - log(debug, ~"ns2=" + u64::to_str(ns2) + ~" ns"); + debug!("ns2=%? ns", ns0); assert ns2 >= ns1; } diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index cf863217deb..88e4ade4b82 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -207,8 +207,8 @@ pub struct TreeMapIterator { /// Advance the iterator to the next node (in order) and return a /// tuple with a reference to the key and value. If there are no /// more nodes, return `None`. -fn map_next(iter: &mut TreeMapIterator/&r) - -> Option<(&r/K, &r/V)> { +pub fn map_next(iter: &mut TreeMapIterator/&r) + -> Option<(&r/K, &r/V)> { while !iter.stack.is_empty() || iter.node.is_some() { match *iter.node { Some(ref x) => { @@ -226,7 +226,7 @@ fn map_next(iter: &mut TreeMapIterator/&r) } /// Advance the iterator through the map -fn map_advance(iter: &mut TreeMapIterator/&r, +pub fn map_advance(iter: &mut TreeMapIterator/&r, f: fn((&r/K, &r/V)) -> bool) { loop { match map_next(iter) { @@ -683,7 +683,11 @@ fn remove(node: &mut Option<~TreeNode>, key: &K) -> bool { #[cfg(test)] mod test_treemap { use super::*; + use core::cmp::{Ord, Eq}; + use core::option::{Some, Option, None}; + use core::rand; use core::str; + use core::vec; #[test] fn find_empty() { diff --git a/src/libstd/uv_global_loop.rs b/src/libstd/uv_global_loop.rs index 401cecf8811..37d9b3221b2 100644 --- a/src/libstd/uv_global_loop.rs +++ b/src/libstd/uv_global_loop.rs @@ -123,9 +123,11 @@ fn spawn_loop() -> IoTask { mod test { use core::prelude::*; + use get_gl = get; use uv::iotask; use uv::ll; use uv_global_loop::*; + use uv_iotask::IoTask; use core::iter; use core::libc; diff --git a/src/libstd/uv_iotask.rs b/src/libstd/uv_iotask.rs index 52956f152fe..14726a0854d 100644 --- a/src/libstd/uv_iotask.rs +++ b/src/libstd/uv_iotask.rs @@ -202,124 +202,120 @@ extern fn tear_down_close_cb(handle: *ll::uv_async_t) { } #[cfg(test)] -mod test { - use core::prelude::*; - - use uv::ll; - use uv_iotask::*; - - use core::iter; - use core::libc; - use core::ptr; - use core::task; - use core::pipes::{stream, Chan, SharedChan, Port}; - - extern fn async_close_cb(handle: *ll::uv_async_t) { - unsafe { - log(debug, fmt!("async_close_cb handle %?", handle)); - let exit_ch = &(*(ll::get_data_for_uv_handle(handle) - as *AhData)).exit_ch; - let exit_ch = exit_ch.clone(); - exit_ch.send(()); - } - } - extern fn async_handle_cb(handle: *ll::uv_async_t, status: libc::c_int) { - unsafe { - log(debug, - fmt!("async_handle_cb handle %? status %?",handle,status)); - ll::close(handle, async_close_cb); - } - } - struct AhData { - iotask: IoTask, - exit_ch: SharedChan<()> +extern fn async_close_cb(handle: *ll::uv_async_t) { + unsafe { + log(debug, fmt!("async_close_cb handle %?", handle)); + let exit_ch = &(*(ll::get_data_for_uv_handle(handle) + as *AhData)).exit_ch; + let exit_ch = exit_ch.clone(); + exit_ch.send(()); } - fn impl_uv_iotask_async(iotask: &IoTask) { - unsafe { - let async_handle = ll::async_t(); - let ah_ptr = ptr::addr_of(&async_handle); - let (exit_po, exit_ch) = stream::<()>(); - let ah_data = AhData { - iotask: iotask.clone(), - exit_ch: SharedChan(exit_ch) - }; - let ah_data_ptr: *AhData = unsafe { - ptr::to_unsafe_ptr(&ah_data) - }; - debug!("about to interact"); - do interact(iotask) |loop_ptr| { - unsafe { - debug!("interacting"); - ll::async_init(loop_ptr, ah_ptr, async_handle_cb); - ll::set_data_for_uv_handle( - ah_ptr, ah_data_ptr as *libc::c_void); - ll::async_send(ah_ptr); - } - }; - debug!("waiting for async close"); - exit_po.recv(); - } +} + +#[cfg(test)] +extern fn async_handle_cb(handle: *ll::uv_async_t, status: libc::c_int) { + unsafe { + log(debug, + fmt!("async_handle_cb handle %? status %?",handle,status)); + ll::close(handle, async_close_cb); } +} + +#[cfg(test)] +struct AhData { + iotask: IoTask, + exit_ch: SharedChan<()> +} - // this fn documents the bear minimum neccesary to roll your own - // high_level_loop - unsafe fn spawn_test_loop(exit_ch: ~Chan<()>) -> IoTask { - let (iotask_port, iotask_ch) = stream::(); - do task::spawn_sched(task::ManualThreads(1u)) { - debug!("about to run a test loop"); - run_loop(&iotask_ch); - exit_ch.send(()); +#[cfg(test)] +fn impl_uv_iotask_async(iotask: &IoTask) { + unsafe { + let async_handle = ll::async_t(); + let ah_ptr = ptr::addr_of(&async_handle); + let (exit_po, exit_ch) = stream::<()>(); + let ah_data = AhData { + iotask: iotask.clone(), + exit_ch: SharedChan(exit_ch) + }; + let ah_data_ptr: *AhData = unsafe { + ptr::to_unsafe_ptr(&ah_data) }; - return iotask_port.recv(); + debug!("about to interact"); + do interact(iotask) |loop_ptr| { + unsafe { + debug!("interacting"); + ll::async_init(loop_ptr, ah_ptr, async_handle_cb); + ll::set_data_for_uv_handle( + ah_ptr, ah_data_ptr as *libc::c_void); + ll::async_send(ah_ptr); + } + }; + debug!("waiting for async close"); + exit_po.recv(); } +} - extern fn lifetime_handle_close(handle: *libc::c_void) { - unsafe { - log(debug, fmt!("lifetime_handle_close ptr %?", handle)); - } - } +// this fn documents the bear minimum neccesary to roll your own +// high_level_loop +#[cfg(test)] +unsafe fn spawn_test_loop(exit_ch: ~Chan<()>) -> IoTask { + let (iotask_port, iotask_ch) = stream::(); + do task::spawn_sched(task::ManualThreads(1u)) { + debug!("about to run a test loop"); + run_loop(&iotask_ch); + exit_ch.send(()); + }; + return iotask_port.recv(); +} - extern fn lifetime_async_callback(handle: *libc::c_void, - status: libc::c_int) { - log(debug, fmt!("lifetime_handle_close ptr %? status %?", - handle, status)); +#[cfg(test)] +extern fn lifetime_handle_close(handle: *libc::c_void) { + unsafe { + log(debug, fmt!("lifetime_handle_close ptr %?", handle)); } +} - #[test] - fn test_uv_iotask_async() { - unsafe { - let (exit_po, exit_ch) = stream::<()>(); - let iotask = &spawn_test_loop(~exit_ch); - - debug!("spawned iotask"); - - // using this handle to manage the lifetime of the - // high_level_loop, as it will exit the first time one of - // the impl_uv_hl_async() is cleaned up with no one ref'd - // handles on the loop (Which can happen under - // race-condition type situations.. this ensures that the - // loop lives until, at least, all of the - // impl_uv_hl_async() runs have been called, at least. - let (work_exit_po, work_exit_ch) = stream::<()>(); - let work_exit_ch = SharedChan(work_exit_ch); - for iter::repeat(7u) { - let iotask_clone = iotask.clone(); - let work_exit_ch_clone = work_exit_ch.clone(); - do task::spawn_sched(task::ManualThreads(1u)) { - debug!("async"); - impl_uv_iotask_async(&iotask_clone); - debug!("done async"); - work_exit_ch_clone.send(()); - }; - }; - for iter::repeat(7u) { - debug!("waiting"); - work_exit_po.recv(); +#[cfg(test)] +extern fn lifetime_async_callback(handle: *libc::c_void, + status: libc::c_int) { + log(debug, fmt!("lifetime_handle_close ptr %? status %?", + handle, status)); +} + +#[test] +fn test_uv_iotask_async() { + unsafe { + let (exit_po, exit_ch) = stream::<()>(); + let iotask = &spawn_test_loop(~exit_ch); + + debug!("spawned iotask"); + + // using this handle to manage the lifetime of the + // high_level_loop, as it will exit the first time one of + // the impl_uv_hl_async() is cleaned up with no one ref'd + // handles on the loop (Which can happen under + // race-condition type situations.. this ensures that the + // loop lives until, at least, all of the + // impl_uv_hl_async() runs have been called, at least. + let (work_exit_po, work_exit_ch) = stream::<()>(); + let work_exit_ch = SharedChan(work_exit_ch); + for iter::repeat(7u) { + let iotask_clone = iotask.clone(); + let work_exit_ch_clone = work_exit_ch.clone(); + do task::spawn_sched(task::ManualThreads(1u)) { + debug!("async"); + impl_uv_iotask_async(&iotask_clone); + debug!("done async"); + work_exit_ch_clone.send(()); }; - log(debug, ~"sending teardown_loop msg.."); - exit(iotask); - exit_po.recv(); - log(debug, ~"after recv on exit_po.. exiting.."); - } + }; + for iter::repeat(7u) { + debug!("waiting"); + work_exit_po.recv(); + }; + log(debug, ~"sending teardown_loop msg.."); + exit(iotask); + exit_po.recv(); + log(debug, ~"after recv on exit_po.. exiting.."); } } diff --git a/src/libstd/uv_ll.rs b/src/libstd/uv_ll.rs index dd54620c83d..b7111bfb023 100644 --- a/src/libstd/uv_ll.rs +++ b/src/libstd/uv_ll.rs @@ -1199,6 +1199,7 @@ pub mod test { use uv_ll::*; + use core::comm::{SharedChan, stream}; use core::libc; use core::ptr; use core::str; @@ -1687,7 +1688,7 @@ pub mod test { // this is the impl for a test that is (maybe) ran on a // per-platform/arch basis below - fn impl_uv_tcp_server_and_request() { + pub fn impl_uv_tcp_server_and_request() { unsafe { let bind_ip = ~"0.0.0.0"; let request_ip = ~"127.0.0.1"; diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index abaf7025505..40315d175cc 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -16,6 +16,7 @@ use ast_util::{inlined_item_utils, path_to_ident, stmt_id}; use ast_util; use attr; use codemap; +use codemap::spanned; use diagnostic::span_handler; use parse::token::ident_interner; use print::pprust; diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 8a1408ad9c0..ab14f6cc086 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -13,7 +13,7 @@ use core::prelude::*; use ast::*; use ast; use ast_util; -use codemap::{span, BytePos, dummy_sp}; +use codemap::{span, BytePos, dummy_sp, spanned}; use parse::token; use visit; use opt_vec; diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs index aea39502362..43eaef95ee2 100644 --- a/src/libsyntax/ext/auto_encode.rs +++ b/src/libsyntax/ext/auto_encode.rs @@ -93,6 +93,7 @@ use core::prelude::*; use ast; use ast_util; use attr; +use codemap; use codemap::span; use ext::base::*; use parse; diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 0eaf6849b7e..9525369d334 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -82,7 +82,7 @@ pub enum SyntaxExtension { IdentTT(SyntaxExpanderTTItem), } -type SyntaxEnv = @mut MapChain; +pub type SyntaxEnv = @mut MapChain; // Name : the domain of SyntaxEnvs // want to change these to uints.... @@ -98,7 +98,7 @@ type Name = @~str; // toward a more uniform syntax syntax (sorry) where blocks are just // another kind of transformer. -enum Transformer { +pub enum Transformer { // this identifier maps to a syntax extension or macro SE(SyntaxExtension), // should blocks occurring here limit macro scopes? @@ -495,6 +495,7 @@ mod test { use super::*; use super::MapChain; use util::testing::check_equal; + use core::hashmap::linear::LinearMap; #[test] fn testenv () { let mut a = LinearMap::new(); diff --git a/src/libsyntax/ext/concat_idents.rs b/src/libsyntax/ext/concat_idents.rs index d83a9f39c5b..1dc5350c452 100644 --- a/src/libsyntax/ext/concat_idents.rs +++ b/src/libsyntax/ext/concat_idents.rs @@ -10,8 +10,11 @@ use core::prelude::*; +use ast; +use codemap::span; use ext::base::*; use ext::base; +use parse::token; pub fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree]) -> base::MacResult { diff --git a/src/libsyntax/ext/env.rs b/src/libsyntax/ext/env.rs index 4420c020a0b..ce87c2f1363 100644 --- a/src/libsyntax/ext/env.rs +++ b/src/libsyntax/ext/env.rs @@ -15,6 +15,8 @@ * interface. */ +use ast; +use codemap::span; use ext::base::*; use ext::base; use ext::build::mk_uniq_str; diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 9a3e8da2b81..1a67a569845 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -10,13 +10,16 @@ use core::prelude::*; +use ast::{blk_, attribute_, attr_outer, meta_word}; use ast::{crate, expr_, expr_mac, mac_invoc_tt}; use ast::{tt_delim, tt_tok, item_mac, stmt_, stmt_mac, stmt_expr, stmt_semi}; use ast; use attr; -use codemap::{span, CallInfo, ExpandedFrom, NameAndSpan}; +use codemap; +use codemap::{span, CallInfo, ExpandedFrom, NameAndSpan, spanned}; use ext::base::*; use fold::*; +use parse; use parse::{parser, parse_item_from_source_str, new_parser_from_tts}; use core::option; @@ -175,7 +178,7 @@ pub fn expand_item(extsbox: @mut SyntaxEnv, } // does this attribute list contain "macro_escape" ? -fn contains_macro_escape (attrs: &[ast::attribute]) -> bool{ +pub fn contains_macro_escape (attrs: &[ast::attribute]) -> bool{ let mut accum = false; do attrs.each |attr| { let mname = attr::get_attr_name(attr); @@ -473,7 +476,13 @@ pub fn expand_crate(parse_sess: @mut parse::ParseSess, #[cfg(test)] mod test { use super::*; + use ast; + use ast::{attribute_, attr_outer, meta_word}; + use codemap; + use codemap::spanned; + use parse; use util::testing::check_equal; + use core::option::{None, Some}; // make sure that fail! is present #[test] fn fail_exists_test () { diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index 937bcef5c25..b8781130562 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -22,6 +22,7 @@ use ast; use codemap::span; use ext::base::*; use ext::base; +use ext::build; use ext::build::*; use private::extfmt::ct::*; diff --git a/src/libsyntax/ext/log_syntax.rs b/src/libsyntax/ext/log_syntax.rs index f713e5ce7d8..15ddc44e85d 100644 --- a/src/libsyntax/ext/log_syntax.rs +++ b/src/libsyntax/ext/log_syntax.rs @@ -14,6 +14,7 @@ use ext::base::*; use ext::base; use print; +use core::io; use core::io::WriterUtil; use core::option; diff --git a/src/libsyntax/ext/pipes/ast_builder.rs b/src/libsyntax/ext/pipes/ast_builder.rs index a49d3dead0c..3e6dedb3b31 100644 --- a/src/libsyntax/ext/pipes/ast_builder.rs +++ b/src/libsyntax/ext/pipes/ast_builder.rs @@ -20,7 +20,7 @@ use ast; use ast_util::{ident_to_path}; use ast_util; use attr; -use codemap::{span, respan, dummy_sp}; +use codemap::{span, respan, dummy_sp, spanned}; use codemap; use ext::base::{ext_ctxt, mk_ctxt}; use ext::quote::rt::*; diff --git a/src/libsyntax/ext/pipes/parse_proto.rs b/src/libsyntax/ext/pipes/parse_proto.rs index 8caa2c4bba8..a6b820cf3f9 100644 --- a/src/libsyntax/ext/pipes/parse_proto.rs +++ b/src/libsyntax/ext/pipes/parse_proto.rs @@ -10,7 +10,9 @@ // Parsing pipes protocols from token trees. +use ast_util; use ext::pipes::pipec::*; +use ext::pipes::proto::*; use parse::common::SeqSep; use parse::parser; use parse::token; diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index 6c124ce16df..46f10cd52bb 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -10,8 +10,9 @@ // A protocol compiler for Rust. +use ast; use ast::ident; -use codemap::dummy_sp; +use codemap::{dummy_sp, spanned}; use ext::base::ext_ctxt; use ext::pipes::ast_builder::{append_types, ext_ctxt_ast_builder, path}; use ext::pipes::ast_builder::{path_global}; diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index b313d42e812..757302c78fc 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -34,10 +34,12 @@ use core::str; pub mod rt { use ast; + use codemap; use ext::base::ext_ctxt; use parse; use print::pprust; + use core::prelude::*; use core::str; pub use ast::*; @@ -49,7 +51,7 @@ pub mod rt { use print::pprust; use print::pprust::{item_to_str, ty_to_str}; - trait ToTokens { + pub trait ToTokens { pub fn to_tokens(&self, _cx: ext_ctxt) -> ~[token_tree]; } @@ -73,7 +75,7 @@ pub mod rt { */ - trait ToSource { + pub trait ToSource { // Takes a thing and generates a string containing rust code for it. pub fn to_source(&self, cx: ext_ctxt) -> ~str; } @@ -164,7 +166,7 @@ pub mod rt { } } - trait ExtParseUtils { + pub trait ExtParseUtils { fn parse_item(s: ~str) -> @ast::item; fn parse_expr(s: ~str) -> @ast::expr; fn parse_stmt(s: ~str) -> @ast::stmt; diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index 808a80e6ad0..5b870f07b60 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -8,12 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use ast; use codemap; use codemap::{FileMap, Loc, Pos, ExpandedFrom, span}; use codemap::{CallInfo, NameAndSpan}; use ext::base::*; use ext::base; use ext::build::{mk_base_vec_e, mk_uint, mk_u8, mk_base_str}; +use parse; use print::pprust; use core::io; diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 890420edf6d..3fc580827e9 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -9,6 +9,7 @@ // except according to those terms. // Earley-like parser for macros. +use ast; use ast::{matcher, match_tok, match_seq, match_nonterminal, ident}; use codemap::{BytePos, mk_sp}; use codemap; @@ -23,6 +24,7 @@ use core::dvec::DVec; use core::dvec; use core::io; use core::option; +use core::option::{Option, Some, None}; use core::str; use core::uint; use core::vec; diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 8da494b95fd..f55ba3adfae 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -12,7 +12,8 @@ use core::prelude::*; use ast::*; use ast; -use codemap::span; +use codemap::{span, spanned}; +use opt_vec::OptVec; use core::option; use core::vec; diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index c0c97a0b9eb..b5c4ff3ddd7 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -15,6 +15,7 @@ use codemap::spanned; use codemap::BytePos; use parse::common::*; //resolve bug? use parse::token; +use parse::parser::Parser; use core::either::{Either, Left, Right}; diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index dc5bdeba92a..c928719c208 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -764,10 +764,14 @@ fn consume_whitespace(rdr: @mut StringReader) { #[cfg(test)] pub mod test { - use super::*; - use util::interner; + + use ast; + use codemap::{BytePos, CodeMap, span}; + use core::option::None; use diagnostic; + use parse::token; + use util::interner; use util::testing::{check_equal, check_equal_ptr}; // represents a testing reader (incl. both reader and interner) diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index a31a73f594a..057412fcd7e 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -234,6 +234,8 @@ mod test { use super::*; use std::serialize::Encodable; use std; + use core::io; + use core::option::None; use core::str; use util::testing::*; diff --git a/src/libsyntax/parse/prec.rs b/src/libsyntax/parse/prec.rs index fff222876aa..e2a89d2a28c 100644 --- a/src/libsyntax/parse/prec.rs +++ b/src/libsyntax/parse/prec.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use ast; use ast::*; use parse::token::*; use parse::token::Token; diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 5eb40626437..0f161a444bd 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -2299,11 +2299,14 @@ pub fn print_onceness(s: @ps, o: ast::Onceness) { #[cfg(test)] pub mod test { + use super::*; + use ast; use ast_util; + use codemap; + use core::cmp::Eq; + use core::option::None; use parse; - use super::*; - //use util; use util::testing::check_equal; fn string_check (given : &T, expected: &T) { diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 95a6500955d..70dec6f3343 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -16,6 +16,7 @@ use ast_util; use codemap::span; use parse; use opt_vec; +use opt_vec::OptVec; use core::option; use core::vec; -- cgit 1.4.1-3-g733a5 From 78d5091a4f09f0f7c613437e502db95b63a0c538 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Thu, 28 Feb 2013 15:20:40 -0800 Subject: core: Remove unwrap_shared_mutable_state. #4436 --- src/libcore/private.rs | 190 ++----------------------------------------------- src/libstd/arc.rs | 66 +---------------- 2 files changed, 5 insertions(+), 251 deletions(-) (limited to 'src/libstd') diff --git a/src/libcore/private.rs b/src/libcore/private.rs index e4fab18966c..5601964685e 100644 --- a/src/libcore/private.rs +++ b/src/libcore/private.rs @@ -107,20 +107,9 @@ fn compare_and_swap(address: &mut int, oldval: int, newval: int) -> bool { * Shared state & exclusive ARC ****************************************************************************/ -struct UnwrapProtoInner { - contents: Option<(comm::ChanOne<()>, comm::PortOne)>, -} - -// An unwrapper uses this protocol to communicate with the "other" task that -// drops the last refcount on an arc. Unfortunately this can't be a proper -// pipe protocol because the unwrapper has to access both stages at once. -type UnwrapProto = ~UnwrapProtoInner; - struct ArcData { mut count: libc::intptr_t, - mut unwrapper: int, // either a UnwrapProto or 0 - // FIXME(#3224) should be able to make this non-option to save memory, and - // in unwrap() use "let ~ArcData { data: result, _ } = thing" to unwrap it + // FIXME(#3224) should be able to make this non-option to save memory mut data: Option, } @@ -131,37 +120,13 @@ struct ArcDestruct { impl Drop for ArcDestruct{ fn finalize(&self) { unsafe { - if self.data.is_null() { - return; // Happens when destructing an unwrapper's handle. - } do task::unkillable { let data: ~ArcData = cast::reinterpret_cast(&self.data); let new_count = intrinsics::atomic_xsub(&mut data.count, 1) - 1; assert new_count >= 0; if new_count == 0 { - // Were we really last, or should we hand off to an - // unwrapper? It's safe to not xchg because the unwrapper - // will set the unwrap lock *before* dropping his/her - // reference. In effect, being here means we're the only - // *awake* task with the data. - if data.unwrapper != 0 { - let mut p: UnwrapProto = - cast::reinterpret_cast(&data.unwrapper); - let (message, response) = - option::swap_unwrap(&mut p.contents); - // Send 'ready' and wait for a response. - comm::send_one(message, ()); - // Unkillable wait. Message guaranteed to come. - if comm::recv_one(response) { - // Other task got the data. - cast::forget(data); - } else { - // Other task was killed. drop glue takes over. - } - } else { - // drop glue takes over. - } + // drop glue takes over. } else { cast::forget(data); } @@ -176,79 +141,6 @@ fn ArcDestruct(data: *libc::c_void) -> ArcDestruct { } } -pub unsafe fn unwrap_shared_mutable_state(rc: SharedMutableState) - -> T { - struct DeathThroes { - mut ptr: Option<~ArcData>, - mut response: Option>, - } - - impl Drop for DeathThroes{ - fn finalize(&self) { - unsafe { - let response = option::swap_unwrap(&mut self.response); - // In case we get killed early, we need to tell the person who - // tried to wake us whether they should hand-off the data to - // us. - if task::failing() { - comm::send_one(response, false); - // Either this swap_unwrap or the one below (at "Got - // here") ought to run. - cast::forget(option::swap_unwrap(&mut self.ptr)); - } else { - assert self.ptr.is_none(); - comm::send_one(response, true); - } - } - } - } - - do task::unkillable { - let ptr: ~ArcData = cast::reinterpret_cast(&rc.data); - let (p1,c1) = comm::oneshot(); // () - let (p2,c2) = comm::oneshot(); // bool - let mut server: UnwrapProto = ~UnwrapProtoInner { - contents: Some((c1,p2)) - }; - let serverp: int = cast::transmute(server); - // Try to put our server end in the unwrapper slot. - if compare_and_swap(&mut ptr.unwrapper, 0, serverp) { - // Got in. Step 0: Tell destructor not to run. We are now it. - rc.data = ptr::null(); - // Step 1 - drop our own reference. - let new_count = intrinsics::atomic_xsub(&mut ptr.count, 1) - 1; - //assert new_count >= 0; - if new_count == 0 { - // We were the last owner. Can unwrap immediately. - // Also we have to free the server endpoints. - let _server: UnwrapProto = cast::transmute(serverp); - option::swap_unwrap(&mut ptr.data) - // drop glue takes over. - } else { - // The *next* person who sees the refcount hit 0 will wake us. - let end_result = - DeathThroes { ptr: Some(ptr), - response: Some(c2) }; - let mut p1 = Some(p1); // argh - do task::rekillable { - comm::recv_one(option::swap_unwrap(&mut p1)); - } - // Got here. Back in the 'unkillable' without getting killed. - // Recover ownership of ptr, then take the data out. - let ptr = option::swap_unwrap(&mut end_result.ptr); - option::swap_unwrap(&mut ptr.data) - // drop glue takes over. - } - } else { - // Somebody else was trying to unwrap. Avoid guaranteed deadlock. - cast::forget(ptr); - // Also we have to free the (rejected) server endpoints. - let _server: UnwrapProto = cast::transmute(serverp); - fail!(~"Another task is already unwrapping this ARC!"); - } - } -} - /** * COMPLETELY UNSAFE. Used as a primitive for the safe versions in std::arc. * @@ -259,7 +151,7 @@ pub type SharedMutableState = ArcDestruct; pub unsafe fn shared_mutable_state(data: T) -> SharedMutableState { - let data = ~ArcData { count: 1, unwrapper: 0, data: Some(data) }; + let data = ~ArcData { count: 1, data: Some(data) }; unsafe { let ptr = cast::transmute(data); ArcDestruct(ptr) @@ -413,14 +305,6 @@ impl Exclusive { } } -// FIXME(#3724) make this a by-move method on the exclusive -pub fn unwrap_exclusive(arc: Exclusive) -> T { - let Exclusive { x: x } = arc; - let inner = unsafe { unwrap_shared_mutable_state(x) }; - let ExData { data: data, _ } = inner; - data -} - #[cfg(test)] pub mod tests { use core::option::{None, Some}; @@ -428,7 +312,7 @@ pub mod tests { use cell::Cell; use comm; use option; - use private::{exclusive, unwrap_exclusive}; + use private::exclusive; use result; use task; use uint; @@ -479,70 +363,4 @@ pub mod tests { assert *one == 1; } } - - #[test] - pub fn exclusive_unwrap_basic() { - let x = exclusive(~~"hello"); - assert unwrap_exclusive(x) == ~~"hello"; - } - - #[test] - pub fn exclusive_unwrap_contended() { - let x = exclusive(~~"hello"); - let x2 = Cell(x.clone()); - do task::spawn { - let x2 = x2.take(); - do x2.with |_hello| { } - task::yield(); - } - assert unwrap_exclusive(x) == ~~"hello"; - - // Now try the same thing, but with the child task blocking. - let x = exclusive(~~"hello"); - let x2 = Cell(x.clone()); - let mut res = None; - do task::task().future_result(|+r| res = Some(r)).spawn { - let x2 = x2.take(); - assert unwrap_exclusive(x2) == ~~"hello"; - } - // Have to get rid of our reference before blocking. - { let _x = x; } // FIXME(#3161) util::ignore doesn't work here - let res = option::swap_unwrap(&mut res); - res.recv(); - } - - #[test] #[should_fail] #[ignore(cfg(windows))] - pub fn exclusive_unwrap_conflict() { - let x = exclusive(~~"hello"); - let x2 = Cell(x.clone()); - let mut res = None; - do task::task().future_result(|+r| res = Some(r)).spawn { - let x2 = x2.take(); - assert unwrap_exclusive(x2) == ~~"hello"; - } - assert unwrap_exclusive(x) == ~~"hello"; - let res = option::swap_unwrap(&mut res); - // See #4689 for why this can't be just "res.recv()". - assert res.recv() == task::Success; - } - - #[test] #[ignore(cfg(windows))] - pub fn exclusive_unwrap_deadlock() { - // This is not guaranteed to get to the deadlock before being killed, - // but it will show up sometimes, and if the deadlock were not there, - // the test would nondeterministically fail. - let result = do task::try { - // a task that has two references to the same exclusive will - // deadlock when it unwraps. nothing to be done about that. - let x = exclusive(~~"hello"); - let x2 = x.clone(); - do task::spawn { - for 10.times { task::yield(); } // try to let the unwrapper go - fail!(); // punt it awake from its deadlock - } - let _z = unwrap_exclusive(x); - do x2.with |_hello| { } - }; - assert result.is_err(); - } } diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index f258e649122..264ea9d0278 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -21,7 +21,7 @@ use core::cell::Cell; use core::pipes; use core::prelude::*; use core::private::{SharedMutableState, shared_mutable_state}; -use core::private::{clone_shared_mutable_state, unwrap_shared_mutable_state}; +use core::private::{clone_shared_mutable_state}; use core::private::{get_shared_mutable_state, get_shared_immutable_state}; use core::ptr; use core::task; @@ -104,20 +104,6 @@ pub fn clone(rc: &ARC) -> ARC { ARC { x: unsafe { clone_shared_mutable_state(&rc.x) } } } -/** - * Retrieve the data back out of the ARC. This function blocks until the - * reference given to it is the last existing one, and then unwrap the data - * instead of destroying it. - * - * If multiple tasks call unwrap, all but the first will fail. Do not call - * unwrap from a task that holds another reference to the same ARC; it is - * guaranteed to deadlock. - */ -pub fn unwrap(rc: ARC) -> T { - let ARC { x: x } = rc; - unsafe { unwrap_shared_mutable_state(x) } -} - impl Clone for ARC { fn clone(&self) -> ARC { clone(self) @@ -213,23 +199,6 @@ impl &MutexARC { } } -/** - * Retrieves the data, blocking until all other references are dropped, - * exactly as arc::unwrap. - * - * Will additionally fail if another task has failed while accessing the arc. - */ -// FIXME(#3724) make this a by-move method on the arc -pub fn unwrap_mutex_arc(arc: MutexARC) -> T { - let MutexARC { x: x } = arc; - let inner = unsafe { unwrap_shared_mutable_state(x) }; - let MutexARCInner { failed: failed, data: data, _ } = inner; - if failed { - fail!(~"Can't unwrap poisoned MutexARC - another task failed inside!") - } - data -} - // Common code for {mutex.access,rwlock.write}{,_cond}. #[inline(always)] #[doc(hidden)] @@ -411,24 +380,6 @@ impl &RWARC { } } -/** - * Retrieves the data, blocking until all other references are dropped, - * exactly as arc::unwrap. - * - * Will additionally fail if another task has failed while accessing the arc - * in write mode. - */ -// FIXME(#3724) make this a by-move method on the arc -pub fn unwrap_rw_arc(arc: RWARC) -> T { - let RWARC { x: x, _ } = arc; - let inner = unsafe { unwrap_shared_mutable_state(x) }; - let RWARCInner { failed: failed, data: data, _ } = inner; - if failed { - fail!(~"Can't unwrap poisoned RWARC - another task failed inside!") - } - data -} - // Borrowck rightly complains about immutably aliasing the rwlock in order to // lock it. This wraps the unsafety, with the justification that the 'lock' // field is never overwritten; only 'failed' and 'data'. @@ -585,21 +536,6 @@ mod tests { } } #[test] #[should_fail] #[ignore(cfg(windows))] - pub fn test_mutex_arc_unwrap_poison() { - let arc = MutexARC(1); - let arc2 = ~(&arc).clone(); - let (p, c) = comm::stream(); - do task::spawn || { - do arc2.access |one| { - c.send(()); - assert *one == 2; - } - } - let _ = p.recv(); - let one = unwrap_mutex_arc(arc); - assert one == 1; - } - #[test] #[should_fail] #[ignore(cfg(windows))] pub fn test_rw_arc_poison_wr() { let arc = ~RWARC(1); let arc2 = ~arc.clone(); -- cgit 1.4.1-3-g733a5 From 4ecb672d7f526cf2cda2d62c04106196ad57d7db Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 26 Feb 2013 21:42:00 -0500 Subject: Remove legacy object creation mode, and convert remaining uses of it --- src/libcore/io.rs | 14 +- src/libcore/rand.rs | 12 +- src/libcore/repr.rs | 4 +- src/libcore/run.rs | 2 +- src/libcore/task/local_data_priv.rs | 2 +- src/librustc/metadata/common.rs | 5 +- src/librustc/metadata/filesearch.rs | 4 +- src/librustc/middle/astencode.rs | 10 +- src/librustc/middle/trans/cabi.rs | 4 +- src/librustc/middle/trans/cabi_arm.rs | 4 +- src/librustc/middle/trans/cabi_x86_64.rs | 2 +- src/librustc/middle/trans/meth.rs | 25 +-- src/librustc/middle/ty.rs | 2 - src/librustc/middle/typeck/check/vtable.rs | 230 +++++++++------------ src/librustc/middle/typeck/rscope.rs | 6 +- src/libstd/sha1.rs | 4 +- src/libsyntax/ext/auto_encode.rs | 8 +- src/libsyntax/fold.rs | 221 ++++++++++---------- src/libsyntax/parse/mod.rs | 2 +- src/test/auxiliary/issue-2380.rs | 2 +- src/test/bench/shootout-mandelbrot.rs | 2 +- src/test/compile-fail/class-cast-to-trait.rs | 2 +- .../compile-fail/kindck-owned-trait-contains.rs | 2 +- src/test/compile-fail/kindck-owned-trait-scoped.rs | 6 +- src/test/compile-fail/kindck-owned-trait.rs | 4 +- src/test/compile-fail/map-types.rs | 4 +- src/test/compile-fail/regions-trait-1.rs | 2 +- src/test/compile-fail/regions-trait-2.rs | 2 +- src/test/compile-fail/regions-trait-3.rs | 2 +- src/test/compile-fail/selftype-astparam.rs | 4 +- src/test/compile-fail/tps-invariant-trait.rs | 2 +- src/test/compile-fail/trait-cast.rs | 2 +- src/test/compile-fail/trait-test-2.rs | 2 +- src/test/run-fail/unwind-box-trait.rs | 2 +- .../autoderef-method-on-trait-monomorphized.rs | 2 +- src/test/run-pass/autoderef-method-on-trait.rs | 2 +- src/test/run-pass/boxed-trait-with-vstore.rs | 2 +- .../run-pass/class-cast-to-trait-cross-crate-2.rs | 2 +- .../run-pass/class-cast-to-trait-multiple-types.rs | 4 +- src/test/run-pass/class-cast-to-trait.rs | 2 +- src/test/run-pass/class-separate-impl.rs | 2 +- src/test/run-pass/explicit-self-objects-ext-1.rs | 2 +- src/test/run-pass/explicit-self-objects-ext-2.rs | 2 +- src/test/run-pass/explicit-self-objects-ext-3.rs | 2 +- src/test/run-pass/explicit-self-objects-ext-4.rs | 2 +- src/test/run-pass/issue-2288.rs | 2 +- src/test/run-pass/issue-2734.rs | 2 +- src/test/run-pass/issue-2735.rs | 6 +- src/test/run-pass/issue-2904.rs | 2 +- src/test/run-pass/issue-2935.rs | 2 +- src/test/run-pass/issue-3305.rs | 2 +- src/test/run-pass/kindck-owned-trait-contains-1.rs | 2 +- src/test/run-pass/reflect-visit-data.rs | 4 +- src/test/run-pass/regions-trait.rs | 2 +- 54 files changed, 295 insertions(+), 354 deletions(-) (limited to 'src/libstd') diff --git a/src/libcore/io.rs b/src/libcore/io.rs index 45d89b29a2e..fdb622f6539 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -504,7 +504,7 @@ pub fn FILE_reader(f: *libc::FILE, cleanup: bool) -> @Reader { pub fn stdin() -> @Reader { unsafe { - rustrt::rust_get_stdin() as @Reader + @rustrt::rust_get_stdin() as @Reader } } @@ -642,11 +642,11 @@ impl Writer for *libc::FILE { } } -pub fn FILE_writer(f: *libc::FILE, cleanup: bool) -> Writer { +pub fn FILE_writer(f: *libc::FILE, cleanup: bool) -> @Writer { if cleanup { - Wrapper { base: f, cleanup: FILERes(f) } as Writer + @Wrapper { base: f, cleanup: FILERes(f) } as @Writer } else { - f as Writer + @f as @Writer } } @@ -702,11 +702,11 @@ pub fn FdRes(fd: fd_t) -> FdRes { } } -pub fn fd_writer(fd: fd_t, cleanup: bool) -> Writer { +pub fn fd_writer(fd: fd_t, cleanup: bool) -> @Writer { if cleanup { - Wrapper { base: fd, cleanup: FdRes(fd) } as Writer + @Wrapper { base: fd, cleanup: FdRes(fd) } as @Writer } else { - fd as Writer + @fd as @Writer } } diff --git a/src/libcore/rand.rs b/src/libcore/rand.rs index 04a551740a8..d9c2b91fb97 100644 --- a/src/libcore/rand.rs +++ b/src/libcore/rand.rs @@ -412,8 +412,8 @@ pub fn Rng() -> Rng { * all other generators constructed with the same seed. The seed may be any * length. */ -pub fn seeded_rng(seed: &[u8]) -> Rng { - seeded_randres(seed) as Rng +pub fn seeded_rng(seed: &[u8]) -> @Rng { + @seeded_randres(seed) as @Rng } fn seeded_randres(seed: &[u8]) -> @RandRes { @@ -449,8 +449,8 @@ pub pure fn xorshift() -> Rng { seeded_xorshift(123456789u32, 362436069u32, 521288629u32, 88675123u32) } -pub pure fn seeded_xorshift(x: u32, y: u32, z: u32, w: u32) -> Rng { - XorShiftState { x: x, y: y, z: z, w: w } as Rng +pub pure fn seeded_xorshift(x: u32, y: u32, z: u32, w: u32) -> @Rng { + @XorShiftState { x: x, y: y, z: z, w: w } as @Rng } @@ -472,10 +472,10 @@ pub fn task_rng() -> Rng { unsafe { let rng = seeded_randres(seed()); task::local_data::local_data_set(tls_rng_state, rng); - rng as Rng + @rng as @Rng } } - Some(rng) => rng as Rng + Some(rng) => @rng as @Rng } } diff --git a/src/libcore/repr.rs b/src/libcore/repr.rs index ab4bdec266c..af135339b2e 100644 --- a/src/libcore/repr.rs +++ b/src/libcore/repr.rs @@ -201,7 +201,7 @@ pub impl ReprVisitor { unsafe { let mut u = ReprVisitor(ptr, self.writer); let v = reflect::MovePtrAdaptor(u); - visit_tydesc(inner, (v) as @TyVisitor); + visit_tydesc(inner, @v as @TyVisitor); true } } @@ -570,7 +570,7 @@ pub fn write_repr(writer: @Writer, object: &T) { let tydesc = intrinsic::get_tydesc::(); let mut u = ReprVisitor(ptr, writer); let v = reflect::MovePtrAdaptor(u); - visit_tydesc(tydesc, (v) as @TyVisitor) + visit_tydesc(tydesc, @v as @TyVisitor) } } diff --git a/src/libcore/run.rs b/src/libcore/run.rs index aa1e473e3bf..e8cd9caaef6 100644 --- a/src/libcore/run.rs +++ b/src/libcore/run.rs @@ -288,7 +288,7 @@ pub fn start_program(prog: &str, args: &[~str]) -> Program { finished: false, }; - ProgRes(repr) as Program + @ProgRes(repr) as @Program } fn read_all(rd: io::Reader) -> ~str { diff --git a/src/libcore/task/local_data_priv.rs b/src/libcore/task/local_data_priv.rs index 3ac457b23d1..df5a5af74ca 100644 --- a/src/libcore/task/local_data_priv.rs +++ b/src/libcore/task/local_data_priv.rs @@ -155,7 +155,7 @@ pub unsafe fn local_set( // does not have a reference associated with it, so it may become invalid // when the box is destroyed. let data_ptr = cast::reinterpret_cast(&data); - let data_box = data as LocalData; + let data_box = @data as @LocalData; // Construct new entry to store in the map. let new_entry = Some((keyval, data_ptr, data_box)); // Find a place to put it. diff --git a/src/librustc/metadata/common.rs b/src/librustc/metadata/common.rs index 90d8dcdc235..daf369f7279 100644 --- a/src/librustc/metadata/common.rs +++ b/src/librustc/metadata/common.rs @@ -132,9 +132,8 @@ pub enum astencode_tag { // Reserves 0x50 -- 0x6f tag_table_method_map = 0x60, tag_table_vtable_map = 0x61, tag_table_adjustments = 0x62, - tag_table_legacy_boxed_trait = 0x63, - tag_table_moves_map = 0x64, - tag_table_capture_map = 0x65 + tag_table_moves_map = 0x63, + tag_table_capture_map = 0x64 } pub const tag_item_trait_method_sort: uint = 0x70; diff --git a/src/librustc/metadata/filesearch.rs b/src/librustc/metadata/filesearch.rs index 82ea0b6d6f1..1a7c7b0793a 100644 --- a/src/librustc/metadata/filesearch.rs +++ b/src/librustc/metadata/filesearch.rs @@ -71,11 +71,11 @@ pub fn mk_filesearch(maybe_sysroot: Option, let sysroot = get_sysroot(maybe_sysroot); debug!("using sysroot = %s", sysroot.to_str()); - FileSearchImpl { + @FileSearchImpl { sysroot: sysroot, addl_lib_search_paths: addl_lib_search_paths, target_triple: str::from_slice(target_triple) - } as FileSearch + } as @FileSearch } pub fn search(filesearch: FileSearch, pick: pick) -> Option { diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index d6af3873999..47e0b3d26ab 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -966,12 +966,6 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext, } } - do option::iter(&tcx.legacy_boxed_traits.find(&id)) |_x| { - do ebml_w.tag(c::tag_table_legacy_boxed_trait) { - ebml_w.id(id); - } - } - for maps.moves_map.find(&id).each |_| { do ebml_w.tag(c::tag_table_moves_map) { ebml_w.id(id); @@ -1121,8 +1115,6 @@ fn decode_side_tables(xcx: @ExtendedDecodeContext, if tag == (c::tag_table_mutbl as uint) { dcx.maps.mutbl_map.insert(id, ()); - } else if tag == (c::tag_table_legacy_boxed_trait as uint) { - dcx.tcx.legacy_boxed_traits.insert(id, ()); } else if tag == (c::tag_table_moves_map as uint) { dcx.maps.moves_map.insert(id, ()); } else { @@ -1230,7 +1222,7 @@ impl fake_ext_ctxt for fake_session { #[cfg(test)] fn mk_ctxt() -> fake_ext_ctxt { - parse::new_parse_sess(None) as fake_ext_ctxt + @parse::new_parse_sess(None) as fake_ext_ctxt } #[cfg(test)] diff --git a/src/librustc/middle/trans/cabi.rs b/src/librustc/middle/trans/cabi.rs index 269fe344fea..bbc19cf86ea 100644 --- a/src/librustc/middle/trans/cabi.rs +++ b/src/librustc/middle/trans/cabi.rs @@ -209,8 +209,8 @@ impl ABIInfo for LLVM_ABIInfo { } } -pub fn llvm_abi_info() -> ABIInfo { - return LLVM_ABIInfo as ABIInfo; +pub fn llvm_abi_info() -> @ABIInfo { + return @LLVM_ABIInfo as @ABIInfo; } diff --git a/src/librustc/middle/trans/cabi_arm.rs b/src/librustc/middle/trans/cabi_arm.rs index 259392bef40..a16b3672b7a 100644 --- a/src/librustc/middle/trans/cabi_arm.rs +++ b/src/librustc/middle/trans/cabi_arm.rs @@ -159,6 +159,6 @@ impl ABIInfo for ARM_ABIInfo { } } -pub fn abi_info() -> ABIInfo { - return ARM_ABIInfo as ABIInfo; +pub fn abi_info() -> @ABIInfo { + return @ARM_ABIInfo as @ABIInfo; } diff --git a/src/librustc/middle/trans/cabi_x86_64.rs b/src/librustc/middle/trans/cabi_x86_64.rs index 1dc70596994..562009dc2ca 100644 --- a/src/librustc/middle/trans/cabi_x86_64.rs +++ b/src/librustc/middle/trans/cabi_x86_64.rs @@ -408,5 +408,5 @@ impl ABIInfo for X86_64_ABIInfo { } pub fn x86_64_abi_info() -> ABIInfo { - return X86_64_ABIInfo as ABIInfo; + return @X86_64_ABIInfo as @ABIInfo; } diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs index 5e7d13c3ad3..be1a3b90b4c 100644 --- a/src/librustc/middle/trans/meth.rs +++ b/src/librustc/middle/trans/meth.rs @@ -870,26 +870,11 @@ pub fn trans_trait_cast(bcx: block, match vstore { ty::vstore_slice(*) | ty::vstore_box => { let mut llboxdest = GEPi(bcx, lldest, [0u, 1u]); - if bcx.tcx().legacy_boxed_traits.contains_key(&id) { - // Allocate an @ box and store the value into it - let MallocResult {bcx: new_bcx, box: llbox, body: body} = - malloc_boxed(bcx, v_ty); - bcx = new_bcx; - add_clean_free(bcx, llbox, heap_managed); - bcx = expr::trans_into(bcx, val, SaveIn(body)); - revoke_clean(bcx, llbox); - - // Store the @ box into the pair - Store(bcx, llbox, PointerCast(bcx, - llboxdest, - T_ptr(val_ty(llbox)))); - } else { - // Just store the pointer into the pair. - llboxdest = PointerCast(bcx, - llboxdest, - T_ptr(type_of(bcx.ccx(), v_ty))); - bcx = expr::trans_into(bcx, val, SaveIn(llboxdest)); - } + // Just store the pointer into the pair. + llboxdest = PointerCast(bcx, + llboxdest, + T_ptr(type_of(bcx.ccx(), v_ty))); + bcx = expr::trans_into(bcx, val, SaveIn(llboxdest)); } ty::vstore_uniq => { // Translate the uniquely-owned value into the second element of diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 7105017cd88..8bca7f42b48 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -269,7 +269,6 @@ struct ctxt_ { adjustments: HashMap, normalized_cache: HashMap, lang_items: middle::lang_items::LanguageItems, - legacy_boxed_traits: HashMap, // A mapping from an implementation ID to the method info and trait // method ID of the provided (a.k.a. default) methods in the traits that // that implementation implements. @@ -831,7 +830,6 @@ pub fn mk_ctxt(s: session::Session, adjustments: HashMap(), normalized_cache: new_ty_hash(), lang_items: lang_items, - legacy_boxed_traits: HashMap(), provided_methods: HashMap(), provided_method_sources: HashMap(), supertraits: HashMap(), diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs index e6b837fa949..5ed247eb447 100644 --- a/src/librustc/middle/typeck/check/vtable.rs +++ b/src/librustc/middle/typeck/check/vtable.rs @@ -97,8 +97,8 @@ pub fn lookup_vtables(vcx: &VtableContext, let mut result = ~[], i = 0u; for substs.tps.each |ty| { for ty::iter_bound_traits_and_supertraits( - tcx, bounds[i]) |trait_ty| { - + tcx, bounds[i]) |trait_ty| + { debug!("about to subst: %?, %?", ppaux::ty_to_str(tcx, trait_ty), ty::substs_to_str(tcx, substs)); @@ -585,138 +585,102 @@ pub fn early_resolve_expr(ex: @ast::expr, } } ast::expr_cast(src, _) => { - let target_ty = fcx.expr_ty(ex); - match ty::get(target_ty).sty { - ty::ty_trait(_, _, vstore) => { - // Look up vtables for the type we're casting to, passing in the - // source and target type. - // - // XXX: This is invariant and shouldn't be. --pcw - - let ty = fcx.expr_ty(src); - let vcx = VtableContext { ccx: fcx.ccx, infcx: fcx.infcx() }; - let vtable_opt = - lookup_vtable(&vcx, - &location_info_for_expr(ex), - ty, - target_ty, - true, - is_early); - match vtable_opt { - None => { - // Try the new-style boxed trait; "@int as @Trait". - // Or the new-style region trait; "&int as &Trait". - // Or the new-style uniquely-owned trait; "~int as - // ~Trait". - let mut err = false; - let ty = structurally_resolved_type(fcx, ex.span, ty); - match ty::get(ty).sty { - ty::ty_box(mt) | ty::ty_rptr(_, mt) | - ty::ty_uniq(mt) => { - // Ensure that the trait vstore and the pointer - // type match. - match (&ty::get(ty).sty, vstore) { - (&ty::ty_box(_), ty::vstore_box) | - (&ty::ty_uniq(_), ty::vstore_uniq) | - (&ty::ty_rptr(*), ty::vstore_slice(*)) => { - let location_info = - &location_info_for_expr(ex); - let vtable_opt = - lookup_vtable(&vcx, - location_info, - mt.ty, - target_ty, - true, - is_early); - match vtable_opt { - Some(vtable) => { - // Map this expression to that - // vtable (that is: "ex has vtable - // ") - if !is_early { - let vtable_map = - cx.vtable_map; - vtable_map.insert(ex.id, - @~[vtable]); - } - } - None => err = true - } - - // Now, if this is &trait, we need to link - // the regions. - match (&ty::get(ty).sty, vstore) { - (&ty::ty_rptr(ra, _), - ty::vstore_slice(rb)) => { - infer::mk_subr(fcx.infcx(), - false, - ex.span, - rb, - ra); - } - _ => {} - } - } - (&ty::ty_box(_), _) => { - fcx.ccx.tcx.sess.span_err(ex.span, - ~"must cast \ - a boxed \ - pointer to \ - a boxed - trait"); - err = true; - } - (&ty::ty_rptr(*), _) => { - fcx.ccx.tcx.sess.span_err(ex.span, - ~"must cast \ - a borrowed \ - pointer to \ - a borrowed \ - trait"); - } - (&ty::ty_uniq(*), _) => { - fcx.ccx.tcx.sess.span_err(ex.span, - ~"must cast \ - a unique \ - pointer to \ - a uniquely-\ - owned trait"); - } - _ => { - fcx.ccx.tcx.sess.impossible_case( - ex.span, - ~"impossible combination of type and \ - trait vstore"); - } - } - } - _ => err = true - } - - if err { - fcx.tcx().sess.span_fatal( - ex.span, - fmt!("failed to find an implementation of trait \ - %s for %s", - fcx.infcx().ty_to_str(target_ty), - fcx.infcx().ty_to_str(ty))); - } - } - Some(vtable) => { - /* - Map this expression to that vtable (that is: "ex has - vtable ") - */ - if !is_early { - let vtable_map = cx.vtable_map; - vtable_map.insert(ex.id, @~[vtable]); - } - fcx.tcx().legacy_boxed_traits.insert(ex.id, ()); - } - } + let target_ty = fcx.expr_ty(ex); + match ty::get(target_ty).sty { + ty::ty_trait(_, _, vstore) => { + // Look up vtables for the type we're casting to, + // passing in the source and target type. The source + // must be a pointer type suitable to the object sigil, + // e.g.: `@x as @Trait`, `&x as &Trait` or `~x as ~Trait` + let ty = structurally_resolved_type(fcx, ex.span, + fcx.expr_ty(src)); + match (&ty::get(ty).sty, vstore) { + (&ty::ty_box(mt), ty::vstore_box) | + (&ty::ty_uniq(mt), ty::vstore_uniq) | + (&ty::ty_rptr(_, mt), ty::vstore_slice(*)) => { + let location_info = + &location_info_for_expr(ex); + let vcx = VtableContext { + ccx: fcx.ccx, + infcx: fcx.infcx() + }; + let vtable_opt = + lookup_vtable(&vcx, + location_info, + mt.ty, + target_ty, + true, + is_early); + match vtable_opt { + Some(vtable) => { + // Map this expression to that + // vtable (that is: "ex has vtable + // ") + if !is_early { + let vtable_map = + cx.vtable_map; + vtable_map.insert(ex.id, + @~[vtable]); + } + } + None => { + fcx.tcx().sess.span_err( + ex.span, + fmt!("failed to find an implementation \ + of trait %s for %s", + fcx.infcx().ty_to_str(target_ty), + fcx.infcx().ty_to_str(mt.ty))); + } + } + + // Now, if this is &trait, we need to link the + // regions. + match (&ty::get(ty).sty, vstore) { + (&ty::ty_rptr(ra, _), + ty::vstore_slice(rb)) => { + infer::mk_subr(fcx.infcx(), + false, + ex.span, + rb, + ra); + } + _ => {} + } + } + + (_, ty::vstore_box(*)) => { + fcx.ccx.tcx.sess.span_err( + ex.span, + fmt!("can only cast an @-pointer \ + to an @-object, not a %s", + ty::ty_sort_str(fcx.tcx(), ty))); + } + + (_, ty::vstore_uniq(*)) => { + fcx.ccx.tcx.sess.span_err( + ex.span, + fmt!("can only cast an ~-pointer \ + to a ~-object, not a %s", + ty::ty_sort_str(fcx.tcx(), ty))); + } + + (_, ty::vstore_slice(*)) => { + fcx.ccx.tcx.sess.span_err( + ex.span, + fmt!("can only cast an &-pointer \ + to an &-object, not a %s", + ty::ty_sort_str(fcx.tcx(), ty))); + } + + (_, ty::vstore_fixed(*)) => { + fcx.tcx().sess.span_bug( + ex.span, + fmt!("trait with fixed vstore")); + } + } + } + _ => { /* not a cast to a trait; ignore */ } } - _ => () - } } _ => () } diff --git a/src/librustc/middle/typeck/rscope.rs b/src/librustc/middle/typeck/rscope.rs index 628cccfa9a2..d82667285ff 100644 --- a/src/librustc/middle/typeck/rscope.rs +++ b/src/librustc/middle/typeck/rscope.rs @@ -70,11 +70,11 @@ pub fn bound_self_region(rp: Option) } } -pub struct anon_rscope { anon: ty::Region, base: region_scope } +pub struct anon_rscope { anon: ty::Region, base: @region_scope } pub fn in_anon_rscope(self: RS, r: ty::Region) -> @anon_rscope { - @anon_rscope {anon: r, base: self as region_scope} + @anon_rscope {anon: r, base: @self as @region_scope} } impl region_scope for @anon_rscope { @@ -97,7 +97,7 @@ pub struct binding_rscope { pub fn in_binding_rscope(self: RS) -> @mut binding_rscope { - let base = self as region_scope; + let base = @self as @region_scope; @mut binding_rscope { base: base, anon_bindings: 0 } } diff --git a/src/libstd/sha1.rs b/src/libstd/sha1.rs index 69c3de5ff62..e8c1413e90a 100644 --- a/src/libstd/sha1.rs +++ b/src/libstd/sha1.rs @@ -63,7 +63,7 @@ const k3: u32 = 0xCA62C1D6u32; /// Construct a `sha` object -pub fn sha1() -> Sha1 { +pub fn sha1() -> @Sha1 { struct Sha1State { h: ~[u32], len_low: u32, @@ -269,7 +269,7 @@ pub fn sha1() -> Sha1 { computed: false, work_buf: @mut vec::from_elem(work_buf_len, 0u32) }; - let mut sh = (st) as Sha1; + let mut sh = @st as @Sha1; sh.reset(); return sh; } diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs index 43eaef95ee2..5f076136271 100644 --- a/src/libsyntax/ext/auto_encode.rs +++ b/src/libsyntax/ext/auto_encode.rs @@ -1296,7 +1296,7 @@ mod test { } - fn to_call_log (val: Encodable) -> ~[call] { + fn to_call_log>(val: E) -> ~[call] { let mut te = TestEncoder {call_log: @mut ~[]}; val.encode(&te); copy *te.call_log @@ -1309,8 +1309,7 @@ mod test { } #[test] fn encode_enum_test () { - check_equal (to_call_log(Book(34,44) - as Encodable::), + check_equal (to_call_log(Book(34,44)), ~[CallToEmitEnum (~"Written"), CallToEmitEnumVariant (~"Book",0,2), CallToEmitEnumVariantArg (0), @@ -1325,8 +1324,7 @@ mod test { pub struct HasPos { pos : BPos } #[test] fn encode_newtype_test () { - check_equal (to_call_log (HasPos {pos:BPos(48)} - as Encodable::), + check_equal (to_call_log (HasPos {pos:BPos(48)}), ~[CallToEmitStruct(~"HasPos",1), CallToEmitField(~"pos",0), CallToEmitUint(48)]); diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index f55ba3adfae..eb9dd0ec03c 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -19,29 +19,29 @@ use core::option; use core::vec; pub trait ast_fold { - fn fold_crate(crate) -> crate; - fn fold_view_item(&&v: @view_item) -> @view_item; - fn fold_foreign_item(&&v: @foreign_item) -> @foreign_item; - fn fold_item(&&v: @item) -> Option<@item>; - fn fold_struct_field(&&v: @struct_field) -> @struct_field; - fn fold_item_underscore(item_) -> item_; - fn fold_method(&&v: @method) -> @method; - fn fold_block(blk) -> blk; - fn fold_stmt(&&v: @stmt) -> @stmt; - fn fold_arm(arm) -> arm; - fn fold_pat(&&v: @pat) -> @pat; - fn fold_decl(&&v: @decl) -> @decl; - fn fold_expr(&&v: @expr) -> @expr; - fn fold_ty(&&v: @Ty) -> @Ty; - fn fold_mod(_mod) -> _mod; - fn fold_foreign_mod(foreign_mod) -> foreign_mod; - fn fold_variant(variant) -> variant; - fn fold_ident(&&v: ident) -> ident; - fn fold_path(&&v: @path) -> @path; - fn fold_local(&&v: @local) -> @local; - fn map_exprs(fn@(&&v: @expr) -> @expr, ~[@expr]) -> ~[@expr]; - fn new_id(node_id) -> node_id; - fn new_span(span) -> span; + fn fold_crate(@self, crate) -> crate; + fn fold_view_item(@self, &&v: @view_item) -> @view_item; + fn fold_foreign_item(@self, &&v: @foreign_item) -> @foreign_item; + fn fold_item(@self, &&v: @item) -> Option<@item>; + fn fold_struct_field(@self, &&v: @struct_field) -> @struct_field; + fn fold_item_underscore(@self, item_) -> item_; + fn fold_method(@self, &&v: @method) -> @method; + fn fold_block(@self, blk) -> blk; + fn fold_stmt(@self, &&v: @stmt) -> @stmt; + fn fold_arm(@self, arm) -> arm; + fn fold_pat(@self, &&v: @pat) -> @pat; + fn fold_decl(@self, &&v: @decl) -> @decl; + fn fold_expr(@self, &&v: @expr) -> @expr; + fn fold_ty(@self, &&v: @Ty) -> @Ty; + fn fold_mod(@self, _mod) -> _mod; + fn fold_foreign_mod(@self, foreign_mod) -> foreign_mod; + fn fold_variant(@self, variant) -> variant; + fn fold_ident(@self, &&v: ident) -> ident; + fn fold_path(@self, &&v: @path) -> @path; + fn fold_local(@self, &&v: @local) -> @local; + fn map_exprs(@self, fn@(&&v: @expr) -> @expr, ~[@expr]) -> ~[@expr]; + fn new_id(@self, node_id) -> node_id; + fn new_span(@self, span) -> span; } // We may eventually want to be able to fold over type parameters, too @@ -78,7 +78,7 @@ pub type ast_fold_fns = @AstFoldFns; /* some little folds that probably aren't useful to have in ast_fold itself*/ //used in noop_fold_item and noop_fold_crate and noop_fold_crate_directive -fn fold_meta_item_(&&mi: @meta_item, fld: ast_fold) -> @meta_item { +fn fold_meta_item_(&&mi: @meta_item, fld: @ast_fold) -> @meta_item { @spanned { node: match mi.node { @@ -95,7 +95,7 @@ fn fold_meta_item_(&&mi: @meta_item, fld: ast_fold) -> @meta_item { span: fld.new_span(mi.span) } } //used in noop_fold_item and noop_fold_crate -fn fold_attribute_(at: attribute, fld: ast_fold) -> attribute { +fn fold_attribute_(at: attribute, fld: @ast_fold) -> attribute { spanned { node: ast::attribute_ { style: at.node.style, @@ -106,7 +106,7 @@ fn fold_attribute_(at: attribute, fld: ast_fold) -> attribute { } } //used in noop_fold_foreign_item and noop_fold_fn_decl -fn fold_arg_(a: arg, fld: ast_fold) -> arg { +fn fold_arg_(a: arg, fld: @ast_fold) -> arg { ast::arg { mode: a.mode, is_mutbl: a.is_mutbl, @@ -116,14 +116,14 @@ fn fold_arg_(a: arg, fld: ast_fold) -> arg { } } //used in noop_fold_expr, and possibly elsewhere in the future -fn fold_mac_(m: mac, fld: ast_fold) -> mac { +fn fold_mac_(m: mac, fld: @ast_fold) -> mac { spanned { node: match m.node { mac_invoc_tt(*) => m.node, }, span: fld.new_span(m.span) } } -pub fn fold_fn_decl(decl: ast::fn_decl, fld: ast_fold) -> ast::fn_decl { +pub fn fold_fn_decl(decl: ast::fn_decl, fld: @ast_fold) -> ast::fn_decl { ast::fn_decl { inputs: decl.inputs.map(|x| fold_arg_(*x, fld)), output: fld.fold_ty(decl.output), @@ -131,41 +131,44 @@ pub fn fold_fn_decl(decl: ast::fn_decl, fld: ast_fold) -> ast::fn_decl { } } -fn fold_ty_param_bound(tpb: TyParamBound, fld: ast_fold) -> TyParamBound { +fn fold_ty_param_bound(tpb: TyParamBound, + fld: @ast_fold) -> TyParamBound { match tpb { TraitTyParamBound(ty) => TraitTyParamBound(fld.fold_ty(ty)), RegionTyParamBound => RegionTyParamBound } } -pub fn fold_ty_param(tp: TyParam, fld: ast_fold) -> TyParam { +pub fn fold_ty_param(tp: TyParam, + fld: @ast_fold) -> TyParam { TyParam {ident: tp.ident, id: fld.new_id(tp.id), bounds: @tp.bounds.map(|x| fold_ty_param_bound(*x, fld))} } pub fn fold_ty_params(tps: &OptVec, - fld: ast_fold) -> OptVec { + fld: @ast_fold) -> OptVec { tps.map(|tp| fold_ty_param(*tp, fld)) } -pub fn fold_lifetime(l: &Lifetime, fld: ast_fold) -> Lifetime { +pub fn fold_lifetime(l: &Lifetime, + fld: @ast_fold) -> Lifetime { Lifetime {id: fld.new_id(l.id), span: fld.new_span(l.span), ident: l.ident} } pub fn fold_lifetimes(lts: &OptVec, - fld: ast_fold) -> OptVec { + fld: @ast_fold) -> OptVec { lts.map(|l| fold_lifetime(l, fld)) } -pub fn fold_generics(generics: &Generics, fld: ast_fold) -> Generics { +pub fn fold_generics(generics: &Generics, fld: @ast_fold) -> Generics { Generics {ty_params: fold_ty_params(&generics.ty_params, fld), lifetimes: fold_lifetimes(&generics.lifetimes, fld)} } -pub fn noop_fold_crate(c: crate_, fld: ast_fold) -> crate_ { +pub fn noop_fold_crate(c: crate_, fld: @ast_fold) -> crate_ { let fold_meta_item = |x| fold_meta_item_(x, fld); let fold_attribute = |x| fold_attribute_(x, fld); @@ -176,12 +179,12 @@ pub fn noop_fold_crate(c: crate_, fld: ast_fold) -> crate_ { } } -fn noop_fold_view_item(vi: view_item_, _fld: ast_fold) -> view_item_ { +fn noop_fold_view_item(vi: view_item_, _fld: @ast_fold) -> view_item_ { return /* FIXME (#2543) */ copy vi; } -fn noop_fold_foreign_item(&&ni: @foreign_item, fld: ast_fold) +fn noop_fold_foreign_item(&&ni: @foreign_item, fld: @ast_fold) -> @foreign_item { let fold_arg = |x| fold_arg_(x, fld); let fold_attribute = |x| fold_attribute_(x, fld); @@ -211,7 +214,7 @@ fn noop_fold_foreign_item(&&ni: @foreign_item, fld: ast_fold) } } -pub fn noop_fold_item(&&i: @item, fld: ast_fold) -> Option<@item> { +pub fn noop_fold_item(&&i: @item, fld: @ast_fold) -> Option<@item> { let fold_attribute = |x| fold_attribute_(x, fld); Some(@ast::item { ident: fld.fold_ident(i.ident), @@ -222,7 +225,7 @@ pub fn noop_fold_item(&&i: @item, fld: ast_fold) -> Option<@item> { span: fld.new_span(i.span) }) } -fn noop_fold_struct_field(&&sf: @struct_field, fld: ast_fold) +fn noop_fold_struct_field(&&sf: @struct_field, fld: @ast_fold) -> @struct_field { @spanned { node: ast::struct_field_ { kind: copy sf.node.kind, id: sf.node.id, @@ -230,7 +233,7 @@ fn noop_fold_struct_field(&&sf: @struct_field, fld: ast_fold) span: sf.span } } -pub fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ { +pub fn noop_fold_item_underscore(i: item_, fld: @ast_fold) -> item_ { match i { item_const(t, e) => item_const(fld.fold_ty(t), fld.fold_expr(e)), item_fn(ref decl, purity, ref typms, ref body) => { @@ -281,7 +284,7 @@ pub fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ { } } -fn fold_struct_def(struct_def: @ast::struct_def, fld: ast_fold) +fn fold_struct_def(struct_def: @ast::struct_def, fld: @ast_fold) -> @ast::struct_def { let dtor = do option::map(&struct_def.dtor) |dtor| { let dtor_body = fld.fold_block(dtor.node.body); @@ -298,21 +301,21 @@ fn fold_struct_def(struct_def: @ast::struct_def, fld: ast_fold) } } -fn fold_trait_ref(&&p: @trait_ref, fld: ast_fold) -> @trait_ref { +fn fold_trait_ref(&&p: @trait_ref, fld: @ast_fold) -> @trait_ref { @ast::trait_ref { path: fld.fold_path(p.path), ref_id: fld.new_id(p.ref_id), } } -fn fold_struct_field(&&f: @struct_field, fld: ast_fold) -> @struct_field { +fn fold_struct_field(&&f: @struct_field, fld: @ast_fold) -> @struct_field { @spanned { node: ast::struct_field_ { kind: copy f.node.kind, id: fld.new_id(f.node.id), ty: fld.fold_ty(f.node.ty) }, span: fld.new_span(f.span) } } -fn noop_fold_method(&&m: @method, fld: ast_fold) -> @method { +fn noop_fold_method(&&m: @method, fld: @ast_fold) -> @method { @ast::method { ident: fld.fold_ident(m.ident), attrs: /* FIXME (#2543) */ copy m.attrs, @@ -329,7 +332,7 @@ fn noop_fold_method(&&m: @method, fld: ast_fold) -> @method { } -pub fn noop_fold_block(b: blk_, fld: ast_fold) -> blk_ { +pub fn noop_fold_block(b: blk_, fld: @ast_fold) -> blk_ { ast::blk_ { view_items: b.view_items.map(|x| fld.fold_view_item(*x)), stmts: b.stmts.map(|x| fld.fold_stmt(*x)), @@ -339,7 +342,7 @@ pub fn noop_fold_block(b: blk_, fld: ast_fold) -> blk_ { } } -fn noop_fold_stmt(s: stmt_, fld: ast_fold) -> stmt_ { +fn noop_fold_stmt(s: stmt_, fld: @ast_fold) -> stmt_ { let fold_mac = |x| fold_mac_(x, fld); return match s { stmt_decl(d, nid) => stmt_decl(fld.fold_decl(d), fld.new_id(nid)), @@ -349,7 +352,7 @@ fn noop_fold_stmt(s: stmt_, fld: ast_fold) -> stmt_ { }; } -fn noop_fold_arm(a: arm, fld: ast_fold) -> arm { +fn noop_fold_arm(a: arm, fld: @ast_fold) -> arm { arm { pats: vec::map(a.pats, |x| fld.fold_pat(*x)), guard: option::map(&a.guard, |x| fld.fold_expr(*x)), @@ -357,7 +360,7 @@ fn noop_fold_arm(a: arm, fld: ast_fold) -> arm { } } -pub fn noop_fold_pat(p: pat_, fld: ast_fold) -> pat_ { +pub fn noop_fold_pat(p: pat_, fld: @ast_fold) -> pat_ { return match p { pat_wild => pat_wild, pat_ident(binding_mode, pth, sub) => { @@ -403,7 +406,7 @@ pub fn noop_fold_pat(p: pat_, fld: ast_fold) -> pat_ { }; } -fn noop_fold_decl(d: decl_, fld: ast_fold) -> decl_ { +fn noop_fold_decl(d: decl_, fld: @ast_fold) -> decl_ { match d { decl_local(ls) => decl_local(vec::map(ls, |x| fld.fold_local(*x))), decl_item(it) => match fld.fold_item(it) { @@ -416,13 +419,13 @@ fn noop_fold_decl(d: decl_, fld: ast_fold) -> decl_ { pub fn wrap(f: fn@(T, ast_fold) -> T) -> fn@(T, span, ast_fold) -> (T, span) { - return fn@(x: T, s: span, fld: ast_fold) -> (T, span) { + return fn@(x: T, s: span, fld: @ast_fold) -> (T, span) { (f(x, fld), s) } } -pub fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ { - fn fold_field_(field: field, fld: ast_fold) -> field { +pub fn noop_fold_expr(e: expr_, fld: @ast_fold) -> expr_ { + fn fold_field_(field: field, fld: @ast_fold) -> field { spanned { node: ast::field_ { mutbl: field.node.mutbl, @@ -533,12 +536,12 @@ pub fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ { } } -pub fn noop_fold_ty(t: ty_, fld: ast_fold) -> ty_ { +pub fn noop_fold_ty(t: ty_, fld: @ast_fold) -> ty_ { let fold_mac = |x| fold_mac_(x, fld); - fn fold_mt(mt: mt, fld: ast_fold) -> mt { + fn fold_mt(mt: mt, fld: @ast_fold) -> mt { mt { ty: fld.fold_ty(mt.ty), mutbl: mt.mutbl } } - fn fold_field(f: ty_field, fld: ast_fold) -> ty_field { + fn fold_field(f: ty_field, fld: @ast_fold) -> ty_field { spanned { node: ast::ty_field_ { ident: fld.fold_ident(f.node.ident), @@ -579,14 +582,14 @@ pub fn noop_fold_ty(t: ty_, fld: ast_fold) -> ty_ { } // ...nor do modules -pub fn noop_fold_mod(m: _mod, fld: ast_fold) -> _mod { +pub fn noop_fold_mod(m: _mod, fld: @ast_fold) -> _mod { ast::_mod { view_items: vec::map(m.view_items, |x| fld.fold_view_item(*x)), items: vec::filter_mapped(m.items, |x| fld.fold_item(*x)), } } -fn noop_fold_foreign_mod(nm: foreign_mod, fld: ast_fold) -> foreign_mod { +fn noop_fold_foreign_mod(nm: foreign_mod, fld: @ast_fold) -> foreign_mod { ast::foreign_mod { sort: nm.sort, abi: nm.abi, @@ -595,8 +598,8 @@ fn noop_fold_foreign_mod(nm: foreign_mod, fld: ast_fold) -> foreign_mod { } } -fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ { - fn fold_variant_arg_(va: variant_arg, fld: ast_fold) -> variant_arg { +fn noop_fold_variant(v: variant_, fld: @ast_fold) -> variant_ { + fn fold_variant_arg_(va: variant_arg, fld: @ast_fold) -> variant_arg { ast::variant_arg { ty: fld.fold_ty(va.ty), id: fld.new_id(va.id) } } let fold_variant_arg = |x| fold_variant_arg_(x, fld); @@ -654,11 +657,11 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ { } } -fn noop_fold_ident(&&i: ident, _fld: ast_fold) -> ident { +fn noop_fold_ident(&&i: ident, _fld: @ast_fold) -> ident { return /* FIXME (#2543) */ copy i; } -fn noop_fold_path(&&p: path, fld: ast_fold) -> path { +fn noop_fold_path(&&p: path, fld: @ast_fold) -> path { ast::path { span: fld.new_span(p.span), global: p.global, idents: p.idents.map(|x| fld.fold_ident(*x)), @@ -666,7 +669,7 @@ fn noop_fold_path(&&p: path, fld: ast_fold) -> path { types: p.types.map(|x| fld.fold_ty(*x)) } } -fn noop_fold_local(l: local_, fld: ast_fold) -> local_ { +fn noop_fold_local(l: local_, fld: @ast_fold) -> local_ { local_ { is_mutbl: l.is_mutbl, ty: fld.fold_ty(l.ty), @@ -712,72 +715,72 @@ pub fn default_ast_fold() -> ast_fold_fns { new_span: noop_span}; } -impl ast_fold for ast_fold_fns { +impl ast_fold for AstFoldFns { /* naturally, a macro to write these would be nice */ - fn fold_crate(c: crate) -> crate { - let (n, s) = (self.fold_crate)(c.node, c.span, self as ast_fold); + fn fold_crate(@self, c: crate) -> crate { + let (n, s) = (self.fold_crate)(c.node, c.span, self as @ast_fold); spanned { node: n, span: (self.new_span)(s) } } - fn fold_view_item(&&x: @view_item) -> + fn fold_view_item(@self, &&x: @view_item) -> @view_item { @ast::view_item { - node: (self.fold_view_item)(x.node, self as ast_fold), + node: (self.fold_view_item)(x.node, self as @ast_fold), attrs: vec::map(x.attrs, |a| - fold_attribute_(*a, self as ast_fold)), + fold_attribute_(*a, self as @ast_fold)), vis: x.vis, span: (self.new_span)(x.span), } } - fn fold_foreign_item(&&x: @foreign_item) + fn fold_foreign_item(@self, &&x: @foreign_item) -> @foreign_item { - return (self.fold_foreign_item)(x, self as ast_fold); + return (self.fold_foreign_item)(x, self as @ast_fold); } - fn fold_item(&&i: @item) -> Option<@item> { - return (self.fold_item)(i, self as ast_fold); + fn fold_item(@self, &&i: @item) -> Option<@item> { + return (self.fold_item)(i, self as @ast_fold); } - fn fold_struct_field(&&sf: @struct_field) -> @struct_field { + fn fold_struct_field(@self, &&sf: @struct_field) -> @struct_field { @spanned { node: ast::struct_field_ { kind: copy sf.node.kind, id: sf.node.id, - ty: (self as ast_fold).fold_ty(sf.node.ty), + ty: (self as @ast_fold).fold_ty(sf.node.ty), }, span: (self.new_span)(sf.span), } } - fn fold_item_underscore(i: item_) -> + fn fold_item_underscore(@self, i: item_) -> item_ { - return (self.fold_item_underscore)(i, self as ast_fold); + return (self.fold_item_underscore)(i, self as @ast_fold); } - fn fold_method(&&x: @method) + fn fold_method(@self, &&x: @method) -> @method { - return (self.fold_method)(x, self as ast_fold); + return (self.fold_method)(x, self as @ast_fold); } - fn fold_block(x: blk) -> blk { - let (n, s) = (self.fold_block)(x.node, x.span, self as ast_fold); + fn fold_block(@self, x: blk) -> blk { + let (n, s) = (self.fold_block)(x.node, x.span, self as @ast_fold); spanned { node: n, span: (self.new_span)(s) } } - fn fold_stmt(&&x: @stmt) -> @stmt { - let (n, s) = (self.fold_stmt)(x.node, x.span, self as ast_fold); + fn fold_stmt(@self, &&x: @stmt) -> @stmt { + let (n, s) = (self.fold_stmt)(x.node, x.span, self as @ast_fold); @spanned { node: n, span: (self.new_span)(s) } } - fn fold_arm(x: arm) -> arm { - return (self.fold_arm)(x, self as ast_fold); + fn fold_arm(@self, x: arm) -> arm { + return (self.fold_arm)(x, self as @ast_fold); } - fn fold_pat(&&x: @pat) -> @pat { - let (n, s) = (self.fold_pat)(x.node, x.span, self as ast_fold); + fn fold_pat(@self, &&x: @pat) -> @pat { + let (n, s) = (self.fold_pat)(x.node, x.span, self as @ast_fold); @pat { id: (self.new_id)(x.id), node: n, span: (self.new_span)(s), } } - fn fold_decl(&&x: @decl) -> @decl { - let (n, s) = (self.fold_decl)(x.node, x.span, self as ast_fold); + fn fold_decl(@self, &&x: @decl) -> @decl { + let (n, s) = (self.fold_decl)(x.node, x.span, self as @ast_fold); @spanned { node: n, span: (self.new_span)(s) } } - fn fold_expr(&&x: @expr) -> @expr { - let (n, s) = (self.fold_expr)(x.node, x.span, self as ast_fold); + fn fold_expr(@self, &&x: @expr) -> @expr { + let (n, s) = (self.fold_expr)(x.node, x.span, self as @ast_fold); @expr { id: (self.new_id)(x.id), callee_id: (self.new_id)(x.callee_id), @@ -785,43 +788,45 @@ impl ast_fold for ast_fold_fns { span: (self.new_span)(s), } } - fn fold_ty(&&x: @Ty) -> @Ty { - let (n, s) = (self.fold_ty)(x.node, x.span, self as ast_fold); + fn fold_ty(@self, &&x: @Ty) -> @Ty { + let (n, s) = (self.fold_ty)(x.node, x.span, self as @ast_fold); @Ty { id: (self.new_id)(x.id), node: n, span: (self.new_span)(s), } } - fn fold_mod(x: _mod) -> _mod { - return (self.fold_mod)(x, self as ast_fold); + fn fold_mod(@self, x: _mod) -> _mod { + return (self.fold_mod)(x, self as @ast_fold); } - fn fold_foreign_mod(x: foreign_mod) -> + fn fold_foreign_mod(@self, x: foreign_mod) -> foreign_mod { - return (self.fold_foreign_mod)(x, self as ast_fold); + return (self.fold_foreign_mod)(x, self as @ast_fold); } - fn fold_variant(x: variant) -> + fn fold_variant(@self, x: variant) -> variant { - let (n, s) = (self.fold_variant)(x.node, x.span, self as ast_fold); + let (n, s) = (self.fold_variant)(x.node, x.span, self as @ast_fold); spanned { node: n, span: (self.new_span)(s) } } - fn fold_ident(&&x: ident) -> ident { - return (self.fold_ident)(x, self as ast_fold); + fn fold_ident(@self, &&x: ident) -> ident { + return (self.fold_ident)(x, self as @ast_fold); } - fn fold_path(&&x: @path) -> @path { - @(self.fold_path)(*x, self as ast_fold) + fn fold_path(@self, &&x: @path) -> @path { + @(self.fold_path)(*x, self as @ast_fold) } - fn fold_local(&&x: @local) -> @local { - let (n, s) = (self.fold_local)(x.node, x.span, self as ast_fold); + fn fold_local(@self, &&x: @local) -> @local { + let (n, s) = (self.fold_local)(x.node, x.span, self as @ast_fold); @spanned { node: n, span: (self.new_span)(s) } } - fn map_exprs(f: fn@(&&v: @expr) -> @expr, e: ~[@expr]) -> ~[@expr] { + fn map_exprs(@self, + f: fn@(&&v: @expr) -> @expr, + e: ~[@expr]) -> ~[@expr] { (self.map_exprs)(f, e) } - fn new_id(node_id: ast::node_id) -> node_id { + fn new_id(@self, node_id: ast::node_id) -> node_id { (self.new_id)(node_id) } - fn new_span(span: span) -> span { + fn new_span(@self, span: span) -> span { (self.new_span)(span) } } @@ -833,7 +838,7 @@ pub impl ast_fold { } pub fn make_fold(afp: ast_fold_fns) -> ast_fold { - afp as ast_fold + afp as @ast_fold } // diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 057412fcd7e..923bc738cf0 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -251,7 +251,7 @@ mod test { @~"fn foo (x : int) { x; }", ~[], new_parse_sess(None)); - check_equal(to_json_str(tts as Encodable::), + check_equal(to_json_str(@tts as Encodable::), ~"[[\"tt_tok\",[,[\"IDENT\",[\"fn\",false]]]],\ [\"tt_tok\",[,[\"IDENT\",[\"foo\",false]]]],\ [\"tt_delim\",[[[\"tt_tok\",[,[\"LPAREN\",[]]]],\ diff --git a/src/test/auxiliary/issue-2380.rs b/src/test/auxiliary/issue-2380.rs index 7cc8dcb22c9..afe7d4a6e8b 100644 --- a/src/test/auxiliary/issue-2380.rs +++ b/src/test/auxiliary/issue-2380.rs @@ -16,5 +16,5 @@ pub trait i { } pub fn f() -> i { impl i for () { } - () as i:: + @() as @i } diff --git a/src/test/bench/shootout-mandelbrot.rs b/src/test/bench/shootout-mandelbrot.rs index 5e472712fda..a52b7889017 100644 --- a/src/test/bench/shootout-mandelbrot.rs +++ b/src/test/bench/shootout-mandelbrot.rs @@ -112,7 +112,7 @@ fn writer(path: ~str, pport: comm::Port, size: uint) { let cout: io::Writer = match path { ~"" => { - Devnull as io::Writer + @Devnull as @io::Writer } ~"-" => { io::stdout() diff --git a/src/test/compile-fail/class-cast-to-trait.rs b/src/test/compile-fail/class-cast-to-trait.rs index 3169b0299a0..092fb4a5b66 100644 --- a/src/test/compile-fail/class-cast-to-trait.rs +++ b/src/test/compile-fail/class-cast-to-trait.rs @@ -58,6 +58,6 @@ fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat { } fn main() { - let nyan : noisy = cat(0, 2, ~"nyan") as noisy; + let nyan : noisy = @cat(0, 2, ~"nyan") as @noisy; nyan.eat(); //~ ERROR type `@noisy` does not implement any method in scope named `eat` } diff --git a/src/test/compile-fail/kindck-owned-trait-contains.rs b/src/test/compile-fail/kindck-owned-trait-contains.rs index 2864e27f42f..f369e765d69 100644 --- a/src/test/compile-fail/kindck-owned-trait-contains.rs +++ b/src/test/compile-fail/kindck-owned-trait-contains.rs @@ -16,7 +16,7 @@ impl repeat for @A { fn repeater(v: @A) -> repeat { // Note: owned kind is not necessary as A appears in the trait type - v as repeat:: // No + @v as repeat:: // No } fn main() { diff --git a/src/test/compile-fail/kindck-owned-trait-scoped.rs b/src/test/compile-fail/kindck-owned-trait-scoped.rs index f11703ecf02..2e0f2774861 100644 --- a/src/test/compile-fail/kindck-owned-trait-scoped.rs +++ b/src/test/compile-fail/kindck-owned-trait-scoped.rs @@ -26,7 +26,7 @@ fn to_foo(t: T) { // the fn body itself. let v = &3; struct F { f: T } - let x = F {f:t} as foo; + let x = @F {f:t} as foo; assert x.foo(v) == 3; } @@ -34,14 +34,14 @@ fn to_foo_2(t: T) -> foo { // Not OK---T may contain borrowed ptrs and it is going to escape // as part of the returned foo value struct F { f: T } - F {f:t} as foo //~ ERROR value may contain borrowed pointers; use `&static` bound + @F {f:t} as foo //~ ERROR value may contain borrowed pointers; use `&static` bound } fn to_foo_3(t: T) -> foo { // OK---T may escape as part of the returned foo value, but it is // owned and hence does not contain borrowed ptrs struct F { f: T } - F {f:t} as foo + @F {f:t} as foo } fn main() { diff --git a/src/test/compile-fail/kindck-owned-trait.rs b/src/test/compile-fail/kindck-owned-trait.rs index 2bc6a911204..30f6a5f9b2d 100644 --- a/src/test/compile-fail/kindck-owned-trait.rs +++ b/src/test/compile-fail/kindck-owned-trait.rs @@ -11,11 +11,11 @@ trait foo { fn foo(); } fn to_foo(t: T) -> foo { - t as foo //~ ERROR value may contain borrowed pointers; use `&static` bound + @t as @foo //~ ERROR value may contain borrowed pointers; use `&static` bound } fn to_foo2(t: T) -> foo { - t as foo + @t as @foo } fn main() {} diff --git a/src/test/compile-fail/map-types.rs b/src/test/compile-fail/map-types.rs index f829c730637..8512e8d13dc 100644 --- a/src/test/compile-fail/map-types.rs +++ b/src/test/compile-fail/map-types.rs @@ -14,8 +14,8 @@ use core::hashmap::linear::LinearMap; // Test that trait types printed in error msgs include the type arguments. fn main() { - let x: Map<~str, ~str> = LinearMap::new::<~str, ~str>() as + let x: @Map<~str, ~str> = @LinearMap::new::<~str, ~str>() as Map::<~str, ~str>; - let y: Map = x; + let y: @Map = @x; //~^ ERROR mismatched types: expected `@core::container::Map/&` } diff --git a/src/test/compile-fail/regions-trait-1.rs b/src/test/compile-fail/regions-trait-1.rs index 4a78fdf9714..811d7c452e3 100644 --- a/src/test/compile-fail/regions-trait-1.rs +++ b/src/test/compile-fail/regions-trait-1.rs @@ -34,5 +34,5 @@ fn get_v(gc: get_ctxt) -> uint { fn main() { let ctxt = ctxt { v: 22u }; let hc = has_ctxt { c: &ctxt }; - assert get_v(hc as get_ctxt) == 22u; + assert get_v(@hc as get_ctxt) == 22u; } diff --git a/src/test/compile-fail/regions-trait-2.rs b/src/test/compile-fail/regions-trait-2.rs index 2cb1f9deb49..c5978e55fb3 100644 --- a/src/test/compile-fail/regions-trait-2.rs +++ b/src/test/compile-fail/regions-trait-2.rs @@ -23,7 +23,7 @@ impl get_ctxt for has_ctxt { fn make_gc() -> get_ctxt { let ctxt = ctxt { v: 22u }; let hc = has_ctxt { c: &ctxt }; //~ ERROR illegal borrow - return hc as get_ctxt; + return @hc as get_ctxt; } fn main() { diff --git a/src/test/compile-fail/regions-trait-3.rs b/src/test/compile-fail/regions-trait-3.rs index d62d6cace3e..0ddaf25710c 100644 --- a/src/test/compile-fail/regions-trait-3.rs +++ b/src/test/compile-fail/regions-trait-3.rs @@ -17,7 +17,7 @@ fn make_gc1(gc: get_ctxt/&a) -> get_ctxt/&b { } fn make_gc2(gc: get_ctxt/&a) -> get_ctxt/&b { - return gc as get_ctxt; //~ ERROR cannot infer an appropriate lifetime + return @gc as get_ctxt; //~ ERROR cannot infer an appropriate lifetime } fn main() { diff --git a/src/test/compile-fail/selftype-astparam.rs b/src/test/compile-fail/selftype-astparam.rs index c89d1d2795b..08b6c0f71fe 100644 --- a/src/test/compile-fail/selftype-astparam.rs +++ b/src/test/compile-fail/selftype-astparam.rs @@ -19,7 +19,7 @@ impl add for int { fn do_add(x: A, y: A) -> A { x.plus(y) } fn main() { - let x = 3 as add; - let y = 4 as add; + let x = @3 as @add; + let y = @4 as @add; do_add(x, y); //~ ERROR a boxed trait with self types may not be passed as a bounded type } diff --git a/src/test/compile-fail/tps-invariant-trait.rs b/src/test/compile-fail/tps-invariant-trait.rs index 60da6d2208a..94bcea8f1d3 100644 --- a/src/test/compile-fail/tps-invariant-trait.rs +++ b/src/test/compile-fail/tps-invariant-trait.rs @@ -34,7 +34,7 @@ fn set_box_impl(b: box_impl<@const T>, v: @const T) { fn main() { let b = box_impl::<@int>(box::<@int> {f: @3}); - set_box_trait(b as box_trait::<@int>, @mut 5); + set_box_trait(@b as box_trait::<@int>, @mut 5); //~^ ERROR values differ in mutability set_box_impl(b, @mut 5); //~^ ERROR values differ in mutability diff --git a/src/test/compile-fail/trait-cast.rs b/src/test/compile-fail/trait-cast.rs index 7b2fc2165b4..d0738be09c7 100644 --- a/src/test/compile-fail/trait-cast.rs +++ b/src/test/compile-fail/trait-cast.rs @@ -11,7 +11,7 @@ trait foo { } fn bar(x: foo) -> foo { - return (x as foo::); + return (@x as foo::); //~^ ERROR mismatched types: expected `@foo` but found `@foo` //~^^ ERROR mismatched types: expected `@foo` but found `@foo` // This is unfortunate -- new handling of parens means the error message diff --git a/src/test/compile-fail/trait-test-2.rs b/src/test/compile-fail/trait-test-2.rs index 73b7c4369ac..a00e63b60d7 100644 --- a/src/test/compile-fail/trait-test-2.rs +++ b/src/test/compile-fail/trait-test-2.rs @@ -15,5 +15,5 @@ impl bar for uint { fn dup() -> uint { self } fn blah() {} } fn main() { 10i.dup::(); //~ ERROR does not take type parameters 10i.blah::(); //~ ERROR incorrect number of type parameters - (10 as bar).dup(); //~ ERROR contains a self-type + (@10 as bar).dup(); //~ ERROR contains a self-type } diff --git a/src/test/run-fail/unwind-box-trait.rs b/src/test/run-fail/unwind-box-trait.rs index b17fc467f0b..905670f8fb7 100644 --- a/src/test/run-fail/unwind-box-trait.rs +++ b/src/test/run-fail/unwind-box-trait.rs @@ -23,7 +23,7 @@ impl i for ~int { } fn main() { - let x = ~0 as i; + let x = @~0 as @i; failfn(); log(error, x); } diff --git a/src/test/run-pass/autoderef-method-on-trait-monomorphized.rs b/src/test/run-pass/autoderef-method-on-trait-monomorphized.rs index b44d1cbb78d..bfde19993e9 100644 --- a/src/test/run-pass/autoderef-method-on-trait-monomorphized.rs +++ b/src/test/run-pass/autoderef-method-on-trait-monomorphized.rs @@ -21,6 +21,6 @@ fn is_equal(x: @D, exp: uint) { } pub fn main() { - let x = @(3u as double); + let x = @(@3u as @double); is_equal(x, 6); } diff --git a/src/test/run-pass/autoderef-method-on-trait.rs b/src/test/run-pass/autoderef-method-on-trait.rs index 3653c0eb9c9..65a274d7764 100644 --- a/src/test/run-pass/autoderef-method-on-trait.rs +++ b/src/test/run-pass/autoderef-method-on-trait.rs @@ -17,6 +17,6 @@ impl double for uint { } pub fn main() { - let x = @(3u as double); + let x = @(@3u as @double); assert x.double() == 6u; } diff --git a/src/test/run-pass/boxed-trait-with-vstore.rs b/src/test/run-pass/boxed-trait-with-vstore.rs index 50e137d6fd5..1d2c30108f1 100644 --- a/src/test/run-pass/boxed-trait-with-vstore.rs +++ b/src/test/run-pass/boxed-trait-with-vstore.rs @@ -19,7 +19,7 @@ impl Foo for int { } pub fn main() { - let x = 3 as @Foo; + let x = @3 as @Foo; x.foo(); } diff --git a/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs b/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs index f81b12b555e..1db3d4b38d7 100644 --- a/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs +++ b/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs @@ -21,7 +21,7 @@ fn print_out(thing: T, expected: ~str) { } pub fn main() { - let nyan : ToStr = cat(0u, 2, ~"nyan") as ToStr; + let nyan : @ToStr = @cat(0u, 2, ~"nyan") as @ToStr; print_out(nyan, ~"nyan"); } diff --git a/src/test/run-pass/class-cast-to-trait-multiple-types.rs b/src/test/run-pass/class-cast-to-trait-multiple-types.rs index 7c5d5c4d126..5cf68174075 100644 --- a/src/test/run-pass/class-cast-to-trait-multiple-types.rs +++ b/src/test/run-pass/class-cast-to-trait-multiple-types.rs @@ -86,8 +86,8 @@ fn annoy_neighbors(critter: T) { pub fn main() { let nyan : cat = cat(0u, 2, ~"nyan"); let whitefang : dog = dog(); - annoy_neighbors((copy nyan) as noisy); - annoy_neighbors((copy whitefang) as noisy); + annoy_neighbors(@(copy nyan) as @noisy); + annoy_neighbors(@(copy whitefang) as @noisy); assert(nyan.meow_count() == 10u); assert(*whitefang.volume == 1); } diff --git a/src/test/run-pass/class-cast-to-trait.rs b/src/test/run-pass/class-cast-to-trait.rs index 581361c154c..a15afa60c75 100644 --- a/src/test/run-pass/class-cast-to-trait.rs +++ b/src/test/run-pass/class-cast-to-trait.rs @@ -56,6 +56,6 @@ fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat { pub fn main() { - let mut nyan: noisy = cat(0u, 2, ~"nyan") as noisy; + let mut nyan: @noisy = @cat(0u, 2, ~"nyan") as @noisy; nyan.speak(); } diff --git a/src/test/run-pass/class-separate-impl.rs b/src/test/run-pass/class-separate-impl.rs index 728deff8e2d..b232be32550 100644 --- a/src/test/run-pass/class-separate-impl.rs +++ b/src/test/run-pass/class-separate-impl.rs @@ -63,6 +63,6 @@ fn print_out(thing: T, expected: ~str) { } pub fn main() { - let mut nyan : ToStr = cat(0u, 2, ~"nyan") as ToStr; + let mut nyan : @ToStr = @cat(0u, 2, ~"nyan") as @ToStr; print_out(nyan, ~"nyan"); } diff --git a/src/test/run-pass/explicit-self-objects-ext-1.rs b/src/test/run-pass/explicit-self-objects-ext-1.rs index e226423f848..92f745d7d53 100644 --- a/src/test/run-pass/explicit-self-objects-ext-1.rs +++ b/src/test/run-pass/explicit-self-objects-ext-1.rs @@ -34,6 +34,6 @@ impl Reader for S { pub fn main() { let x = S { x: 1, y: 2 }; - let x = x as @Reader; + let x = @x as @Reader; x.read_bytes(0); } diff --git a/src/test/run-pass/explicit-self-objects-ext-2.rs b/src/test/run-pass/explicit-self-objects-ext-2.rs index e226423f848..92f745d7d53 100644 --- a/src/test/run-pass/explicit-self-objects-ext-2.rs +++ b/src/test/run-pass/explicit-self-objects-ext-2.rs @@ -34,6 +34,6 @@ impl Reader for S { pub fn main() { let x = S { x: 1, y: 2 }; - let x = x as @Reader; + let x = @x as @Reader; x.read_bytes(0); } diff --git a/src/test/run-pass/explicit-self-objects-ext-3.rs b/src/test/run-pass/explicit-self-objects-ext-3.rs index 1a18ee7c6f7..2cfd327dc4e 100644 --- a/src/test/run-pass/explicit-self-objects-ext-3.rs +++ b/src/test/run-pass/explicit-self-objects-ext-3.rs @@ -34,6 +34,6 @@ impl Reader for S { pub fn main() { let x = S { x: 1, y: 2 }; - let x = x as @Reader; + let x = @x as @Reader; x.read_bytes(0); } diff --git a/src/test/run-pass/explicit-self-objects-ext-4.rs b/src/test/run-pass/explicit-self-objects-ext-4.rs index a5d934d9984..3945be77904 100644 --- a/src/test/run-pass/explicit-self-objects-ext-4.rs +++ b/src/test/run-pass/explicit-self-objects-ext-4.rs @@ -34,6 +34,6 @@ impl Reader for S { pub fn main() { let x = S { x: 1, y: 2 }; - let x = x as @Reader; + let x = @x as @Reader; x.read_bytes(0); } diff --git a/src/test/run-pass/issue-2288.rs b/src/test/run-pass/issue-2288.rs index 375259baaf5..85ed524118b 100644 --- a/src/test/run-pass/issue-2288.rs +++ b/src/test/run-pass/issue-2288.rs @@ -33,6 +33,6 @@ fn f(x: clam, a: A) { pub fn main() { let c = foo(42); - let d: clam = c as clam::; + let d: clam = @c as clam::; f(d, c.x); } diff --git a/src/test/run-pass/issue-2734.rs b/src/test/run-pass/issue-2734.rs index 45c6b22544d..a76d2242b40 100644 --- a/src/test/run-pass/issue-2734.rs +++ b/src/test/run-pass/issue-2734.rs @@ -12,7 +12,7 @@ trait hax { } impl hax for A { } fn perform_hax(x: @T) -> hax { - x as hax + @x as @hax } fn deadcode() { diff --git a/src/test/run-pass/issue-2735.rs b/src/test/run-pass/issue-2735.rs index 7c87c6a31cd..14e27dce63d 100644 --- a/src/test/run-pass/issue-2735.rs +++ b/src/test/run-pass/issue-2735.rs @@ -8,11 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait hax { } -impl hax for A { } +trait hax { } +impl hax for A { } fn perform_hax(x: @T) -> hax { - x as hax + @x as @hax } fn deadcode() { diff --git a/src/test/run-pass/issue-2904.rs b/src/test/run-pass/issue-2904.rs index 9106d39c592..3ed7d2f842d 100644 --- a/src/test/run-pass/issue-2904.rs +++ b/src/test/run-pass/issue-2904.rs @@ -60,7 +60,7 @@ fn square_from_char(c: char) -> square { } fn read_board_grid(+in: rdr) -> ~[~[square]] { - let in = (in) as io::Reader; + let in = @in as @io::Reader; let mut grid = ~[]; for in.each_line |line| { let mut row = ~[]; diff --git a/src/test/run-pass/issue-2935.rs b/src/test/run-pass/issue-2935.rs index 82089dd3bed..64af4de46a2 100644 --- a/src/test/run-pass/issue-2935.rs +++ b/src/test/run-pass/issue-2935.rs @@ -25,7 +25,7 @@ pub fn main() { // let y = @({a: 4i}); // let z = @({a: 4i} as it); // let z = @({a: true} as it); - let z = @(true as it); + let z = @(@true as it); // x.f(); // y.f(); // (*z).f(); diff --git a/src/test/run-pass/issue-3305.rs b/src/test/run-pass/issue-3305.rs index b44d1cbb78d..bfde19993e9 100644 --- a/src/test/run-pass/issue-3305.rs +++ b/src/test/run-pass/issue-3305.rs @@ -21,6 +21,6 @@ fn is_equal(x: @D, exp: uint) { } pub fn main() { - let x = @(3u as double); + let x = @(@3u as @double); is_equal(x, 6); } diff --git a/src/test/run-pass/kindck-owned-trait-contains-1.rs b/src/test/run-pass/kindck-owned-trait-contains-1.rs index 351f68ab37c..0ef09d39663 100644 --- a/src/test/run-pass/kindck-owned-trait-contains-1.rs +++ b/src/test/run-pass/kindck-owned-trait-contains-1.rs @@ -16,7 +16,7 @@ impl repeat for @A { fn repeater(v: @A) -> repeat { // Note: owned kind is not necessary as A appears in the trait type - v as repeat:: // No + @v as repeat:: // No } pub fn main() { diff --git a/src/test/run-pass/reflect-visit-data.rs b/src/test/run-pass/reflect-visit-data.rs index 98e42bd7b4d..c472e530584 100644 --- a/src/test/run-pass/reflect-visit-data.rs +++ b/src/test/run-pass/reflect-visit-data.rs @@ -489,7 +489,7 @@ pub impl my_visitor { unsafe { let u = my_visitor(*self); let v = ptr_visit_adaptor::(Inner {inner: u}); - visit_tydesc(inner, v as TyVisitor); + visit_tydesc(inner, @v as @TyVisitor); true } } @@ -644,7 +644,7 @@ pub fn main() { let td = get_tydesc_for(r); unsafe { error!("tydesc sz: %u, align: %u", (*td).size, (*td).align); } - let v = v as TyVisitor; + let v = @v as @TyVisitor; visit_tydesc(td, v); for (copy u.vals).each |s| { diff --git a/src/test/run-pass/regions-trait.rs b/src/test/run-pass/regions-trait.rs index e45a0d252c6..2b9930778b2 100644 --- a/src/test/run-pass/regions-trait.rs +++ b/src/test/run-pass/regions-trait.rs @@ -30,5 +30,5 @@ pub fn main() { let ctxt = Ctxt { v: 22 }; let hc = HasCtxt { c: &ctxt }; - assert get_v(hc as get_ctxt) == 22; + assert get_v(@hc as @get_ctxt) == 22; } -- cgit 1.4.1-3-g733a5 From 6b6d15ac206e599509ebc40c39270877bf77c000 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Thu, 28 Feb 2013 20:30:16 -0800 Subject: Remove code that was awaiting a snapshot * Disallow structural records everywhere * Remove all #[cfg(stage0)] stuff * Remove the last deprecated modes in libcore * Un-xfail a test --- src/libcore/comm.rs | 3 --- src/libcore/core.rc | 4 ---- src/libcore/pipes.rs | 2 -- src/libcore/private/finally.rs | 23 ----------------------- src/libcore/stackwalk.rs | 3 --- src/librustc/middle/trans/common.rs | 5 +---- src/libstd/test.rs | 24 ------------------------ src/test/pretty/record-trailing-comma.rs | 3 --- src/test/run-pass/pipe-select-macro.rs | 2 -- 9 files changed, 1 insertion(+), 68 deletions(-) (limited to 'src/libstd') diff --git a/src/libcore/comm.rs b/src/libcore/comm.rs index da69cd984cd..b0825816626 100644 --- a/src/libcore/comm.rs +++ b/src/libcore/comm.rs @@ -8,9 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Transitional -- needs snapshot -#[allow(structural_records)]; - use either::{Either, Left, Right}; use kinds::Owned; use option; diff --git a/src/libcore/core.rc b/src/libcore/core.rc index ed18388f578..91eb61e342e 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -227,10 +227,6 @@ pub const debug : u32 = 4_u32; // The runtime interface used by the compiler #[cfg(notest)] pub mod rt; -// The runtime and compiler interface to fmt! -#[cfg(stage0)] -#[path = "private/extfmt.rs"] -pub mod extfmt; // Private APIs pub mod private; diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index 6389ec08615..77554656913 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -82,8 +82,6 @@ bounded and unbounded protocols allows for less code duplication. */ -#[allow(structural_records)]; // Macros -- needs another snapshot - use cmp::Eq; use cast::{forget, reinterpret_cast, transmute}; use cell::Cell; diff --git a/src/libcore/private/finally.rs b/src/libcore/private/finally.rs index af7197159ca..ff75963511c 100644 --- a/src/libcore/private/finally.rs +++ b/src/libcore/private/finally.rs @@ -26,33 +26,10 @@ do || { use ops::Drop; use task::{spawn, failing}; -#[cfg(stage0)] -pub trait Finally { - fn finally(&self, +dtor: &fn()) -> T; -} - -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] pub trait Finally { fn finally(&self, dtor: &fn()) -> T; } -#[cfg(stage0)] -impl Finally for &fn() -> T { - // FIXME #4518: Should not require a mode here - fn finally(&self, +dtor: &fn()) -> T { - let _d = Finallyalizer { - dtor: dtor - }; - - (*self)() - } -} - -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] impl Finally for &fn() -> T { fn finally(&self, dtor: &fn()) -> T { let _d = Finallyalizer { diff --git a/src/libcore/stackwalk.rs b/src/libcore/stackwalk.rs index 2e24df86c78..8950a1d0c02 100644 --- a/src/libcore/stackwalk.rs +++ b/src/libcore/stackwalk.rs @@ -10,9 +10,6 @@ #[doc(hidden)]; // FIXME #3538 -#[legacy_modes]; // tjc: remove after snapshot -#[allow(deprecated_mode)]; - use cast::reinterpret_cast; use ptr::offset; use sys::size_of; diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index 5ce20ac23bc..97f8ec84a1d 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -553,10 +553,7 @@ impl get_node_info for ast::blk { } } -// XXX: Work around a trait parsing bug. remove after snapshot -pub type optional_boxed_ast_expr = Option<@ast::expr>; - -impl get_node_info for optional_boxed_ast_expr { +impl get_node_info for Option<@ast::expr> { fn info(&self) -> Option { self.chain_ref(|s| s.info()) } diff --git a/src/libstd/test.rs b/src/libstd/test.rs index bfeaf8400bc..49a8dff4a96 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -46,34 +46,10 @@ extern mod rustrt { // colons. This way if some test runner wants to arrange the tests // hierarchically it may. -#[cfg(stage0)] -pub enum TestName { - // Stage0 doesn't understand sendable &static/str yet - StaticTestName(&static/[u8]), - DynTestName(~str) -} - -#[cfg(stage0)] -impl ToStr for TestName { - pure fn to_str(&self) -> ~str { - match self { - &StaticTestName(s) => str::from_bytes(s), - &DynTestName(s) => s.to_str() - } - } -} - -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] pub enum TestName { StaticTestName(&static/str), DynTestName(~str) } - -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] impl ToStr for TestName { pure fn to_str(&self) -> ~str { match self { diff --git a/src/test/pretty/record-trailing-comma.rs b/src/test/pretty/record-trailing-comma.rs index ace5da8eb4e..8c6afb7879d 100644 --- a/src/test/pretty/record-trailing-comma.rs +++ b/src/test/pretty/record-trailing-comma.rs @@ -8,9 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// NOTE this is a pretty-printer bug that I fixed, but it's -// not in the snapshot yet. After a new snapshot, can un-xfail -// xfail-pretty // pp-exact struct Thing { x: int, diff --git a/src/test/run-pass/pipe-select-macro.rs b/src/test/run-pass/pipe-select-macro.rs index 368cda63394..a77e6acbb25 100644 --- a/src/test/run-pass/pipe-select-macro.rs +++ b/src/test/run-pass/pipe-select-macro.rs @@ -8,9 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// tjc: un-xfail after snapshot // xfail-test -// xfail-pretty // Protocols proto! foo ( -- cgit 1.4.1-3-g733a5