From 7ff7489dc62bdcc0dbd507c52cba90d47cfdd129 Mon Sep 17 00:00:00 2001 From: Tyler Bindon Date: Fri, 25 Jan 2013 12:27:29 -0700 Subject: [PATCH 1/6] Fix Option camel case in error message --- src/librustc/middle/typeck/check/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index e1a549bcc7b24..43f609dd2f0a3 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -2696,7 +2696,7 @@ fn check_instantiable(tcx: ty::ctxt, if !ty::is_instantiable(tcx, item_ty) { tcx.sess.span_err(sp, fmt!("this type cannot be instantiated \ without an instance of itself; \ - consider using `option<%s>`", + consider using `Option<%s>`", ppaux::ty_to_str(tcx, item_ty))); } } From 3a5d2cdbf3aff91b57bc6b70dd429ae5e771d054 Mon Sep 17 00:00:00 2001 From: Tyler Bindon Date: Fri, 25 Jan 2013 12:29:51 -0700 Subject: [PATCH 2/6] Fix Option camel case in comments --- src/libcore/option.rs | 2 +- src/librustc/middle/borrowck/mod.rs | 6 +++--- src/librustc/middle/borrowck/preserve.rs | 8 ++++---- src/librustc/middle/trans/type_of.rs | 4 ++-- src/libstd/net_tcp.rs | 8 ++++---- src/libstd/rope.rs | 2 +- src/libstd/timer.rs | 8 ++++---- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 48f2ae719384e..05a2572fdefe3 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -149,7 +149,7 @@ pub pure fn chain_ref(opt: &Option, #[inline(always)] pub pure fn or(opta: Option, optb: Option) -> Option { /*! - * Returns the leftmost some() value, or none if both are none. + * Returns the leftmost Some() value, or None if both are None. */ match move opta { Some(move opta) => Some(move opta), diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index ab7de6d52ca41..35c1c96befae5 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -114,10 +114,10 @@ variables from reassigned if there may be pointers to their interior) Finally, in some cases, both dangers can arise. For example, something like the following: - let mut x = ~some(5); + let mut x = ~Some(5); match x { - ~some(ref y) => { ... } - ~none => { ... } + ~Some(ref y) => { ... } + ~None => { ... } } In this case, if `x` to be reassigned or `*x` were to be mutated, then diff --git a/src/librustc/middle/borrowck/preserve.rs b/src/librustc/middle/borrowck/preserve.rs index 4f7711c74a698..5916588a9a2bb 100644 --- a/src/librustc/middle/borrowck/preserve.rs +++ b/src/librustc/middle/borrowck/preserve.rs @@ -226,8 +226,8 @@ priv impl &preserve_ctxt { // // As an example, consider this scenario: // - // let mut x = @some(3); - // match *x { Some(y) {...} none {...} } + // let mut x = @Some(3); + // match *x { Some(y) {...} None {...} } // // Technically, the value `x` need only be rooted // in the `some` arm. However, we evaluate `x` in trans @@ -236,8 +236,8 @@ priv impl &preserve_ctxt { // // As a second example, consider *this* scenario: // - // let x = @mut @some(3); - // match x { @@some(y) {...} @@none {...} } + // let x = @mut @Some(3); + // match x { @@Some(y) {...} @@None {...} } // // Here again, `x` need only be rooted in the `some` arm. // In this case, the value which needs to be rooted is diff --git a/src/librustc/middle/trans/type_of.rs b/src/librustc/middle/trans/type_of.rs index c79cf45ec4bba..6a62e622526d7 100644 --- a/src/librustc/middle/trans/type_of.rs +++ b/src/librustc/middle/trans/type_of.rs @@ -100,8 +100,8 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef { // Replace any typedef'd types with their equivalent non-typedef // type. This ensures that all LLVM nominal types that contain // Rust types are defined as the same LLVM types. If we don't do - // this then, e.g. `option<{myfield: bool}>` would be a different - // type than `option`. + // this then, e.g. `Option<{myfield: bool}>` would be a different + // type than `Option`. let t_norm = ty::normalize_ty(cx.tcx, t); if t != t_norm { diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index aa5eec2b43ce2..3e9a9756a81c6 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -468,7 +468,7 @@ fn read_future(sock: &TcpSocket, timeout_msecs: uint) * } * // this callback is ran when a new connection arrives * {|new_conn, kill_ch| - * let cont_po = core::comm::port::>(); + * let cont_po = core::comm::port::>(); * let cont_ch = core::comm::chan(cont_po); * task::spawn {|| * let accept_result = net::tcp::accept(new_conn); @@ -484,9 +484,9 @@ fn read_future(sock: &TcpSocket, timeout_msecs: uint) * }; * match core::comm::recv(cont_po) { * // shut down listen() - * some(err_data) { core::comm::send(kill_chan, some(err_data)) } + * Some(err_data) { core::comm::send(kill_chan, Some(err_data)) } * // wait for next connection - * none {} + * None {} * } * }; * ~~~~~~~~~~~ @@ -593,7 +593,7 @@ pub fn accept(new_conn: TcpNewConnection) * callback's arguments are: * * `new_conn` - an opaque type that can be passed to * `net::tcp::accept` in order to be converted to a `tcp_socket`. - * * `kill_ch` - channel of type `core::comm::chan>`. + * * `kill_ch` - channel of type `core::comm::chan>`. * this channel can be used to send a message to cause `listen` to begin * closing the underlying libuv data structures. * diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs index 8c6d77c882838..ded0f316a150e 100644 --- a/src/libstd/rope.rs +++ b/src/libstd/rope.rs @@ -893,7 +893,7 @@ pub mod node { * # Return value * * * `option::None` if no transformation happened - * * `option::some(x)` otherwise, in which case `x` has the same contents + * * `option::Some(x)` otherwise, in which case `x` has the same contents * as `node` bot lower height and/or fragmentation. */ pub fn bal(node: @Node) -> Option<@Node> { diff --git a/src/libstd/timer.rs b/src/libstd/timer.rs index f8147c532e679..ce6231afa673d 100644 --- a/src/libstd/timer.rs +++ b/src/libstd/timer.rs @@ -100,11 +100,11 @@ pub fn sleep(iotask: IoTask, msecs: uint) { } /** - * Receive on a port for (up to) a specified time, then return an `option` + * Receive on a port for (up to) a specified time, then return an `Option` * * This call will block to receive on the provided port for up to the * specified timeout. Depending on whether the provided port receives in that - * time period, `recv_timeout` will return an `option` representing the + * time period, `recv_timeout` will return an `Option` representing the * result. * * # Arguments @@ -115,9 +115,9 @@ pub fn sleep(iotask: IoTask, msecs: uint) { * * # Returns * - * An `option` representing the outcome of the call. If the call `recv`'d + * An `Option` representing the outcome of the call. If the call `recv`'d * on the provided port in the allotted timeout period, then the result will - * be a `some(T)`. If not, then `none` will be returned. + * be a `Some(T)`. If not, then `None` will be returned. */ pub fn recv_timeout(iotask: IoTask, msecs: uint, From edc94f5c23a87e5f6d32b63779d60920ca70735d Mon Sep 17 00:00:00 2001 From: Tyler Bindon Date: Fri, 25 Jan 2013 12:31:45 -0700 Subject: [PATCH 3/6] Fix Option camel case in xfailed/ignored tests --- src/libstd/timer.rs | 2 +- src/test/compile-fail/issue-2354.rs | 6 +++--- src/test/run-pass-fulldeps/qquote.rs | 4 ++-- src/test/run-pass/bind-by-move.rs | 6 +++--- src/test/run-pass/class-impl-parameterized-trait.rs | 4 ++-- src/test/run-pass/class-implements-multiple-traits.rs | 8 ++++---- src/test/run-pass/class-trait-bounded-param.rs | 2 +- src/test/run-pass/issue-2869.rs | 8 ++++---- .../run-pass/region-return-interior-of-option-in-self.rs | 6 +++--- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/libstd/timer.rs b/src/libstd/timer.rs index ce6231afa673d..d0ca133b39e4a 100644 --- a/src/libstd/timer.rs +++ b/src/libstd/timer.rs @@ -255,7 +255,7 @@ mod test { }; match recv_timeout(hl_loop, 10u, test_po) { - some(val) => { + Some(val) => { assert val == expected; successes += 1; } diff --git a/src/test/compile-fail/issue-2354.rs b/src/test/compile-fail/issue-2354.rs index 30c6a6afdab0f..2505859a737a3 100644 --- a/src/test/compile-fail/issue-2354.rs +++ b/src/test/compile-fail/issue-2354.rs @@ -15,9 +15,9 @@ xfailed for now (see Issue #2354) */ fn foo() { //~ ERROR this open brace is not closed - match some(x) { - some(y) { fail; } - none { fail; } + match Some(x) { + Some(y) { fail; } + None { fail; } } fn bar() { diff --git a/src/test/run-pass-fulldeps/qquote.rs b/src/test/run-pass-fulldeps/qquote.rs index 4e4df552a2ecd..5a82d0104383b 100644 --- a/src/test/run-pass-fulldeps/qquote.rs +++ b/src/test/run-pass-fulldeps/qquote.rs @@ -69,8 +69,8 @@ fn main() { let stmt = quote_stmt!(let x = 20;); check_pp(ext_cx, *stmt, pprust::print_stmt, ~"let x = 20;"); - let pat = quote_pat!(some(_)); - check_pp(ext_cx, pat, pprust::print_refutable_pat, ~"some(_)"); + let pat = quote_pat!(Some(_)); + check_pp(ext_cx, pat, pprust::print_refutable_pat, ~"Some(_)"); } diff --git a/src/test/run-pass/bind-by-move.rs b/src/test/run-pass/bind-by-move.rs index 9c2a16e3e37e6..eda015cce1840 100644 --- a/src/test/run-pass/bind-by-move.rs +++ b/src/test/run-pass/bind-by-move.rs @@ -16,9 +16,9 @@ fn dispose(+_x: arc::ARC) unsafe { } fn main() { let p = arc::arc(true); - let x = some(p); + let x = Some(p); match move x { - some(move z) => { dispose(z); }, - none => fail + Some(move z) => { dispose(z); }, + None => fail } } diff --git a/src/test/run-pass/class-impl-parameterized-trait.rs b/src/test/run-pass/class-impl-parameterized-trait.rs index fdc01e2682003..0bf5b7de75d3c 100644 --- a/src/test/run-pass/class-impl-parameterized-trait.rs +++ b/src/test/run-pass/class-impl-parameterized-trait.rs @@ -55,8 +55,8 @@ class cat : map { fn contains_key(&&k: int) -> bool { k <= self.meows } fn get(&&k:int) -> bool { k <= self.meows } fn [](&&k:int) -> bool { k <= self.meows } - fn find(&&k:int) -> option { some(self.get(k)) } - fn remove(&&k:int) -> option { self.meows -= k; some(true) } + fn find(&&k:int) -> Option { Some(self.get(k)) } + fn remove(&&k:int) -> Option { self.meows -= k; Some(true) } fn each(f: fn(&&int, &&bool) -> bool) { let mut n = int::abs(self.meows); while n > 0 { diff --git a/src/test/run-pass/class-implements-multiple-traits.rs b/src/test/run-pass/class-implements-multiple-traits.rs index 813814d8b5663..f80e3956eda71 100644 --- a/src/test/run-pass/class-implements-multiple-traits.rs +++ b/src/test/run-pass/class-implements-multiple-traits.rs @@ -23,7 +23,7 @@ trait noisy { } trait scratchy { - fn scratch() -> option; + fn scratch() -> Option; } trait bitey { @@ -72,13 +72,13 @@ class cat : noisy, scratchy, bitey { fn speak() -> int { self.meow() as int } fn meow_count() -> uint { *self.meows } - fn scratch() -> option { + fn scratch() -> Option { let all = ~[chair, couch, bed]; log(error, self.scratched); - let mut rslt = none; + let mut rslt = None; for each(all) |thing| { if !self.scratched.contains(thing) { self.scratched.push(thing); - return some(thing); }} + return Some(thing); }} rslt } fn bite() -> body_part { diff --git a/src/test/run-pass/class-trait-bounded-param.rs b/src/test/run-pass/class-trait-bounded-param.rs index 7e70f91d54c39..b6e9d66ec7260 100644 --- a/src/test/run-pass/class-trait-bounded-param.rs +++ b/src/test/run-pass/class-trait-bounded-param.rs @@ -23,7 +23,7 @@ class keys> } fn each(blk: fn(K) -> bool) { self.map.each(|k, _v| blk(k) ) } - fn size_hint() -> option { some(self.map.size()) } + fn size_hint() -> Option { Some(self.map.size()) } fn eachi(blk: fn(uint, K) -> bool) { iter::eachi(self, blk) } } diff --git a/src/test/run-pass/issue-2869.rs b/src/test/run-pass/issue-2869.rs index 00933f19e4f7d..fddc41a376145 100644 --- a/src/test/run-pass/issue-2869.rs +++ b/src/test/run-pass/issue-2869.rs @@ -9,16 +9,16 @@ // except according to those terms. // xfail-test -enum pat { pat_ident(option) } +enum pat { pat_ident(Option) } fn f(pat: pat) -> bool { true } fn num_bindings(pat: pat) -> uint { match pat { pat_ident(_) if f(pat) { 0 } - pat_ident(none) { 1 } - pat_ident(some(sub)) { sub } + pat_ident(None) { 1 } + pat_ident(Some(sub)) { sub } } } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/run-pass/region-return-interior-of-option-in-self.rs b/src/test/run-pass/region-return-interior-of-option-in-self.rs index fef62e805bcd6..8ed85b957ee73 100644 --- a/src/test/run-pass/region-return-interior-of-option-in-self.rs +++ b/src/test/run-pass/region-return-interior-of-option-in-self.rs @@ -15,14 +15,14 @@ struct cell { } struct cells { - vals: ~[option>]; + vals: ~[Option>]; } impl &cells { fn get(idx: uint) -> &self/T { match self.vals[idx] { - some(ref v) => &v.value, - none => fail + Some(ref v) => &v.value, + None => fail } } } From 633b40f75da9dae81ae02c96b108622dc01946ba Mon Sep 17 00:00:00 2001 From: Tyler Bindon Date: Fri, 25 Jan 2013 12:32:06 -0700 Subject: [PATCH 4/6] Fix Option camel case in debug messages --- src/librustc/middle/typeck/infer/lattice.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc/middle/typeck/infer/lattice.rs b/src/librustc/middle/typeck/infer/lattice.rs index 9783aee0848c9..54638819f7ccc 100644 --- a/src/librustc/middle/typeck/infer/lattice.rs +++ b/src/librustc/middle/typeck/infer/lattice.rs @@ -492,13 +492,13 @@ fn lattice_var_and_t { // If a has an upper bound, return the LUB(a.ub, b) - debug!("bnd=some(%s)", a_bnd.inf_str(self.infcx())); + debug!("bnd=Some(%s)", a_bnd.inf_str(self.infcx())); lattice_dir_op(a_bnd, b) } None => { // If a does not have an upper bound, make b the upper bound of a // and then return b. - debug!("bnd=none"); + debug!("bnd=None"); let a_bounds = self.with_bnd(a_bounds, *b); do self.combine_fields().bnds(&a_bounds.lb, &a_bounds.ub).then { self.infcx().set(vb, a_id, Root(a_bounds, nde_a.rank)); From 5a69cd75fb9e45d1776b091e1dcf2f9827727e11 Mon Sep 17 00:00:00 2001 From: Tyler Bindon Date: Fri, 25 Jan 2013 12:32:52 -0700 Subject: [PATCH 5/6] Fix Option camel case in commented portion of test --- src/test/run-pass/issue-2718.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/run-pass/issue-2718.rs b/src/test/run-pass/issue-2718.rs index 871d349b24ba0..cc3b3d623322d 100644 --- a/src/test/run-pass/issue-2718.rs +++ b/src/test/run-pass/issue-2718.rs @@ -310,8 +310,8 @@ fn main() { // Commented out because of option::get error let (client_, server_) = pingpong::init(); - let client_ = ~mut some(client_); - let server_ = ~mut some(server_); + let client_ = ~mut Some(client_); + let server_ = ~mut Some(server_); task::spawn {|move client_| let mut client__ = none; From c89afc39718ed7b326f2e4f4ba4dd65a6d160bb3 Mon Sep 17 00:00:00 2001 From: Tyler Bindon Date: Fri, 25 Jan 2013 12:34:12 -0700 Subject: [PATCH 6/6] Fix Option camel case in a compile-fail test The compile fails for another reason, that triggers before the the failure for non-camel cased option, some or none undefined errors. --- src/test/compile-fail/pat-ref-enum.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/compile-fail/pat-ref-enum.rs b/src/test/compile-fail/pat-ref-enum.rs index 129fced62d5a0..f1f0637a31805 100644 --- a/src/test/compile-fail/pat-ref-enum.rs +++ b/src/test/compile-fail/pat-ref-enum.rs @@ -8,10 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn matcher(x: option) { +fn matcher(x: Option) { match x { - ref some(i) => {} //~ ERROR expected identifier, found enum pattern - none => {} + ref Some(i) => {} //~ ERROR expected identifier, found enum pattern + None => {} } }