From 5394e34aa43687e36fb94656faf075b125c43bb5 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Mon, 13 Aug 2012 16:20:27 -0700 Subject: [PATCH] core: Camel case some lesser-used modules --- src/libcore/at_vec.rs | 2 +- src/libcore/cmp.rs | 10 ++-- src/libcore/core.rc | 14 +++++ src/libcore/core.rs | 12 ++-- src/libcore/f32.rs | 2 +- src/libcore/f64.rs | 2 +- src/libcore/float.rs | 4 +- src/libcore/int-template.rs | 10 ++-- src/libcore/num.rs | 2 +- src/libcore/option.rs | 2 +- src/libcore/pipes.rs | 2 +- src/libcore/priv.rs | 25 ++++---- src/libcore/stackwalk.rs | 16 ++--- src/libcore/sys.rs | 11 ++-- src/libcore/task.rs | 8 +-- src/libcore/to_bytes.rs | 10 ++-- src/libcore/to_str.rs | 40 ++++++------- src/libcore/tuple.rs | 10 ++-- src/libcore/uint-template.rs | 8 +-- src/libcore/unsafe.rs | 59 ++++++++++--------- src/libcore/util.rs | 4 +- src/libcore/vec.rs | 4 +- src/libstd/arc.rs | 9 +-- src/libstd/dbg.rs | 12 ++-- src/libstd/json.rs | 4 +- src/libstd/map.rs | 4 +- src/libstd/net_url.rs | 2 +- src/libstd/sort.rs | 4 +- src/libstd/sync.rs | 6 +- src/libsyntax/ext/pipes/pipec.rs | 2 +- src/libsyntax/ext/pipes/proto.rs | 4 +- src/rustc/middle/liveness.rs | 4 +- src/test/auxiliary/cci_class_cast.rs | 4 +- src/test/auxiliary/issue_2242_a.rs | 8 +-- src/test/auxiliary/issue_2242_b.rs | 6 +- src/test/auxiliary/issue_2242_c.rs | 6 +- .../class-cast-to-trait-cross-crate-2.rs | 6 +- src/test/run-pass/class-separate-impl.rs | 8 +-- src/test/run-pass/issue-2242-d.rs | 8 +-- src/test/run-pass/issue-2904.rs | 2 +- 40 files changed, 187 insertions(+), 169 deletions(-) diff --git a/src/libcore/at_vec.rs b/src/libcore/at_vec.rs index 87802c5c13b..060015c26cf 100644 --- a/src/libcore/at_vec.rs +++ b/src/libcore/at_vec.rs @@ -14,7 +14,7 @@ export unsafe; #[abi = "cdecl"] extern mod rustrt { - fn vec_reserve_shared_actual(++t: *sys::type_desc, + fn vec_reserve_shared_actual(++t: *sys::TypeDesc, ++v: **vec::unsafe::vec_repr, ++n: libc::size_t); } diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index aa39ab2ada4..b7b32722a10 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -4,22 +4,22 @@ /// Interfaces used for comparison. -trait ord { +trait Ord { pure fn lt(&&other: self) -> bool; } -trait eq { +trait Eq { pure fn eq(&&other: self) -> bool; } -pure fn lt(v1: &T, v2: &T) -> bool { +pure fn lt(v1: &T, v2: &T) -> bool { v1.lt(*v2) } -pure fn le(v1: &T, v2: &T) -> bool { +pure fn le(v1: &T, v2: &T) -> bool { v1.lt(*v2) || v1.eq(*v2) } -pure fn eq(v1: &T, v2: &T) -> bool { +pure fn eq(v1: &T, v2: &T) -> bool { v1.eq(*v2) } diff --git a/src/libcore/core.rc b/src/libcore/core.rc index a9950d2897e..96324c1b297 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -159,17 +159,22 @@ mod ptr; mod vec; mod at_vec; mod bool; +#[warn(non_camel_case_types)] mod tuple; // Ubiquitous-utility-type modules #[cfg(notest)] mod ops; +#[warn(non_camel_case_types)] mod cmp; +#[warn(non_camel_case_types)] mod num; +#[warn(non_camel_case_types)] mod hash; mod either; mod iter; +#[warn(non_camel_case_types)] mod logging; mod option; #[path="iter-trait"] @@ -178,8 +183,11 @@ mod option_iter { mod inst; } mod result; +#[warn(non_camel_case_types)] mod to_str; +#[warn(non_camel_case_types)] mod to_bytes; +#[warn(non_camel_case_types)] mod util; // Data structure modules @@ -212,7 +220,9 @@ mod os; mod path; mod rand; mod run; +#[warn(non_camel_case_types)] mod sys; +#[warn(non_camel_case_types)] mod unsafe; @@ -227,9 +237,13 @@ mod rt; // For internal use, not exported +#[warn(non_camel_case_types)] mod unicode; +#[warn(non_camel_case_types)] mod priv; +#[warn(non_camel_case_types)] mod cmath; +#[warn(non_camel_case_types)] mod stackwalk; // Local Variables: diff --git a/src/libcore/core.rs b/src/libcore/core.rs index 14bafcd68f4..2f5e2cf6e0b 100644 --- a/src/libcore/core.rs +++ b/src/libcore/core.rs @@ -5,27 +5,27 @@ import option::{some, none}; import option = option::option; import path = path::path; -import tuple::{tuple_ops, extended_tuple_ops}; +import tuple::{TupleOps, ExtendedTupleOps}; import str::{str_slice, unique_str}; import vec::{const_vector, copyable_vector, immutable_vector}; import vec::{immutable_copyable_vector, iter_trait_extensions}; import iter::{base_iter, extended_iter, copyable_iter, times, timesi}; -import num::num; +import num::Num; import ptr::ptr; -import to_str::to_str; +import to_str::ToStr; export path, option, some, none, unreachable; export extensions; // The following exports are the extension impls for numeric types -export num, times, timesi; +export Num, times, timesi; // The following exports are the common traits export str_slice, unique_str; export const_vector, copyable_vector, immutable_vector; export immutable_copyable_vector, iter_trait_extensions; export base_iter, copyable_iter, extended_iter; -export tuple_ops, extended_tuple_ops; +export TupleOps, ExtendedTupleOps; export ptr; -export to_str; +export ToStr; // The following exports are the core operators and kinds // The compiler has special knowlege of these so we must not duplicate them diff --git a/src/libcore/f32.rs b/src/libcore/f32.rs index 5faf5393e39..17b8a2aa9e3 100644 --- a/src/libcore/f32.rs +++ b/src/libcore/f32.rs @@ -167,7 +167,7 @@ pure fn log2(n: f32) -> f32 { return ln(n) / consts::ln_2; } -impl f32: num::num { +impl f32: num::Num { pure fn add(&&other: f32) -> f32 { return self + other; } pure fn sub(&&other: f32) -> f32 { return self - other; } pure fn mul(&&other: f32) -> f32 { return self * other; } diff --git a/src/libcore/f64.rs b/src/libcore/f64.rs index bb7768beba2..4f4fe391625 100644 --- a/src/libcore/f64.rs +++ b/src/libcore/f64.rs @@ -194,7 +194,7 @@ pure fn log2(n: f64) -> f64 { return ln(n) / consts::ln_2; } -impl f64: num::num { +impl f64: num::Num { pure fn add(&&other: f64) -> f64 { return self + other; } pure fn sub(&&other: f64) -> f64 { return self - other; } pure fn mul(&&other: f64) -> f64 { return self * other; } diff --git a/src/libcore/float.rs b/src/libcore/float.rs index 0542b5b6593..040f321b513 100644 --- a/src/libcore/float.rs +++ b/src/libcore/float.rs @@ -409,7 +409,7 @@ pure fn sin(x: float) -> float { f64::sin(x as f64) as float } pure fn cos(x: float) -> float { f64::cos(x as f64) as float } pure fn tan(x: float) -> float { f64::tan(x as f64) as float } -impl float: num::num { +impl float: num::Num { pure fn add(&&other: float) -> float { return self + other; } pure fn sub(&&other: float) -> float { return self - other; } pure fn mul(&&other: float) -> float { return self * other; } @@ -516,7 +516,7 @@ fn test_to_str_inf() { #[test] fn test_traits() { - fn test(ten: U) { + fn test(ten: U) { assert (ten.to_int() == 10); let two = ten.from_int(2); diff --git a/src/libcore/int-template.rs b/src/libcore/int-template.rs index ac5d83a778b..dd0892f7100 100644 --- a/src/libcore/int-template.rs +++ b/src/libcore/int-template.rs @@ -1,5 +1,5 @@ import T = inst::T; -import cmp::{eq, ord}; +import cmp::{Eq, Ord}; export min_value, max_value; export min, max; @@ -62,20 +62,20 @@ pure fn abs(i: T) -> T { if is_negative(i) { -i } else { i } } -impl T: ord { +impl T: Ord { pure fn lt(&&other: T) -> bool { return self < other; } } -impl T: eq { +impl T: Eq { pure fn eq(&&other: T) -> bool { return self == other; } } -impl T: num::num { +impl T: num::Num { pure fn add(&&other: T) -> T { return self + other; } pure fn sub(&&other: T) -> T { return self - other; } pure fn mul(&&other: T) -> T { return self * other; } @@ -235,7 +235,7 @@ fn test_to_str() { #[test] fn test_interfaces() { - fn test(ten: U) { + fn test(ten: U) { assert (ten.to_int() == 10); let two = ten.from_int(2); diff --git a/src/libcore/num.rs b/src/libcore/num.rs index e8a36f38842..a06c4e419e5 100644 --- a/src/libcore/num.rs +++ b/src/libcore/num.rs @@ -1,6 +1,6 @@ /// An interface for numbers. -trait num { +trait Num { // FIXME: Cross-crate overloading doesn't work yet. (#2615) // FIXME: Trait composition. (#2616) pure fn add(&&other: self) -> self; diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 325f4cf70c5..d68401fadbe 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -227,7 +227,7 @@ fn test_option_dance() { } #[test] #[should_fail] #[ignore(cfg(windows))] fn test_option_too_much_dance() { - let mut y = some(util::noncopyable()); + let mut y = some(util::NonCopyable()); let _y2 = swap_unwrap(&mut y); let _y3 = swap_unwrap(&mut y); } diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index b96bf30ea7e..4f39c42137c 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -1081,7 +1081,7 @@ impl port: selectable { } /// A channel that can be shared between many senders. -type shared_chan = unsafe::exclusive>; +type shared_chan = unsafe::Exclusive>; impl shared_chan: channel { fn send(+x: T) { diff --git a/src/libcore/priv.rs b/src/libcore/priv.rs index 2ec12b6c849..a844a0d6e13 100644 --- a/src/libcore/priv.rs +++ b/src/libcore/priv.rs @@ -5,6 +5,7 @@ export chan_from_global_ptr, weaken_task; import compare_and_swap = rustrt::rust_compare_and_swap_ptr; import task::task_builder; +#[allow(non_camel_case_types)] // runtime type type rust_port_id = uint; extern mod rustrt { @@ -15,7 +16,7 @@ extern mod rustrt { fn rust_task_unweaken(ch: rust_port_id); } -type global_ptr = *libc::uintptr_t; +type GlobalPtr = *libc::uintptr_t; /** * Atomically gets a channel from a pointer to a pointer-sized memory location @@ -23,14 +24,14 @@ type global_ptr = *libc::uintptr_t; * new task to receive from it. */ unsafe fn chan_from_global_ptr( - global: global_ptr, + global: GlobalPtr, task_fn: fn() -> task::task_builder, +f: fn~(comm::port) ) -> comm::chan { - enum msg { - proceed, - abort + enum Msg { + Proceed, + Abort } log(debug,~"ENTERING chan_from_global_ptr, before is_prob_zero check"); @@ -48,9 +49,9 @@ unsafe fn chan_from_global_ptr( // Wait to hear if we are the official instance of // this global task - match comm::recv::(setup_po) { - proceed => f(po), - abort => () + match comm::recv::(setup_po) { + Proceed => f(po), + Abort => () } }; @@ -68,11 +69,11 @@ unsafe fn chan_from_global_ptr( if swapped { // Success! - comm::send(setup_ch, proceed); + comm::send(setup_ch, Proceed); ch } else { // Somebody else got in before we did - comm::send(setup_ch, abort); + comm::send(setup_ch, Abort); unsafe::reinterpret_cast(*global) } } else { @@ -186,10 +187,10 @@ unsafe fn weaken_task(f: fn(comm::port<()>)) { unsafe { rustrt::rust_task_weaken(unsafe::reinterpret_cast(ch)); } - let _unweaken = unweaken(ch); + let _unweaken = Unweaken(ch); f(po); - class unweaken { + class Unweaken { let ch: comm::chan<()>; new(ch: comm::chan<()>) { self.ch = ch; } drop unsafe { diff --git a/src/libcore/stackwalk.rs b/src/libcore/stackwalk.rs index 939cdfade82..07c6ae6925e 100644 --- a/src/libcore/stackwalk.rs +++ b/src/libcore/stackwalk.rs @@ -4,32 +4,32 @@ import unsafe::reinterpret_cast; import ptr::offset; import sys::size_of; -type word = uint; +type Word = uint; -class frame { - let fp: *word; +class Frame { + let fp: *Word; - new(fp: *word) { + new(fp: *Word) { self.fp = fp; } } -fn walk_stack(visit: fn(frame) -> bool) { +fn walk_stack(visit: fn(Frame) -> bool) { debug!{"beginning stack walk"}; do frame_address |frame_pointer| { - let mut frame_address: *word = unsafe { + let mut frame_address: *Word = unsafe { reinterpret_cast(frame_pointer) }; loop { - let fr = frame(frame_address); + let fr = Frame(frame_address); debug!{"frame: %x", unsafe { reinterpret_cast(fr.fp) }}; visit(fr); unsafe { - let next_fp: **word = reinterpret_cast(frame_address); + let next_fp: **Word = reinterpret_cast(frame_address); frame_address = *next_fp; if *frame_address == 0u { debug!{"encountered task_start_wrapper. ending walk"}; diff --git a/src/libcore/sys.rs b/src/libcore/sys.rs index 1e77a1441cc..76f18a8c5d9 100644 --- a/src/libcore/sys.rs +++ b/src/libcore/sys.rs @@ -1,6 +1,6 @@ //! Misc low level stuff -export type_desc; +export TypeDesc; export get_type_desc; export size_of; export min_align_of; @@ -9,7 +9,8 @@ export refcount; export log_str; export shape_eq, shape_lt, shape_le; -enum type_desc = { +// Corresponds to runtime type_desc type +enum TypeDesc = { size: uint, align: uint // Remaining fields not listed @@ -17,7 +18,7 @@ enum type_desc = { #[abi = "cdecl"] extern mod rustrt { - pure fn shape_log_str(t: *sys::type_desc, data: *()) -> ~str; + pure fn shape_log_str(t: *sys::TypeDesc, data: *()) -> ~str; } #[abi = "rust-intrinsic"] @@ -48,8 +49,8 @@ pure fn shape_le(x1: &T, x2: &T) -> bool { * Useful for calling certain function in the Rust runtime or otherwise * performing dark magick. */ -pure fn get_type_desc() -> *type_desc { - unchecked { rusti::get_tydesc::() as *type_desc } +pure fn get_type_desc() -> *TypeDesc { + unchecked { rusti::get_tydesc::() as *TypeDesc } } /// Returns the size of a type diff --git a/src/libcore/task.rs b/src/libcore/task.rs index e2767da0c3e..244feb3f713 100644 --- a/src/libcore/task.rs +++ b/src/libcore/task.rs @@ -188,7 +188,7 @@ type task_opts = { enum task_builder = { opts: task_opts, gen_body: fn@(+fn~()) -> fn~(), - can_not_copy: option, + can_not_copy: option, mut consumed: bool, }; @@ -725,7 +725,7 @@ type taskgroup_data = { // tasks in this group. mut descendants: taskset, }; -type taskgroup_arc = unsafe::exclusive>; +type taskgroup_arc = unsafe::Exclusive>; type taskgroup_inner = &mut option; @@ -754,7 +754,7 @@ type ancestor_node = { // Recursive rest of the list. mut ancestors: ancestor_list, }; -enum ancestor_list = option>; +enum ancestor_list = option>; // Accessors for taskgroup arcs and ancestor arcs that wrap the unsafety. #[inline(always)] @@ -762,7 +762,7 @@ fn access_group(x: taskgroup_arc, blk: fn(taskgroup_inner) -> U) -> U { unsafe { x.with(blk) } } #[inline(always)] -fn access_ancestors(x: unsafe::exclusive, +fn access_ancestors(x: unsafe::Exclusive, blk: fn(x: &mut ancestor_node) -> U) -> U { unsafe { x.with(blk) } } diff --git a/src/libcore/to_bytes.rs b/src/libcore/to_bytes.rs index 45e502e4b0c..90026e1a194 100644 --- a/src/libcore/to_bytes.rs +++ b/src/libcore/to_bytes.rs @@ -1,19 +1,19 @@ -trait to_bytes { +trait ToBytes { fn to_bytes() -> ~[u8]; } -impl ~[u8]: to_bytes { +impl ~[u8]: ToBytes { fn to_bytes() -> ~[u8] { copy self } } -impl @~[u8]: to_bytes { +impl @~[u8]: ToBytes { fn to_bytes() -> ~[u8] { copy *self } } -impl ~str: to_bytes { +impl ~str: ToBytes { fn to_bytes() -> ~[u8] { str::bytes(self) } } -impl @(~str): to_bytes { +impl @(~str): ToBytes { fn to_bytes() -> ~[u8] { str::bytes(*self) } } diff --git a/src/libcore/to_str.rs b/src/libcore/to_str.rs index 01f55a24bde..93cae2772ac 100644 --- a/src/libcore/to_str.rs +++ b/src/libcore/to_str.rs @@ -1,62 +1,62 @@ -trait to_str { fn to_str() -> ~str; } +trait ToStr { fn to_str() -> ~str; } -impl int: to_str { +impl int: ToStr { fn to_str() -> ~str { int::str(self) } } -impl i8: to_str { +impl i8: ToStr { fn to_str() -> ~str { i8::str(self) } } -impl i16: to_str { +impl i16: ToStr { fn to_str() -> ~str { i16::str(self) } } -impl i32: to_str { +impl i32: ToStr { fn to_str() -> ~str { i32::str(self) } } -impl i64: to_str { +impl i64: ToStr { fn to_str() -> ~str { i64::str(self) } } -impl uint: to_str { +impl uint: ToStr { fn to_str() -> ~str { uint::str(self) } } -impl u8: to_str { +impl u8: ToStr { fn to_str() -> ~str { u8::str(self) } } -impl u16: to_str { +impl u16: ToStr { fn to_str() -> ~str { u16::str(self) } } -impl u32: to_str { +impl u32: ToStr { fn to_str() -> ~str { u32::str(self) } } -impl u64: to_str { +impl u64: ToStr { fn to_str() -> ~str { u64::str(self) } } -impl float: to_str { +impl float: ToStr { fn to_str() -> ~str { float::to_str(self, 4u) } } -impl bool: to_str { +impl bool: ToStr { fn to_str() -> ~str { bool::to_str(self) } } -impl (): to_str { +impl (): ToStr { fn to_str() -> ~str { ~"()" } } -impl ~str: to_str { +impl ~str: ToStr { fn to_str() -> ~str { self } } -impl (A, B): to_str { +impl (A, B): ToStr { fn to_str() -> ~str { let (a, b) = self; ~"(" + a.to_str() + ~", " + b.to_str() + ~")" } } -impl (A, B, C): to_str { +impl (A, B, C): ToStr { fn to_str() -> ~str { let (a, b, c) = self; ~"(" + a.to_str() + ~", " + b.to_str() + ~", " + c.to_str() + ~")" } } -impl ~[A]: to_str { +impl ~[A]: ToStr { fn to_str() -> ~str { let mut acc = ~"[", first = true; for vec::each(self) |elt| { @@ -69,10 +69,10 @@ impl ~[A]: to_str { } } -impl @A: to_str { +impl @A: ToStr { fn to_str() -> ~str { ~"@" + (*self).to_str() } } -impl ~A: to_str { +impl ~A: ToStr { fn to_str() -> ~str { ~"~" + (*self).to_str() } } diff --git a/src/libcore/tuple.rs b/src/libcore/tuple.rs index 42990eaf4ba..749532c3f4b 100644 --- a/src/libcore/tuple.rs +++ b/src/libcore/tuple.rs @@ -1,12 +1,12 @@ //! Operations on tuples -trait tuple_ops { +trait TupleOps { pure fn first() -> T; pure fn second() -> U; pure fn swap() -> (U, T); } -impl (T, U): tuple_ops { +impl (T, U): TupleOps { /// Return the first element of self pure fn first() -> T { @@ -28,12 +28,12 @@ impl (T, U): tuple_ops { } -trait extended_tuple_ops { +trait ExtendedTupleOps { fn zip() -> ~[(A, B)]; fn map(f: fn(A, B) -> C) -> ~[C]; } -impl (&[A], &[B]): extended_tuple_ops { +impl (&[A], &[B]): ExtendedTupleOps { fn zip() -> ~[(A, B)] { let (a, b) = self; @@ -46,7 +46,7 @@ impl (&[A], &[B]): extended_tuple_ops { } } -impl (~[A], ~[B]): extended_tuple_ops { +impl (~[A], ~[B]): ExtendedTupleOps { fn zip() -> ~[(A, B)] { let (a, b) = self; diff --git a/src/libcore/uint-template.rs b/src/libcore/uint-template.rs index 3178e6ab75d..162b0d39838 100644 --- a/src/libcore/uint-template.rs +++ b/src/libcore/uint-template.rs @@ -1,5 +1,5 @@ import T = inst::T; -import cmp::{eq, ord}; +import cmp::{Eq, Ord}; export min_value, max_value; export min, max; @@ -56,19 +56,19 @@ pure fn compl(i: T) -> T { max_value ^ i } -impl T: ord { +impl T: Ord { pure fn lt(&&other: T) -> bool { return self < other; } } -impl T: eq { +impl T: Eq { pure fn eq(&&other: T) -> bool { return self == other; } } -impl T: num::num { +impl T: num::Num { pure fn add(&&other: T) -> T { return self + other; } pure fn sub(&&other: T) -> T { return self - other; } pure fn mul(&&other: T) -> T { return self * other; } diff --git a/src/libcore/unsafe.rs b/src/libcore/unsafe.rs index e8a6cd075a5..f8c6074abcf 100644 --- a/src/libcore/unsafe.rs +++ b/src/libcore/unsafe.rs @@ -2,9 +2,9 @@ export reinterpret_cast, forget, bump_box_refcount, transmute; -export shared_mutable_state, clone_shared_mutable_state; +export SharedMutableState, shared_mutable_state, clone_shared_mutable_state; export get_shared_mutable_state, get_shared_immutable_state; -export exclusive; +export Exclusive, exclusive; import task::atomically; @@ -57,16 +57,16 @@ unsafe fn transmute(-thing: L) -> G { * Shared state & exclusive ARC ****************************************************************************/ -type arc_data = { +type ArcData = { mut count: libc::intptr_t, data: T }; -class arc_destruct { +class ArcDestruct { let data: *libc::c_void; new(data: *libc::c_void) { self.data = data; } drop unsafe { - let data: ~arc_data = unsafe::reinterpret_cast(self.data); + let data: ~ArcData = unsafe::reinterpret_cast(self.data); let new_count = rustrt::rust_atomic_decrement(&mut data.count); assert new_count >= 0; if new_count == 0 { @@ -83,20 +83,20 @@ class arc_destruct { * Data races between tasks can result in crashes and, with sufficient * cleverness, arbitrary type coercion. */ -type shared_mutable_state = arc_destruct; +type SharedMutableState = ArcDestruct; -unsafe fn shared_mutable_state(+data: T) -> shared_mutable_state { +unsafe fn shared_mutable_state(+data: T) -> SharedMutableState { let data = ~{mut count: 1, data: data}; unsafe { let ptr = unsafe::transmute(data); - arc_destruct(ptr) + ArcDestruct(ptr) } } -unsafe fn get_shared_mutable_state(rc: &shared_mutable_state) +unsafe fn get_shared_mutable_state(rc: &SharedMutableState) -> &mut T { unsafe { - let ptr: ~arc_data = unsafe::reinterpret_cast((*rc).data); + let ptr: ~ArcData = unsafe::reinterpret_cast((*rc).data); assert ptr.count > 0; // Cast us back into the correct region let r = unsafe::reinterpret_cast(&ptr.data); @@ -104,10 +104,10 @@ unsafe fn get_shared_mutable_state(rc: &shared_mutable_state) return r; } } -unsafe fn get_shared_immutable_state(rc: &shared_mutable_state) +unsafe fn get_shared_immutable_state(rc: &SharedMutableState) -> &T { unsafe { - let ptr: ~arc_data = unsafe::reinterpret_cast((*rc).data); + let ptr: ~ArcData = unsafe::reinterpret_cast((*rc).data); assert ptr.count > 0; // Cast us back into the correct region let r = unsafe::reinterpret_cast(&ptr.data); @@ -116,19 +116,20 @@ unsafe fn get_shared_immutable_state(rc: &shared_mutable_state) } } -unsafe fn clone_shared_mutable_state(rc: &shared_mutable_state) - -> shared_mutable_state { +unsafe fn clone_shared_mutable_state(rc: &SharedMutableState) + -> SharedMutableState { unsafe { - let ptr: ~arc_data = unsafe::reinterpret_cast((*rc).data); + let ptr: ~ArcData = unsafe::reinterpret_cast((*rc).data); let new_count = rustrt::rust_atomic_increment(&mut ptr.count); assert new_count >= 2; unsafe::forget(ptr); } - arc_destruct((*rc).data) + ArcDestruct((*rc).data) } /****************************************************************************/ +#[allow(non_camel_case_types)] // runtime type type rust_little_lock = *libc::c_void; #[abi = "cdecl"] @@ -147,7 +148,7 @@ extern mod rustrt { fn rust_unlock_little_lock(lock: rust_little_lock); } -class little_lock { +class LittleLock { let l: rust_little_lock; new() { self.l = rustrt::rust_create_little_lock(); @@ -155,9 +156,9 @@ class little_lock { drop { rustrt::rust_destroy_little_lock(self.l); } } -impl little_lock { +impl LittleLock { unsafe fn lock(f: fn() -> T) -> T { - class unlock { + class Unlock { let l: rust_little_lock; new(l: rust_little_lock) { self.l = l; } drop { rustrt::rust_unlock_little_lock(self.l); } @@ -165,29 +166,29 @@ impl little_lock { do atomically { rustrt::rust_lock_little_lock(self.l); - let _r = unlock(self.l); + let _r = Unlock(self.l); f() } } } -struct ex_data { lock: little_lock; mut failed: bool; mut data: T; } +struct ExData { lock: LittleLock; mut failed: bool; mut data: T; } /** * An arc over mutable data that is protected by a lock. For library use only. */ -struct exclusive { x: shared_mutable_state>; } +struct Exclusive { x: SharedMutableState>; } -fn exclusive(+user_data: T) -> exclusive { - let data = ex_data { - lock: little_lock(), mut failed: false, mut data: user_data +fn exclusive(+user_data: T) -> Exclusive { + let data = ExData { + lock: LittleLock(), mut failed: false, mut data: user_data }; - exclusive { x: unsafe { shared_mutable_state(data) } } + Exclusive { x: unsafe { shared_mutable_state(data) } } } -impl exclusive { +impl Exclusive { // Duplicate an exclusive ARC, as std::arc::clone. - fn clone() -> exclusive { - exclusive { x: unsafe { clone_shared_mutable_state(&self.x) } } + fn clone() -> Exclusive { + Exclusive { x: unsafe { clone_shared_mutable_state(&self.x) } } } // Exactly like std::arc::mutex_arc,access(), but with the little_lock diff --git a/src/libcore/util.rs b/src/libcore/util.rs index 0f6c852ddcb..c8e1d72e305 100644 --- a/src/libcore/util.rs +++ b/src/libcore/util.rs @@ -29,7 +29,7 @@ fn replace(dest: &mut T, +src: T) -> T { } /// A non-copyable dummy type. -class noncopyable { +class NonCopyable { i: (); new() { self.i = (); } drop { } @@ -52,7 +52,7 @@ mod tests { } #[test] fn test_replace() { - let mut x = some(noncopyable()); + let mut x = some(NonCopyable()); let y = replace(&mut x, none); assert x.is_none(); assert y.is_some(); diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index fcda831d905..6bd0e8c8cd2 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -95,10 +95,10 @@ export vec_concat; #[abi = "cdecl"] extern mod rustrt { - fn vec_reserve_shared(++t: *sys::type_desc, + fn vec_reserve_shared(++t: *sys::TypeDesc, ++v: **unsafe::vec_repr, ++n: libc::size_t); - fn vec_from_buf_shared(++t: *sys::type_desc, + fn vec_from_buf_shared(++t: *sys::TypeDesc, ++ptr: *(), ++count: libc::size_t) -> *unsafe::vec_repr; } diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index 4b01e77b22a..03261ec0025 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -3,7 +3,8 @@ * between tasks. */ -import unsafe::{shared_mutable_state, clone_shared_mutable_state, +import unsafe::{SharedMutableState, + shared_mutable_state, clone_shared_mutable_state, get_shared_mutable_state, get_shared_immutable_state}; import sync; import sync::{mutex, rwlock}; @@ -39,7 +40,7 @@ impl &condvar { ****************************************************************************/ /// An atomically reference counted wrapper for shared immutable state. -struct arc { x: shared_mutable_state; } +struct arc { x: SharedMutableState; } /// Create an atomically reference counted wrapper. fn arc(+data: T) -> arc { @@ -71,7 +72,7 @@ fn clone(rc: &arc) -> arc { struct mutex_arc_inner { lock: mutex; failed: bool; data: T; } /// An ARC with mutable data protected by a blocking mutex. -struct mutex_arc { x: shared_mutable_state>; } +struct mutex_arc { x: SharedMutableState>; } /// Create a mutex-protected ARC with the supplied data. fn mutex_arc(+user_data: T) -> mutex_arc { @@ -176,7 +177,7 @@ struct rw_arc_inner { lock: rwlock; failed: bool; data: T; } * Unlike mutex_arcs, rw_arcs are safe, because they cannot be nested. */ struct rw_arc { - x: shared_mutable_state>; + x: SharedMutableState>; mut cant_nest: (); } diff --git a/src/libstd/dbg.rs b/src/libstd/dbg.rs index ddc0d3b4450..736ad0e416a 100644 --- a/src/libstd/dbg.rs +++ b/src/libstd/dbg.rs @@ -12,12 +12,12 @@ export breakpoint; #[abi = "cdecl"] extern mod rustrt { - fn debug_tydesc(td: *sys::type_desc); - fn debug_opaque(td: *sys::type_desc, x: *()); - fn debug_box(td: *sys::type_desc, x: *()); - fn debug_tag(td: *sys::type_desc, x: *()); - fn debug_fn(td: *sys::type_desc, x: *()); - fn debug_ptrcast(td: *sys::type_desc, x: *()) -> *(); + fn debug_tydesc(td: *sys::TypeDesc); + fn debug_opaque(td: *sys::TypeDesc, x: *()); + fn debug_box(td: *sys::TypeDesc, x: *()); + fn debug_tag(td: *sys::TypeDesc, x: *()); + fn debug_fn(td: *sys::TypeDesc, x: *()); + fn debug_ptrcast(td: *sys::TypeDesc, x: *()) -> *(); fn rust_dbg_breakpoint(); } diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 2ddfc041f95..f78e4be06da 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -622,11 +622,11 @@ impl option: to_json { } } -impl json: to_str::to_str { +impl json: to_str::ToStr { fn to_str() -> ~str { to_str(self) } } -impl error: to_str::to_str { +impl error: to_str::ToStr { fn to_str() -> ~str { fmt!{"%u:%u: %s", self.line, self.col, *self.msg} } diff --git a/src/libstd/map.rs b/src/libstd/map.rs index 944e9c93e19..071ef5952e0 100644 --- a/src/libstd/map.rs +++ b/src/libstd/map.rs @@ -3,7 +3,7 @@ #[warn(deprecated_mode)]; import io::writer_util; -import to_str::to_str; +import to_str::ToStr; export hashmap, hashfn, eqfn, set, map, chained, hashmap, str_hash; export box_str_hash; export bytes_hash, int_hash, uint_hash, set_add; @@ -327,7 +327,7 @@ mod chained { } } - impl t: to_str { + impl t: ToStr { fn to_writer(wr: io::writer) { if self.count == 0u { wr.write_str(~"{}"); diff --git a/src/libstd/net_url.rs b/src/libstd/net_url.rs index e6428c19d10..e39eb777156 100644 --- a/src/libstd/net_url.rs +++ b/src/libstd/net_url.rs @@ -673,7 +673,7 @@ fn to_str(url: url) -> ~str { fragment]); } -impl url: to_str::to_str { +impl url: to_str::ToStr { fn to_str() -> ~str { to_str(self) } diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 5cd2a8aa532..df13fcba1af 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -1,6 +1,6 @@ //! Sorting methods import vec::{len, push}; -import core::cmp::{eq, ord}; +import core::cmp::{Eq, Ord}; export le; export merge_sort; @@ -153,7 +153,7 @@ fn qsort3(compare_func_lt: le, compare_func_eq: le, * * This is an unstable sort. */ -fn quick_sort3(arr: ~[mut T]) { +fn quick_sort3(arr: ~[mut T]) { if arr.len() <= 1 { return; } qsort3(core::cmp::lt, core::cmp::eq, arr, 0, (arr.len() - 1) as int); } diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index 5f08cf9128c..20aa6846bcb 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -8,7 +8,7 @@ export condvar, semaphore, mutex, rwlock; // FIXME (#3119) This shouldn't be a thing exported from core. -import unsafe::exclusive; +import unsafe::{Exclusive, exclusive}; /**************************************************************************** * Internals @@ -55,7 +55,7 @@ struct sem_inner { // a condition variable attached, others should. blocked: Q; } -enum sem = exclusive>; +enum sem = Exclusive>; fn new_sem(count: int, +q: Q) -> sem { let (wait_tail, wait_head) = pipes::stream(); @@ -293,7 +293,7 @@ struct rwlock_inner { struct rwlock { /* priv */ order_lock: semaphore; /* priv */ access_lock: sem; - /* priv */ state: exclusive; + /* priv */ state: Exclusive; } /// Create a new rwlock. diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index f1f8eb4f452..ef7562e0ffe 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -1,6 +1,6 @@ // A protocol compiler for Rust. -import to_str::to_str; +import to_str::ToStr; import dvec::dvec; diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs index 8409135db6b..5fba31ed6e7 100644 --- a/src/libsyntax/ext/pipes/proto.rs +++ b/src/libsyntax/ext/pipes/proto.rs @@ -1,4 +1,4 @@ -import to_str::to_str; +import to_str::ToStr; import dvec::dvec; import ast::{ident}; @@ -9,7 +9,7 @@ enum direction { send, recv } -impl direction: to_str { +impl direction: ToStr { fn to_str() -> ~str { match self { send => ~"send", diff --git a/src/rustc/middle/liveness.rs b/src/rustc/middle/liveness.rs index 4c4bf98626b..14a8fa1af5b 100644 --- a/src/rustc/middle/liveness.rs +++ b/src/rustc/middle/liveness.rs @@ -152,11 +152,11 @@ fn check_crate(tcx: ty::ctxt, return last_use_map; } -impl live_node: to_str::to_str { +impl live_node: to_str::ToStr { fn to_str() -> ~str { fmt!{"ln(%u)", *self} } } -impl variable: to_str::to_str { +impl variable: to_str::ToStr { fn to_str() -> ~str { fmt!{"v(%u)", *self} } } diff --git a/src/test/auxiliary/cci_class_cast.rs b/src/test/auxiliary/cci_class_cast.rs index 36642db378f..64644f665d2 100644 --- a/src/test/auxiliary/cci_class_cast.rs +++ b/src/test/auxiliary/cci_class_cast.rs @@ -1,9 +1,9 @@ import to_str::*; -import to_str::to_str; +import to_str::ToStr; mod kitty { -class cat : to_str { +class cat : ToStr { priv { let mut meows : uint; fn meow() { diff --git a/src/test/auxiliary/issue_2242_a.rs b/src/test/auxiliary/issue_2242_a.rs index c00f27cd511..ac7a8e47f26 100644 --- a/src/test/auxiliary/issue_2242_a.rs +++ b/src/test/auxiliary/issue_2242_a.rs @@ -1,10 +1,10 @@ #[link(name = "a", vers = "0.1")]; #[crate_type = "lib"]; -trait to_str { - fn to_str() -> ~str; +trait to_strz { + fn to_strz() -> ~str; } -impl ~str: to_str { - fn to_str() -> ~str { self } +impl ~str: to_strz { + fn to_strz() -> ~str { self } } diff --git a/src/test/auxiliary/issue_2242_b.rs b/src/test/auxiliary/issue_2242_b.rs index a676066acf3..c8c120416d5 100644 --- a/src/test/auxiliary/issue_2242_b.rs +++ b/src/test/auxiliary/issue_2242_b.rs @@ -2,8 +2,8 @@ #[crate_type = "lib"]; use a; -import a::to_str; +import a::to_strz; -impl int: to_str { - fn to_str() -> ~str { fmt!{"%?", self} } +impl int: to_strz { + fn to_strz() -> ~str { fmt!{"%?", self} } } diff --git a/src/test/auxiliary/issue_2242_c.rs b/src/test/auxiliary/issue_2242_c.rs index 35c82ff7c01..c0f73fdb220 100644 --- a/src/test/auxiliary/issue_2242_c.rs +++ b/src/test/auxiliary/issue_2242_c.rs @@ -3,8 +3,8 @@ use a; -import a::to_str; +import a::to_strz; -impl bool: to_str { - fn to_str() -> ~str { fmt!{"%b", self} } +impl bool: to_strz { + fn to_strz() -> ~str { fmt!{"%b", self} } } 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 24ffaa22cd4..73061c85dfb 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 @@ -1,17 +1,17 @@ // xfail-fast // aux-build:cci_class_cast.rs use cci_class_cast; -import to_str::to_str; +import to_str::ToStr; import cci_class_cast::kitty::*; -fn print_out(thing: T, expected: ~str) { +fn print_out(thing: T, expected: ~str) { let actual = thing.to_str(); debug!{"%s", actual}; assert(actual == expected); } fn main() { - let nyan : to_str = cat(0u, 2, ~"nyan") as to_str; + let nyan : ToStr = cat(0u, 2, ~"nyan") as ToStr; print_out(nyan, ~"nyan"); } diff --git a/src/test/run-pass/class-separate-impl.rs b/src/test/run-pass/class-separate-impl.rs index 9be142647b5..097418cd884 100644 --- a/src/test/run-pass/class-separate-impl.rs +++ b/src/test/run-pass/class-separate-impl.rs @@ -1,6 +1,6 @@ // xfail-fast import to_str::*; -import to_str::to_str; +import to_str::ToStr; class cat { priv { @@ -35,17 +35,17 @@ class cat { } } -impl cat: to_str { +impl cat: ToStr { fn to_str() -> ~str { self.name } } -fn print_out(thing: T, expected: ~str) { +fn print_out(thing: T, expected: ~str) { let actual = thing.to_str(); debug!{"%s", actual}; assert(actual == expected); } fn main() { - let nyan : to_str = cat(0u, 2, ~"nyan") as to_str; + let nyan : ToStr = cat(0u, 2, ~"nyan") as ToStr; print_out(nyan, ~"nyan"); } diff --git a/src/test/run-pass/issue-2242-d.rs b/src/test/run-pass/issue-2242-d.rs index fcbb0009035..625bbf13ecb 100644 --- a/src/test/run-pass/issue-2242-d.rs +++ b/src/test/run-pass/issue-2242-d.rs @@ -7,10 +7,10 @@ use a; use b; use c; -import a::to_str; +import a::to_strz; fn main() { - io::println((~"foo").to_str()); - io::println(1.to_str()); - io::println(true.to_str()); + io::println((~"foo").to_strz()); + io::println(1.to_strz()); + io::println(true.to_strz()); } diff --git a/src/test/run-pass/issue-2904.rs b/src/test/run-pass/issue-2904.rs index 200fe185f9f..467ebd824ce 100644 --- a/src/test/run-pass/issue-2904.rs +++ b/src/test/run-pass/issue-2904.rs @@ -13,7 +13,7 @@ enum square { empty } -impl square: to_str::to_str { +impl square: to_str::ToStr { fn to_str() -> ~str { match self { bot => { ~"R" }