From 3faa6762c18333154961029393fdc5e58636be66 Mon Sep 17 00:00:00 2001 From: Kevin Butler Date: Mon, 26 May 2014 01:12:43 +0100 Subject: [PATCH] lib{std,core,debug,rustuv,collections,native,regex}: Fix snake_case errors. A number of functions/methods have been moved or renamed to align better with rust standard conventions. std::reflect::MovePtrAdaptor => MovePtrAdaptor::new debug::reflect::MovePtrAdaptor => MovePtrAdaptor::new std::repr::ReprVisitor => ReprVisitor::new debug::repr::ReprVisitor => ReprVisitor::new rustuv::homing::HomingIO.go_to_IO_home => go_to_io_home [breaking-change] --- src/libcollections/smallintmap.rs | 14 ++++++------ src/libcore/char.rs | 3 ++- src/libcore/unicode.rs | 2 +- src/libdebug/reflect.rs | 9 ++++---- src/libdebug/repr.rs | 38 ++++++++++++------------------- src/libnative/io/process.rs | 3 ++- src/libregex/test/bench.rs | 1 + src/librustuv/homing.rs | 6 ++--- src/libstd/reflect.rs | 9 ++++---- src/libstd/repr.rs | 38 ++++++++++++------------------- 10 files changed, 54 insertions(+), 69 deletions(-) diff --git a/src/libcollections/smallintmap.rs b/src/libcollections/smallintmap.rs index 8e4e47405e71f..932011baa56f1 100644 --- a/src/libcollections/smallintmap.rs +++ b/src/libcollections/smallintmap.rs @@ -296,20 +296,20 @@ mod test_map { // given a new key, initialize it with this new count, // given an existing key, add more to its count - fn addMoreToCount(_k: uint, v0: uint, v1: uint) -> uint { + fn add_more_to_count(_k: uint, v0: uint, v1: uint) -> uint { v0 + v1 } - fn addMoreToCount_simple(v0: uint, v1: uint) -> uint { + fn add_more_to_count_simple(v0: uint, v1: uint) -> uint { v0 + v1 } // count integers - map.update(3, 1, addMoreToCount_simple); - map.update_with_key(9, 1, addMoreToCount); - map.update(3, 7, addMoreToCount_simple); - map.update_with_key(5, 3, addMoreToCount); - map.update_with_key(3, 2, addMoreToCount); + map.update(3, 1, add_more_to_count_simple); + map.update_with_key(9, 1, add_more_to_count); + map.update(3, 7, add_more_to_count_simple); + map.update_with_key(5, 3, add_more_to_count); + map.update_with_key(3, 2, add_more_to_count); // check the total counts assert_eq!(map.find(&3).unwrap(), &10); diff --git a/src/libcore/char.rs b/src/libcore/char.rs index 2d1cab5d84156..6b0f0b705612e 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -1,4 +1,4 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -23,6 +23,7 @@ //! however the converse is not always true due to the above range limits //! and, as such, should be performed via the `from_u32` function.. +#![allow(non_snake_case_functions)] use mem::transmute; use option::{None, Option, Some}; diff --git a/src/libcore/unicode.rs b/src/libcore/unicode.rs index 242672de2967a..c6fc5f16ed142 100644 --- a/src/libcore/unicode.rs +++ b/src/libcore/unicode.rs @@ -10,7 +10,7 @@ // NOTE: The following code was generated by "src/etc/unicode.py", do not edit directly -#![allow(missing_doc, non_uppercase_statics)] +#![allow(missing_doc, non_uppercase_statics, non_snake_case_functions)] fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool { diff --git a/src/libdebug/reflect.rs b/src/libdebug/reflect.rs index 367994466b21e..997d3427122e8 100644 --- a/src/libdebug/reflect.rs +++ b/src/libdebug/reflect.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -42,11 +42,12 @@ pub fn align(size: uint, align: uint) -> uint { pub struct MovePtrAdaptor { inner: V } -pub fn MovePtrAdaptor(v: V) -> MovePtrAdaptor { - MovePtrAdaptor { inner: v } -} impl MovePtrAdaptor { + pub fn new(v: V) -> MovePtrAdaptor { + MovePtrAdaptor { inner: v } + } + #[inline] pub fn bump(&mut self, sz: uint) { self.inner.move_ptr(|p| ((p as uint) + sz) as *u8) diff --git a/src/libdebug/repr.rs b/src/libdebug/repr.rs index 67eee6f2ecf0d..e6cc9785b44e7 100644 --- a/src/libdebug/repr.rs +++ b/src/libdebug/repr.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -99,17 +99,6 @@ pub struct ReprVisitor<'a> { last_err: Option, } -pub fn ReprVisitor<'a>(ptr: *u8, - writer: &'a mut io::Writer) -> ReprVisitor<'a> { - ReprVisitor { - ptr: ptr, - ptr_stk: vec!(), - var_stk: vec!(), - writer: writer, - last_err: None, - } -} - impl<'a> MovePtr for ReprVisitor<'a> { #[inline] fn move_ptr(&mut self, adjustment: |*u8| -> *u8) { @@ -125,6 +114,15 @@ impl<'a> MovePtr for ReprVisitor<'a> { impl<'a> ReprVisitor<'a> { // Various helpers for the TyVisitor impl + pub fn new(ptr: *u8, writer: &'a mut io::Writer) -> ReprVisitor<'a> { + ReprVisitor { + ptr: ptr, + ptr_stk: vec!(), + var_stk: vec!(), + writer: writer, + last_err: None, + } + } #[inline] pub fn get(&mut self, f: |&mut ReprVisitor, &T| -> bool) -> bool { @@ -141,16 +139,8 @@ impl<'a> ReprVisitor<'a> { #[inline] pub fn visit_ptr_inner(&mut self, ptr: *u8, inner: *TyDesc) -> bool { unsafe { - // This should call the constructor up above, but due to limiting - // issues we have to recreate it here. - let u = ReprVisitor { - ptr: ptr, - ptr_stk: vec!(), - var_stk: vec!(), - writer: mem::transmute_copy(&self.writer), - last_err: None, - }; - let mut v = reflect::MovePtrAdaptor(u); + let u = ReprVisitor::new(ptr, mem::transmute_copy(&self.writer)); + let mut v = reflect::MovePtrAdaptor::new(u); // Obviously this should not be a thing, but blame #8401 for now visit_tydesc(inner, &mut v as &mut TyVisitor); match v.unwrap().last_err { @@ -584,8 +574,8 @@ pub fn write_repr(writer: &mut io::Writer, object: &T) -> io::IoResult<()> { unsafe { let ptr = object as *T as *u8; let tydesc = get_tydesc::(); - let u = ReprVisitor(ptr, writer); - let mut v = reflect::MovePtrAdaptor(u); + let u = ReprVisitor::new(ptr, writer); + let mut v = reflect::MovePtrAdaptor::new(u); visit_tydesc(tydesc, &mut v as &mut TyVisitor); match v.unwrap().last_err { Some(e) => Err(e), diff --git a/src/libnative/io/process.rs b/src/libnative/io/process.rs index 5bee9489ca973..cddae53fa42f6 100644 --- a/src/libnative/io/process.rs +++ b/src/libnative/io/process.rs @@ -1,4 +1,4 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -758,6 +758,7 @@ fn free_handle(_handle: *()) { #[cfg(unix)] fn translate_status(status: c_int) -> p::ProcessExit { + #![allow(non_snake_case_functions)] #[cfg(target_os = "linux")] #[cfg(target_os = "android")] mod imp { diff --git a/src/libregex/test/bench.rs b/src/libregex/test/bench.rs index 7c806ece5c85b..0e4581a401e90 100644 --- a/src/libregex/test/bench.rs +++ b/src/libregex/test/bench.rs @@ -7,6 +7,7 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_snake_case_functions)] use std::rand::{Rng, task_rng}; use std::str; diff --git a/src/librustuv/homing.rs b/src/librustuv/homing.rs index b9025397b8d22..5bb9c70f04795 100644 --- a/src/librustuv/homing.rs +++ b/src/librustuv/homing.rs @@ -1,4 +1,4 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -88,7 +88,7 @@ pub trait HomingIO { /// This function will move tasks to run on their home I/O scheduler. Note /// that this function does *not* pin the task to the I/O scheduler, but /// rather it simply moves it to running on the I/O scheduler. - fn go_to_IO_home(&mut self) -> uint { + fn go_to_io_home(&mut self) -> uint { let _f = ForbidUnwind::new("going home"); let cur_loop_id = local_id(); @@ -118,7 +118,7 @@ pub trait HomingIO { /// move the local task to its I/O scheduler and then return an RAII wrapper /// which will return the task home. fn fire_homing_missile(&mut self) -> HomingMissile { - HomingMissile { io_home: self.go_to_IO_home() } + HomingMissile { io_home: self.go_to_io_home() } } } diff --git a/src/libstd/reflect.rs b/src/libstd/reflect.rs index 02535ccee516f..f21dcdf2a4690 100644 --- a/src/libstd/reflect.rs +++ b/src/libstd/reflect.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -42,11 +42,12 @@ pub fn align(size: uint, align: uint) -> uint { pub struct MovePtrAdaptor { inner: V } -pub fn MovePtrAdaptor(v: V) -> MovePtrAdaptor { - MovePtrAdaptor { inner: v } -} impl MovePtrAdaptor { + pub fn new(v: V) -> MovePtrAdaptor { + MovePtrAdaptor { inner: v } + } + #[inline] pub fn bump(&mut self, sz: uint) { self.inner.move_ptr(|p| ((p as uint) + sz) as *u8) diff --git a/src/libstd/repr.rs b/src/libstd/repr.rs index 969c20d8b55de..0621cbf35fe22 100644 --- a/src/libstd/repr.rs +++ b/src/libstd/repr.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -110,17 +110,6 @@ pub struct ReprVisitor<'a> { last_err: Option, } -pub fn ReprVisitor<'a>(ptr: *u8, - writer: &'a mut io::Writer) -> ReprVisitor<'a> { - ReprVisitor { - ptr: ptr, - ptr_stk: vec!(), - var_stk: vec!(), - writer: writer, - last_err: None, - } -} - impl<'a> MovePtr for ReprVisitor<'a> { #[inline] fn move_ptr(&mut self, adjustment: |*u8| -> *u8) { @@ -136,6 +125,15 @@ impl<'a> MovePtr for ReprVisitor<'a> { impl<'a> ReprVisitor<'a> { // Various helpers for the TyVisitor impl + pub fn new(ptr: *u8, writer: &'a mut io::Writer) -> ReprVisitor<'a> { + ReprVisitor { + ptr: ptr, + ptr_stk: vec!(), + var_stk: vec!(), + writer: writer, + last_err: None, + } + } #[inline] pub fn get(&mut self, f: |&mut ReprVisitor, &T| -> bool) -> bool { @@ -152,16 +150,8 @@ impl<'a> ReprVisitor<'a> { #[inline] pub fn visit_ptr_inner(&mut self, ptr: *u8, inner: *TyDesc) -> bool { unsafe { - // This should call the constructor up above, but due to limiting - // issues we have to recreate it here. - let u = ReprVisitor { - ptr: ptr, - ptr_stk: vec!(), - var_stk: vec!(), - writer: ::mem::transmute_copy(&self.writer), - last_err: None, - }; - let mut v = reflect::MovePtrAdaptor(u); + let u = ReprVisitor::new(ptr, ::mem::transmute_copy(&self.writer)); + let mut v = reflect::MovePtrAdaptor::new(u); // Obviously this should not be a thing, but blame #8401 for now visit_tydesc(inner, &mut v as &mut TyVisitor); match v.unwrap().last_err { @@ -592,8 +582,8 @@ pub fn write_repr(writer: &mut io::Writer, object: &T) -> io::IoResult<()> { unsafe { let ptr = object as *T as *u8; let tydesc = get_tydesc::(); - let u = ReprVisitor(ptr, writer); - let mut v = reflect::MovePtrAdaptor(u); + let u = ReprVisitor::new(ptr, writer); + let mut v = reflect::MovePtrAdaptor::new(u); visit_tydesc(tydesc, &mut v as &mut TyVisitor); match v.unwrap().last_err { Some(e) => Err(e),