From e1089fed5c7252b0ee764a2601b99638279515a8 Mon Sep 17 00:00:00 2001 From: thomas Date: Fri, 10 Jan 2014 19:16:00 +0100 Subject: [PATCH 1/2] Switched both non_camel_case_type and non_uppercase_constants lints to warn Updated copyright --- src/librustc/middle/lint.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs index 098e4154e1748..b442830e8f42e 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.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. // @@ -184,14 +184,14 @@ static lint_table: &'static [(&'static str, LintSpec)] = &[ LintSpec { lint: NonCamelCaseTypes, desc: "types, variants and traits should have camel case names", - default: allow + default: warn }), ("non_uppercase_statics", LintSpec { lint: NonUppercaseStatics, desc: "static constants should have uppercase identifiers", - default: allow + default: warn }), ("non_uppercase_pattern_statics", From 64ab8845f97c48482d64584ba9a1fe52627b6df4 Mon Sep 17 00:00:00 2001 From: thomas Date: Sat, 11 Jan 2014 12:18:24 +0100 Subject: [PATCH 2/2] Added changes of b64697d and dealt with rebasing issues --- src/compiletest/runtest.rs | 4 +- src/libextra/tempfile.rs | 4 +- src/libextra/uuid.rs | 4 +- src/libnative/io/file.rs | 29 +++++------ src/libnative/io/net.rs | 16 ++++-- src/libnative/io/process.rs | 2 +- src/librustc/back/link.rs | 4 +- src/librustc/middle/dataflow.rs | 4 +- src/librustdoc/html/render.rs | 4 +- src/librustpkg/lib.rs | 14 +++--- src/librustpkg/path_util.rs | 12 ++--- src/librustpkg/tests.rs | 54 ++++++++++----------- src/librustpkg/util.rs | 6 +-- src/librustuv/file.rs | 2 +- src/librustuv/lib.rs | 2 +- src/libstd/io/fs.rs | 46 +++++++++--------- src/libstd/io/mod.rs | 36 +++++++------- src/libstd/io/process.rs | 10 ++-- src/libstd/path/posix.rs | 60 +++++++++++------------ src/libstd/path/windows.rs | 45 ++++++++--------- src/libstd/rt/logging.rs | 4 +- src/libstd/rt/unwind.rs | 8 +-- src/libstd/run.rs | 6 +-- src/libsyntax/abi.rs | 32 ++++++------ src/libsyntax/ast_util.rs | 6 ++- src/libsyntax/diagnostic.rs | 2 + src/libsyntax/parse/parser.rs | 6 +-- src/libsyntax/parse/token.rs | 3 ++ src/libsyntax/print/pprust.rs | 70 +++++++++++++-------------- src/test/run-pass/glob-std.rs | 4 +- src/test/run-pass/rename-directory.rs | 6 +-- src/test/run-pass/tempfile.rs | 16 +++--- 32 files changed, 270 insertions(+), 251 deletions(-) diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 6b822fedda623..f9f5656d6cced 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.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. // @@ -720,7 +720,7 @@ fn compose_and_run_compiler( fn ensure_dir(path: &Path) { if path.is_dir() { return; } - fs::mkdir(path, io::UserRWX); + fs::mkdir(path, io::USER_RWX); } fn compose_and_run(config: &config, testfile: &Path, diff --git a/src/libextra/tempfile.rs b/src/libextra/tempfile.rs index c9ea556f23a50..1bf7b5c02f222 100644 --- a/src/libextra/tempfile.rs +++ b/src/libextra/tempfile.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. // @@ -38,7 +38,7 @@ impl TempDir { let mut r = rand::rng(); for _ in range(0u, 1000) { let p = tmpdir.join(r.gen_ascii_str(16) + suffix); - match io::result(|| fs::mkdir(&p, io::UserRWX)) { + match io::result(|| fs::mkdir(&p, io::USER_RWX)) { Err(..) => {} Ok(()) => return Some(TempDir { path: Some(p) }) } diff --git a/src/libextra/uuid.rs b/src/libextra/uuid.rs index 2c48a7a4d3e5d..7fbd2b7c78d42 100644 --- a/src/libextra/uuid.rs +++ b/src/libextra/uuid.rs @@ -154,7 +154,7 @@ impl ToStr for ParseError { } // Length of each hyphenated group in hex digits -static UuidGroupLens: [uint, ..5] = [8u, 4u, 4u, 4u, 12u]; +static UUID_GROUP_LENS: [uint, ..5] = [8u, 4u, 4u, 4u, 12u]; /// UUID support impl Uuid { @@ -395,7 +395,7 @@ impl Uuid { 5 => { // Ensure each group length matches the expected for (i, (&gl, &expected)) in - group_lens.iter().zip(UuidGroupLens.iter()).enumerate() { + group_lens.iter().zip(UUID_GROUP_LENS.iter()).enumerate() { if gl != expected { return Err(ErrorInvalidGroupLength(i, gl, expected)) } diff --git a/src/libnative/io/file.rs b/src/libnative/io/file.rs index 49290434785cf..7c80f8454d347 100644 --- a/src/libnative/io/file.rs +++ b/src/libnative/io/file.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. // @@ -27,8 +27,8 @@ use io::{IoResult, retry}; #[cfg(windows)] use std::str; pub fn keep_going(data: &[u8], f: |*u8, uint| -> i64) -> i64 { - #[cfg(windows)] static eintr: int = 0; // doesn't matter - #[cfg(not(windows))] static eintr: int = libc::EINTR as int; + #[cfg(windows)] static EINTR: int = 0; // doesn't matter + #[cfg(not(windows))] static EINTR: int = libc::EINTR as int; let origamt = data.len(); let mut data = data.as_ptr(); @@ -37,9 +37,9 @@ pub fn keep_going(data: &[u8], f: |*u8, uint| -> i64) -> i64 { let mut ret; loop { ret = f(data, amt); - if cfg!(windows) { break } // windows has no eintr - // if we get an eintr, then try again - if ret != -1 || os::errno() as int != eintr { break } + if cfg!(windows) { break } // windows has no EINTR + // if we get an EINTR, then try again + if ret != -1 || os::errno() as int != EINTR { break } } if ret == 0 { break @@ -53,6 +53,7 @@ pub fn keep_going(data: &[u8], f: |*u8, uint| -> i64) -> i64 { return (origamt - amt) as i64; } +#[allow(non_camel_case_types)] pub type fd_t = libc::c_int; pub struct FileDesc { @@ -77,12 +78,12 @@ impl FileDesc { // native::io wanting to use them is forced to have all the // rtio traits in scope pub fn inner_read(&mut self, buf: &mut [u8]) -> Result { - #[cfg(windows)] type rlen = libc::c_uint; - #[cfg(not(windows))] type rlen = libc::size_t; + #[cfg(windows)] type RLen = libc::c_uint; + #[cfg(not(windows))] type RLen = libc::size_t; let ret = retry(|| unsafe { libc::read(self.fd, buf.as_ptr() as *mut libc::c_void, - buf.len() as rlen) as libc::c_int + buf.len() as RLen) as libc::c_int }); if ret == 0 { Err(io::standard_error(io::EndOfFile)) @@ -93,11 +94,11 @@ impl FileDesc { } } pub fn inner_write(&mut self, buf: &[u8]) -> Result<(), IoError> { - #[cfg(windows)] type wlen = libc::c_uint; - #[cfg(not(windows))] type wlen = libc::size_t; + #[cfg(windows)] type WLen = libc::c_uint; + #[cfg(not(windows))] type WLen = libc::size_t; let ret = keep_going(buf, |buf, len| { unsafe { - libc::write(self.fd, buf as *libc::c_void, len as wlen) as i64 + libc::write(self.fd, buf as *libc::c_void, len as WLen) as i64 } }); if ret < 0 { @@ -782,7 +783,7 @@ fn mkstat(stat: &libc::stat, path: &CString) -> io::FileStat { path: Path::new(path), size: stat.st_size as u64, kind: kind, - perm: (stat.st_mode) as io::FilePermission & io::AllPermissions, + perm: (stat.st_mode) as io::FilePermission & io::ALL_PERMISSIONS, created: stat.st_ctime as u64, modified: stat.st_mtime as u64, accessed: stat.st_atime as u64, @@ -831,7 +832,7 @@ fn mkstat(stat: &libc::stat, path: &CString) -> io::FileStat { path: Path::new(path), size: stat.st_size as u64, kind: kind, - perm: (stat.st_mode) as io::FilePermission & io::AllPermissions, + perm: (stat.st_mode) as io::FilePermission & io::ALL_PERMISSIONS, created: mktime(stat.st_ctime as u64, stat.st_ctime_nsec as u64), modified: mktime(stat.st_mtime as u64, stat.st_mtime_nsec as u64), accessed: mktime(stat.st_atime as u64, stat.st_atime_nsec as u64), diff --git a/src/libnative/io/net.rs b/src/libnative/io/net.rs index adcd21f0ac4c5..7f48638da0a94 100644 --- a/src/libnative/io/net.rs +++ b/src/libnative/io/net.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. // @@ -23,7 +23,10 @@ use super::file::keep_going; // sockaddr and misc bindings //////////////////////////////////////////////////////////////////////////////// +#[allow(non_camel_case_types)] #[cfg(windows)] pub type sock_t = libc::SOCKET; + +#[allow(non_camel_case_types)] #[cfg(unix)] pub type sock_t = super::file::fd_t; pub fn htons(u: u16) -> u16 { @@ -270,8 +273,8 @@ impl TcpStream { } } -#[cfg(windows)] type wrlen = libc::c_int; -#[cfg(not(windows))] type wrlen = libc::size_t; +#[cfg(windows)] type WrLen = libc::c_int; +#[cfg(not(windows))] type WrLen = libc::size_t; impl rtio::RtioTcpStream for TcpStream { fn read(&mut self, buf: &mut [u8]) -> IoResult { @@ -279,7 +282,7 @@ impl rtio::RtioTcpStream for TcpStream { unsafe { libc::recv(self.fd, buf.as_ptr() as *mut libc::c_void, - buf.len() as wrlen, + buf.len() as WrLen, 0) as libc::c_int } }); @@ -296,7 +299,7 @@ impl rtio::RtioTcpStream for TcpStream { unsafe { libc::send(self.fd, buf as *mut libc::c_void, - len as wrlen, + len as WrLen, 0) as i64 } }); @@ -487,7 +490,10 @@ impl rtio::RtioSocket for UdpSocket { } } +#[allow(non_camel_case_types)] #[cfg(windows)] type msglen_t = libc::c_int; + +#[allow(non_camel_case_types)] #[cfg(unix)] type msglen_t = libc::size_t; impl rtio::RtioUdpSocket for UdpSocket { diff --git a/src/libnative/io/process.rs b/src/libnative/io/process.rs index 0569c45f6def9..ca560a3b4dc8a 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. // diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index 9e1e1f7bd342b..e3f5e34f859fe 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.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. // @@ -790,7 +790,7 @@ fn is_writeable(p: &Path) -> bool { match io::result(|| p.stat()) { Err(..) => true, - Ok(m) => m.perm & io::UserWrite == io::UserWrite + Ok(m) => m.perm & io::USER_WRITE == io::USER_WRITE } } diff --git a/src/librustc/middle/dataflow.rs b/src/librustc/middle/dataflow.rs index e79d1649099d9..55f9aa428f10e 100644 --- a/src/librustc/middle/dataflow.rs +++ b/src/librustc/middle/dataflow.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. // @@ -355,7 +355,7 @@ impl DataFlowContext { fn pretty_print_to(@self, wr: ~io::Writer, blk: &ast::Block) { let mut ps = pprust::rust_printer_annotated(wr, self.tcx.sess.intr(), self as @pprust::PpAnn); - pprust::cbox(&mut ps, pprust::indent_unit); + pprust::cbox(&mut ps, pprust::INDENT_UNIT); pprust::ibox(&mut ps, 0u); pprust::print_block(&mut ps, blk); pp::eof(&mut ps.s); diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 64328cdd7c3c6..bd16fceb5c6a5 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.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. // @@ -319,7 +319,7 @@ fn mkdir(path: &Path) { fail!() }).inside(|| { if !path.is_dir() { - fs::mkdir(path, io::UserRWX); + fs::mkdir(path, io::USER_RWX); } }) } diff --git a/src/librustpkg/lib.rs b/src/librustpkg/lib.rs index ac94c477e7836..d4f2d1c41790a 100644 --- a/src/librustpkg/lib.rs +++ b/src/librustpkg/lib.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. // @@ -694,7 +694,7 @@ impl CtxMethods for BuildContext { for exec in subex.iter() { debug!("Copying: {} -> {}", exec.display(), sub_target_ex.display()); - fs::mkdir_recursive(&sub_target_ex.dir_path(), io::UserRWX); + fs::mkdir_recursive(&sub_target_ex.dir_path(), io::USER_RWX); fs::copy(exec, &sub_target_ex); // FIXME (#9639): This needs to handle non-utf8 paths exe_thing.discover_output("binary", @@ -707,7 +707,7 @@ impl CtxMethods for BuildContext { .clone().expect(format!("I built {} but apparently \ didn't install it!", lib.display())); target_lib.set_filename(lib.filename().expect("weird target lib")); - fs::mkdir_recursive(&target_lib.dir_path(), io::UserRWX); + fs::mkdir_recursive(&target_lib.dir_path(), io::USER_RWX); fs::copy(lib, &target_lib); debug!("3. discovering output {}", target_lib.display()); exe_thing.discover_output("binary", @@ -748,10 +748,10 @@ impl CtxMethods for BuildContext { } fn init(&self) { - fs::mkdir_recursive(&Path::new("src"), io::UserRWX); - fs::mkdir_recursive(&Path::new("bin"), io::UserRWX); - fs::mkdir_recursive(&Path::new("lib"), io::UserRWX); - fs::mkdir_recursive(&Path::new("build"), io::UserRWX); + fs::mkdir_recursive(&Path::new("src"), io::USER_RWX); + fs::mkdir_recursive(&Path::new("bin"), io::USER_RWX); + fs::mkdir_recursive(&Path::new("lib"), io::USER_RWX); + fs::mkdir_recursive(&Path::new("build"), io::USER_RWX); } fn uninstall(&self, _id: &str, _vers: Option<~str>) { diff --git a/src/librustpkg/path_util.rs b/src/librustpkg/path_util.rs index 78ff748c3b927..f443842633337 100644 --- a/src/librustpkg/path_util.rs +++ b/src/librustpkg/path_util.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. // @@ -34,7 +34,7 @@ pub fn default_workspace() -> Path { } let result = p[0]; if !result.is_dir() { - fs::mkdir_recursive(&result, io::UserRWX); + fs::mkdir_recursive(&result, io::USER_RWX); } result } @@ -49,11 +49,11 @@ pub static U_RWX: i32 = (S_IRUSR | S_IWUSR | S_IXUSR) as i32; /// and executable by the user. Returns true iff creation /// succeeded. pub fn make_dir_rwx(p: &Path) -> bool { - io::result(|| fs::mkdir(p, io::UserRWX)).is_ok() + io::result(|| fs::mkdir(p, io::USER_RWX)).is_ok() } pub fn make_dir_rwx_recursive(p: &Path) -> bool { - io::result(|| fs::mkdir_recursive(p, io::UserRWX)).is_ok() + io::result(|| fs::mkdir_recursive(p, io::USER_RWX)).is_ok() } // n.b. The next three functions ignore the package version right @@ -363,7 +363,7 @@ fn target_file_in_workspace(crateid: &CrateId, workspace: &Path, (Install, Lib) => target_lib_dir(workspace), (Install, _) => target_bin_dir(workspace) }; - if io::result(|| fs::mkdir_recursive(&result, io::UserRWX)).is_err() { + if io::result(|| fs::mkdir_recursive(&result, io::USER_RWX)).is_err() { cond.raise((result.clone(), format!("target_file_in_workspace couldn't \ create the {} dir (crateid={}, workspace={}, what={:?}, where={:?}", subdir, crateid.to_str(), workspace.display(), what, where))); @@ -378,7 +378,7 @@ pub fn build_pkg_id_in_workspace(crateid: &CrateId, workspace: &Path) -> Path { result.push(&crateid.path); debug!("Creating build dir {} for package id {}", result.display(), crateid.to_str()); - fs::mkdir_recursive(&result, io::UserRWX); + fs::mkdir_recursive(&result, io::USER_RWX); return result; } diff --git a/src/librustpkg/tests.rs b/src/librustpkg/tests.rs index 0e78e907de052..6b112aa9b2a4c 100644 --- a/src/librustpkg/tests.rs +++ b/src/librustpkg/tests.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. // @@ -84,7 +84,7 @@ fn writeFile(file_path: &Path, contents: &str) { fn mk_emptier_workspace(tag: &str) -> TempDir { let workspace = TempDir::new(tag).expect("couldn't create temp dir"); let package_dir = workspace.path().join("src"); - fs::mkdir_recursive(&package_dir, io::UserRWX); + fs::mkdir_recursive(&package_dir, io::USER_RWX); workspace } @@ -99,7 +99,7 @@ fn mk_workspace(workspace: &Path, short_name: &Path, version: &Version) -> Path // FIXME (#9639): This needs to handle non-utf8 paths let package_dir = workspace.join_many([~"src", format!("{}-{}", short_name.as_str().unwrap(), version.to_str())]); - fs::mkdir_recursive(&package_dir, io::UserRWX); + fs::mkdir_recursive(&package_dir, io::USER_RWX); package_dir } @@ -115,7 +115,7 @@ fn mk_temp_workspace(short_name: &Path, version: &Version) -> (TempDir, Path) { package_dir.is_dir()); // Create main, lib, test, and bench files debug!("mk_workspace: creating {}", package_dir.display()); - fs::mkdir_recursive(&package_dir, io::UserRWX); + fs::mkdir_recursive(&package_dir, io::USER_RWX); debug!("Created {} and does it exist? {:?}", package_dir.display(), package_dir.is_dir()); // Create main, lib, test, and bench files @@ -154,7 +154,7 @@ fn init_git_repo(p: &Path) -> TempDir { let tmp = TempDir::new("git_local").expect("couldn't create temp dir"); let work_dir = tmp.path().join(p); let work_dir_for_opts = work_dir.clone(); - fs::mkdir_recursive(&work_dir, io::UserRWX); + fs::mkdir_recursive(&work_dir, io::USER_RWX); debug!("Running: git init in {}", work_dir.display()); run_git([~"init"], None, &work_dir_for_opts, format!("Couldn't initialize git repository in {}", work_dir.display())); @@ -190,12 +190,12 @@ fn add_git_tag(repo: &Path, tag: ~str) { fn is_rwx(p: &Path) -> bool { if !p.exists() { return false } - p.stat().perm & io::UserRWX == io::UserRWX + p.stat().perm & io::USER_RWX == io::USER_RWX } fn is_read_only(p: &Path) -> bool { if !p.exists() { return false } - p.stat().perm & io::UserRWX == io::UserRead + p.stat().perm & io::USER_RWX == io::USER_READ } fn test_sysroot() -> Path { @@ -305,7 +305,7 @@ fn create_local_package_in(crateid: &CrateId, pkgdir: &Path) -> Path { let package_dir = pkgdir.join_many([~"src", crateid.to_str()]); // Create main, lib, test, and bench files - fs::mkdir_recursive(&package_dir, io::UserRWX); + fs::mkdir_recursive(&package_dir, io::USER_RWX); debug!("Created {} and does it exist? {:?}", package_dir.display(), package_dir.is_dir()); // Create main, lib, test, and bench files @@ -759,7 +759,7 @@ fn test_package_version() { let repo = repo.path(); let repo_subdir = repo.join_many(["mockgithub.com", "catamorphism", "test_pkg_version"]); debug!("Writing files in: {}", repo_subdir.display()); - fs::mkdir_recursive(&repo_subdir, io::UserRWX); + fs::mkdir_recursive(&repo_subdir, io::USER_RWX); writeFile(&repo_subdir.join("main.rs"), "fn main() { let _x = (); }"); writeFile(&repo_subdir.join("lib.rs"), @@ -896,7 +896,7 @@ fn rustpkg_build_no_arg() { let tmp = TempDir::new("rustpkg_build_no_arg").expect("rustpkg_build_no_arg failed"); let tmp = tmp.path().join(".rust"); let package_dir = tmp.join_many(["src", "foo"]); - fs::mkdir_recursive(&package_dir, io::UserRWX); + fs::mkdir_recursive(&package_dir, io::USER_RWX); writeFile(&package_dir.join("main.rs"), "fn main() { let _x = (); }"); @@ -910,7 +910,7 @@ fn rustpkg_install_no_arg() { let tmp = TempDir::new("rustpkg_install_no_arg").expect("rustpkg_install_no_arg failed"); let tmp = tmp.path().join(".rust"); let package_dir = tmp.join_many(["src", "foo"]); - fs::mkdir_recursive(&package_dir, io::UserRWX); + fs::mkdir_recursive(&package_dir, io::USER_RWX); writeFile(&package_dir.join("lib.rs"), "fn main() { let _x = (); }"); debug!("install_no_arg: dir = {}", package_dir.display()); @@ -923,7 +923,7 @@ fn rustpkg_clean_no_arg() { let tmp = TempDir::new("rustpkg_clean_no_arg").expect("rustpkg_clean_no_arg failed"); let tmp = tmp.path().join(".rust"); let package_dir = tmp.join_many(["src", "foo"]); - fs::mkdir_recursive(&package_dir, io::UserRWX); + fs::mkdir_recursive(&package_dir, io::USER_RWX); writeFile(&package_dir.join("main.rs"), "fn main() { let _x = (); }"); @@ -958,9 +958,9 @@ fn rust_path_test() { fn rust_path_contents() { let dir = TempDir::new("rust_path").expect("rust_path_contents failed"); let abc = &dir.path().join_many(["A", "B", "C"]); - fs::mkdir_recursive(&abc.join(".rust"), io::UserRWX); - fs::mkdir_recursive(&abc.with_filename(".rust"), io::UserRWX); - fs::mkdir_recursive(&abc.dir_path().with_filename(".rust"), io::UserRWX); + fs::mkdir_recursive(&abc.join(".rust"), io::USER_RWX); + fs::mkdir_recursive(&abc.with_filename(".rust"), io::USER_RWX); + fs::mkdir_recursive(&abc.dir_path().with_filename(".rust"), io::USER_RWX); assert!(os::change_dir(abc)); let p = rust_path(); @@ -1234,7 +1234,7 @@ fn test_extern_mod() { let lib_depend_dir = TempDir::new("foo").expect("test_extern_mod"); let lib_depend_dir = lib_depend_dir.path(); let aux_dir = lib_depend_dir.join_many(["src", "mockgithub.com", "catamorphism", "test_pkg"]); - fs::mkdir_recursive(&aux_dir, io::UserRWX); + fs::mkdir_recursive(&aux_dir, io::USER_RWX); let aux_pkg_file = aux_dir.join("lib.rs"); writeFile(&aux_pkg_file, "pub mod bar { pub fn assert_true() { assert!(true); } }\n"); @@ -1283,7 +1283,7 @@ fn test_extern_mod_simpler() { let lib_depend_dir = TempDir::new("foo").expect("test_extern_mod_simpler"); let lib_depend_dir = lib_depend_dir.path(); let aux_dir = lib_depend_dir.join_many(["src", "rust-awesomeness"]); - fs::mkdir_recursive(&aux_dir, io::UserRWX); + fs::mkdir_recursive(&aux_dir, io::USER_RWX); let aux_pkg_file = aux_dir.join("lib.rs"); writeFile(&aux_pkg_file, "pub mod bar { pub fn assert_true() { assert!(true); } }\n"); @@ -1433,7 +1433,7 @@ fn rust_path_hack_cwd() { // Same as rust_path_hack_test, but the CWD is the dir to build out of let cwd = TempDir::new("foo").expect("rust_path_hack_cwd"); let cwd = cwd.path().join("foo"); - fs::mkdir_recursive(&cwd, io::UserRWX); + fs::mkdir_recursive(&cwd, io::USER_RWX); writeFile(&cwd.join("lib.rs"), "pub fn f() { }"); let dest_workspace = mk_empty_workspace(&Path::new("bar"), &NoVersion, "dest_workspace"); @@ -1453,7 +1453,7 @@ fn rust_path_hack_multi_path() { // Same as rust_path_hack_test, but with a more complex package ID let cwd = TempDir::new("pkg_files").expect("rust_path_hack_cwd"); let subdir = cwd.path().join_many(["foo", "bar", "quux"]); - fs::mkdir_recursive(&subdir, io::UserRWX); + fs::mkdir_recursive(&subdir, io::USER_RWX); writeFile(&subdir.join("lib.rs"), "pub fn f() { }"); let name = ~"foo/bar/quux"; @@ -1870,14 +1870,14 @@ fn crateid_pointing_to_subdir() { let workspace = workspace.path(); fs::mkdir_recursive(&workspace.join_many(["src", "mockgithub.com", "mozilla", "some_repo"]), - io::UserRWX); + io::USER_RWX); let foo_dir = workspace.join_many(["src", "mockgithub.com", "mozilla", "some_repo", "extras", "foo"]); let bar_dir = workspace.join_many(["src", "mockgithub.com", "mozilla", "some_repo", "extras", "bar"]); - fs::mkdir_recursive(&foo_dir, io::UserRWX); - fs::mkdir_recursive(&bar_dir, io::UserRWX); + fs::mkdir_recursive(&foo_dir, io::USER_RWX); + fs::mkdir_recursive(&bar_dir, io::USER_RWX); writeFile(&foo_dir.join("lib.rs"), "#[crate_id=\"mockgithub.com/mozilla/some_repo/extras/rust-foo#foo:0.0\"];" + "pub fn f() {}"); @@ -1887,7 +1887,7 @@ fn crateid_pointing_to_subdir() { debug!("Creating a file in {}", workspace.display()); let testpkg_dir = workspace.join_many(["src", "testpkg-0.0"]); - fs::mkdir_recursive(&testpkg_dir, io::UserRWX); + fs::mkdir_recursive(&testpkg_dir, io::USER_RWX); writeFile(&testpkg_dir.join("main.rs"), "extern mod foo = \"mockgithub.com/mozilla/some_repo/extras/foo\";\n @@ -1991,7 +1991,7 @@ fn test_dependencies_terminate() { let workspace = workspace.path(); let b_dir = workspace.join_many(["src", "b-0.0"]); let b_subdir = b_dir.join("test"); - fs::mkdir_recursive(&b_subdir, io::UserRWX); + fs::mkdir_recursive(&b_subdir, io::USER_RWX); writeFile(&b_subdir.join("test.rs"), "extern mod b; use b::f; #[test] fn g() { f() }"); command_line_test([~"install", ~"b"], workspace); @@ -2220,7 +2220,7 @@ fn test_installed_local_changes() { debug!("repo = {}", repo.display()); let repo_subdir = repo.join_many(["mockgithub.com", "catamorphism", "test-pkg"]); debug!("repo_subdir = {}", repo_subdir.display()); - fs::mkdir_recursive(&repo.join_many([".rust", "src"]), io::UserRWX); + fs::mkdir_recursive(&repo.join_many([".rust", "src"]), io::USER_RWX); writeFile(&repo_subdir.join("main.rs"), "fn main() { let _x = (); }"); @@ -2303,7 +2303,7 @@ fn find_sources_in_cwd() { let temp_dir = TempDir::new("sources").expect("find_sources_in_cwd failed"); let temp_dir = temp_dir.path(); let source_dir = temp_dir.join("foo"); - fs::mkdir_recursive(&source_dir, io::UserRWX); + fs::mkdir_recursive(&source_dir, io::USER_RWX); writeFile(&source_dir.join("main.rs"), r#"#[crate_id="rust-foo#foo:0.0"]; fn main() { let _x = (); }"#); command_line_test([~"install", ~"foo"], &source_dir); @@ -2442,5 +2442,5 @@ fn correct_error_dependency() { /// Returns true if p exists and is executable fn is_executable(p: &Path) -> bool { - p.exists() && p.stat().perm & io::UserExecute == io::UserExecute + p.exists() && p.stat().perm & io::USER_EXECUTE == io::USER_EXECUTE } diff --git a/src/librustpkg/util.rs b/src/librustpkg/util.rs index 4d8f5c668b74f..443b079384366 100644 --- a/src/librustpkg/util.rs +++ b/src/librustpkg/util.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. // @@ -179,7 +179,7 @@ pub fn compile_input(context: &BuildContext, let mut out_dir = target_build_dir(workspace); out_dir.push(&pkg_id.path); // Make the output directory if it doesn't exist already - fs::mkdir_recursive(&out_dir, io::UserRWX); + fs::mkdir_recursive(&out_dir, io::USER_RWX); let binary = os::args()[0].to_owned(); @@ -255,7 +255,7 @@ pub fn compile_input(context: &BuildContext, assert!(p.is_dir()) } else { - fs::mkdir_recursive(p, io::UserRWX); + fs::mkdir_recursive(p, io::USER_RWX); } } } diff --git a/src/librustuv/file.rs b/src/librustuv/file.rs index 82d0fd823a320..b11a8e04767cd 100644 --- a/src/librustuv/file.rs +++ b/src/librustuv/file.rs @@ -262,7 +262,7 @@ impl FsRequest { path: path, size: stat.st_size as u64, kind: kind, - perm: (stat.st_mode as io::FilePermission) & io::AllPermissions, + perm: (stat.st_mode as io::FilePermission) & io::ALL_PERMISSIONS, created: to_msec(stat.st_birthtim), modified: to_msec(stat.st_mtim), accessed: to_msec(stat.st_atim), diff --git a/src/librustuv/lib.rs b/src/librustuv/lib.rs index 96ac975d567bd..ae5b314147555 100644 --- a/src/librustuv/lib.rs +++ b/src/librustuv/lib.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. // diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs index aac565f2c45e9..161def29066d7 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/io/fs.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. // @@ -379,13 +379,15 @@ pub fn copy(from: &Path, to: &Path) { /// /// # Example /// +/// ```rust /// use std::io; /// use std::io::fs; /// -/// fs::chmod(&Path::new("file.txt"), io::UserFile); -/// fs::chmod(&Path::new("file.txt"), io::UserRead | io::UserWrite); -/// fs::chmod(&Path::new("dir"), io::UserDir); -/// fs::chmod(&Path::new("file.exe"), io::UserExec); +/// fs::chmod(&Path::new("file.txt"), io::USER_FILE); +/// fs::chmod(&Path::new("file.txt"), io::USER_READ | io::USER_WRITE); +/// fs::chmod(&Path::new("dir"), io::USER_DIR); +/// fs::chmod(&Path::new("file.exe"), io::USER_EXEC); +/// ``` /// /// # Errors /// @@ -737,7 +739,7 @@ mod test { use os; use rand; let ret = os::tmpdir().join(format!("rust-{}", rand::random::())); - io::fs::mkdir(&ret, io::UserRWX); + io::fs::mkdir(&ret, io::USER_RWX); TempDir(ret) } @@ -905,7 +907,7 @@ mod test { iotest!(fn file_test_stat_is_correct_on_is_dir() { let tmpdir = tmpdir(); let filename = &tmpdir.join("file_stat_correct_on_is_dir"); - mkdir(filename, io::UserRWX); + mkdir(filename, io::USER_RWX); let stat_res = filename.stat(); assert!(stat_res.kind == io::TypeDirectory); rmdir(filename); @@ -914,7 +916,7 @@ mod test { iotest!(fn file_test_fileinfo_false_when_checking_is_file_on_a_directory() { let tmpdir = tmpdir(); let dir = &tmpdir.join("fileinfo_false_on_dir"); - mkdir(dir, io::UserRWX); + mkdir(dir, io::USER_RWX); assert!(dir.is_file() == false); rmdir(dir); }) @@ -932,7 +934,7 @@ mod test { let tmpdir = tmpdir(); let dir = &tmpdir.join("before_and_after_dir"); assert!(!dir.exists()); - mkdir(dir, io::UserRWX); + mkdir(dir, io::USER_RWX); assert!(dir.exists()); assert!(dir.is_dir()); rmdir(dir); @@ -943,7 +945,7 @@ mod test { use std::str; let tmpdir = tmpdir(); let dir = &tmpdir.join("di_readdir"); - mkdir(dir, io::UserRWX); + mkdir(dir, io::USER_RWX); let prefix = "foo"; for n in range(0,3) { let f = dir.join(format!("{}.txt", n)); @@ -971,7 +973,7 @@ mod test { }) iotest!(fn recursive_mkdir_slash() { - mkdir_recursive(&Path::new("/"), io::UserRWX); + mkdir_recursive(&Path::new("/"), io::USER_RWX); }) iotest!(fn unicode_path_is_dir() { @@ -982,7 +984,7 @@ mod test { let mut dirpath = tmpdir.path().clone(); dirpath.push(format!("test-가一ー你好")); - mkdir(&dirpath, io::UserRWX); + mkdir(&dirpath, io::USER_RWX); assert!(dirpath.is_dir()); let mut filepath = dirpath; @@ -999,7 +1001,7 @@ mod test { let tmpdir = tmpdir(); let unicode = tmpdir.path(); let unicode = unicode.join(format!("test-각丁ー再见")); - mkdir(&unicode, io::UserRWX); + mkdir(&unicode, io::USER_RWX); assert!(unicode.exists()); assert!(!Path::new("test/unicode-bogus-path-각丁ー再见").exists()); }) @@ -1068,12 +1070,12 @@ mod test { let out = tmpdir.join("out.txt"); File::create(&input); - chmod(&input, io::UserRead); + chmod(&input, io::USER_READ); copy(&input, &out); - assert!(out.stat().perm & io::UserWrite == 0); + assert!(out.stat().perm & io::USER_WRITE == 0); - chmod(&input, io::UserFile); - chmod(&out, io::UserFile); + chmod(&input, io::USER_FILE); + chmod(&out, io::USER_FILE); }) #[cfg(not(windows))] // FIXME(#10264) operation not permitted? @@ -1138,16 +1140,16 @@ mod test { let file = tmpdir.join("in.txt"); File::create(&file); - assert!(stat(&file).perm & io::UserWrite == io::UserWrite); - chmod(&file, io::UserRead); - assert!(stat(&file).perm & io::UserWrite == 0); + assert!(stat(&file).perm & io::USER_WRITE == io::USER_WRITE); + chmod(&file, io::USER_READ); + assert!(stat(&file).perm & io::USER_WRITE == 0); - match io::result(|| chmod(&tmpdir.join("foo"), io::UserRWX)) { + match io::result(|| chmod(&tmpdir.join("foo"), io::USER_RWX)) { Ok(..) => fail!("wanted a failure"), Err(..) => {} } - chmod(&file, io::UserFile); + chmod(&file, io::USER_FILE); }) iotest!(fn sync_doesnt_kill_anything() { diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 871809805418d..3b4d1d56d4a5d 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.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. // @@ -1390,31 +1390,31 @@ pub struct UnstableFileStat { pub type FilePermission = u32; // Each permission bit -pub static UserRead: FilePermission = 0x100; -pub static UserWrite: FilePermission = 0x080; -pub static UserExecute: FilePermission = 0x040; -pub static GroupRead: FilePermission = 0x020; -pub static GroupWrite: FilePermission = 0x010; -pub static GroupExecute: FilePermission = 0x008; -pub static OtherRead: FilePermission = 0x004; -pub static OtherWrite: FilePermission = 0x002; -pub static OtherExecute: FilePermission = 0x001; +pub static USER_READ: FilePermission = 0x100; +pub static USER_WRITE: FilePermission = 0x080; +pub static USER_EXECUTE: FilePermission = 0x040; +pub static GROUP_READ: FilePermission = 0x020; +pub static GROUP_WRITE: FilePermission = 0x010; +pub static GROUP_EXECUTE: FilePermission = 0x008; +pub static OTHER_READ: FilePermission = 0x004; +pub static OTHER_WRITE: FilePermission = 0x002; +pub static OTHER_EXECUTE: FilePermission = 0x001; // Common combinations of these bits -pub static UserRWX: FilePermission = UserRead | UserWrite | UserExecute; -pub static GroupRWX: FilePermission = GroupRead | GroupWrite | GroupExecute; -pub static OtherRWX: FilePermission = OtherRead | OtherWrite | OtherExecute; +pub static USER_RWX: FilePermission = USER_READ | USER_WRITE | USER_EXECUTE; +pub static GROUP_RWX: FilePermission = GROUP_READ | GROUP_WRITE | GROUP_EXECUTE; +pub static OTHER_RWX: FilePermission = OTHER_READ | OTHER_WRITE | OTHER_EXECUTE; /// A set of permissions for user owned files, this is equivalent to 0644 on /// unix-like systems. -pub static UserFile: FilePermission = UserRead | UserWrite | GroupRead | OtherRead; +pub static USER_FILE: FilePermission = USER_READ | USER_WRITE | GROUP_READ | OTHER_READ; /// A set of permissions for user owned directories, this is equivalent to 0755 /// on unix-like systems. -pub static UserDir: FilePermission = UserRWX | GroupRead | GroupExecute | - OtherRead | OtherExecute; +pub static USER_DIR: FilePermission = USER_RWX | GROUP_READ | GROUP_EXECUTE | + OTHER_READ | OTHER_EXECUTE; /// A set of permissions for user owned executables, this is equivalent to 0755 /// on unix-like systems. -pub static UserExec: FilePermission = UserDir; +pub static USER_EXEC: FilePermission = USER_DIR; /// A mask for all possible permission bits -pub static AllPermissions: FilePermission = 0x1ff; +pub static ALL_PERMISSIONS: FilePermission = 0x1ff; diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs index 4c8a640a849c1..1db633a446fe1 100644 --- a/src/libstd/io/process.rs +++ b/src/libstd/io/process.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. // @@ -21,10 +21,10 @@ use fmt; // windows values don't matter as long as they're at least one of unix's // TERM/KILL/INT signals -#[cfg(windows)] pub static PleaseExitSignal: int = 15; -#[cfg(windows)] pub static MustDieSignal: int = 9; -#[cfg(not(windows))] pub static PleaseExitSignal: int = libc::SIGTERM as int; -#[cfg(not(windows))] pub static MustDieSignal: int = libc::SIGKILL as int; +#[cfg(windows)] pub static PLEASE_EXIT_SIGNAL: int = 15; +#[cfg(windows)] pub static MUST_DIE_SIGNAL: int = 9; +#[cfg(not(windows))] pub static PLEASE_EXIT_SIGNAL: int = libc::SIGTERM as int; +#[cfg(not(windows))] pub static MUST_DIE_SIGNAL: int = libc::SIGKILL as int; pub struct Process { priv handle: ~RtioProcess, diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs index 0a93f385a0632..3cc6d8d638a5a 100644 --- a/src/libstd/path/posix.rs +++ b/src/libstd/path/posix.rs @@ -45,19 +45,19 @@ pub struct Path { } /// The standard path separator character -pub static sep: char = '/'; -static sep_byte: u8 = sep as u8; +pub static SEP: char = '/'; +static SEP_BYTE: u8 = SEP as u8; /// Returns whether the given byte is a path separator #[inline] pub fn is_sep_byte(u: &u8) -> bool { - *u as char == sep + *u as char == SEP } /// Returns whether the given char is a path separator #[inline] pub fn is_sep(c: char) -> bool { - c == sep + c == SEP } impl Eq for Path { @@ -115,7 +115,7 @@ impl GenericPathUnsafe for Path { unsafe fn new_unchecked(path: T) -> Path { let path = Path::normalize(path.container_as_bytes()); assert!(!path.is_empty()); - let idx = path.rposition_elem(&sep_byte); + let idx = path.rposition_elem(&SEP_BYTE); Path{ repr: path, sepidx: idx } } @@ -124,8 +124,8 @@ impl GenericPathUnsafe for Path { match self.sepidx { None if bytes!("..") == self.repr => { let mut v = vec::with_capacity(3 + filename.len()); - v.push_all(dot_dot_static); - v.push(sep_byte); + v.push_all(DOT_DOT_STATIC); + v.push(SEP_BYTE); v.push_all(filename); self.repr = Path::normalize(v); } @@ -135,7 +135,7 @@ impl GenericPathUnsafe for Path { Some(idx) if self.repr.slice_from(idx+1) == bytes!("..") => { let mut v = vec::with_capacity(self.repr.len() + 1 + filename.len()); v.push_all(self.repr); - v.push(sep_byte); + v.push(SEP_BYTE); v.push_all(filename); self.repr = Path::normalize(v); } @@ -146,22 +146,22 @@ impl GenericPathUnsafe for Path { self.repr = Path::normalize(v); } } - self.sepidx = self.repr.rposition_elem(&sep_byte); + self.sepidx = self.repr.rposition_elem(&SEP_BYTE); } unsafe fn push_unchecked(&mut self, path: T) { let path = path.container_as_bytes(); if !path.is_empty() { - if path[0] == sep_byte { + if path[0] == SEP_BYTE { self.repr = Path::normalize(path); } else { let mut v = vec::with_capacity(self.repr.len() + path.len() + 1); v.push_all(self.repr); - v.push(sep_byte); + v.push(SEP_BYTE); v.push_all(path); self.repr = Path::normalize(v); } - self.sepidx = self.repr.rposition_elem(&sep_byte); + self.sepidx = self.repr.rposition_elem(&SEP_BYTE); } } } @@ -179,7 +179,7 @@ impl GenericPath for Path { fn dirname<'a>(&'a self) -> &'a [u8] { match self.sepidx { None if bytes!("..") == self.repr => self.repr.as_slice(), - None => dot_static, + None => DOT_STATIC, Some(0) => self.repr.slice_to(1), Some(idx) if self.repr.slice_from(idx+1) == bytes!("..") => self.repr.as_slice(), Some(idx) => self.repr.slice_to(idx) @@ -211,7 +211,7 @@ impl GenericPath for Path { } else { self.repr.truncate(idx); } - self.sepidx = self.repr.rposition_elem(&sep_byte); + self.sepidx = self.repr.rposition_elem(&SEP_BYTE); true } } @@ -227,7 +227,7 @@ impl GenericPath for Path { #[inline] fn is_absolute(&self) -> bool { - self.repr[0] == sep_byte + self.repr[0] == SEP_BYTE } fn is_ancestor_of(&self, other: &Path) -> bool { @@ -276,14 +276,14 @@ impl GenericPath for Path { comps.extend(&mut ita); break; } - (None, _) => comps.push(dot_dot_static), + (None, _) => comps.push(DOT_DOT_STATIC), (Some(a), Some(b)) if comps.is_empty() && a == b => (), (Some(a), Some(b)) if b == bytes!(".") => comps.push(a), (Some(_), Some(b)) if b == bytes!("..") => return None, (Some(a), Some(_)) => { - comps.push(dot_dot_static); + comps.push(DOT_DOT_STATIC); for _ in itb { - comps.push(dot_dot_static); + comps.push(DOT_DOT_STATIC); } comps.push(a); comps.extend(&mut ita); @@ -291,7 +291,7 @@ impl GenericPath for Path { } } } - Some(Path::new(comps.connect_vec(&sep_byte))) + Some(Path::new(comps.connect_vec(&SEP_BYTE))) } } @@ -333,14 +333,14 @@ impl Path { fn normalize+CopyableVector>(v: V) -> ~[u8] { // borrowck is being very picky let val = { - let is_abs = !v.as_slice().is_empty() && v.as_slice()[0] == sep_byte; + let is_abs = !v.as_slice().is_empty() && v.as_slice()[0] == SEP_BYTE; let v_ = if is_abs { v.as_slice().slice_from(1) } else { v.as_slice() }; let comps = normalize_helper(v_, is_abs); match comps { None => None, Some(comps) => { if is_abs && comps.is_empty() { - Some(~[sep_byte]) + Some(~[SEP_BYTE]) } else { let n = if is_abs { comps.len() } else { comps.len() - 1} + comps.iter().map(|v| v.len()).sum(); @@ -353,7 +353,7 @@ impl Path { } } for comp in it { - v.push(sep_byte); + v.push(SEP_BYTE); v.push_all(comp); } Some(v) @@ -371,8 +371,8 @@ impl Path { /// Does not distinguish between absolute and relative paths, e.g. /// /a/b/c and a/b/c yield the same set of components. /// A path of "/" yields no components. A path of "." yields one component. - pub fn components<'a>(&'a self) -> Components<'a> { - let v = if self.repr[0] == sep_byte { + pub fn components<'a>(&'a self) -> ComponentIter<'a> { + let v = if self.repr[0] == SEP_BYTE { self.repr.slice_from(1) } else { self.repr.as_slice() }; let mut ret = v.split(is_sep_byte); @@ -385,8 +385,8 @@ impl Path { /// Returns an iterator that yields each component of the path in reverse. /// See components() for details. - pub fn rev_components<'a>(&'a self) -> RevComponents<'a> { - let v = if self.repr[0] == sep_byte { + pub fn rev_components<'a>(&'a self) -> RevComponentIter<'a> { + let v = if self.repr[0] == SEP_BYTE { self.repr.slice_from(1) } else { self.repr.as_slice() }; let mut ret = v.rsplit(is_sep_byte); @@ -423,7 +423,7 @@ fn normalize_helper<'a>(v: &'a [u8], is_abs: bool) -> Option<~[&'a [u8]]> { else if comp == bytes!(".") { changed = true } else if comp == bytes!("..") { if is_abs && comps.is_empty() { changed = true } - else if comps.len() == n_up { comps.push(dot_dot_static); n_up += 1 } + else if comps.len() == n_up { comps.push(DOT_DOT_STATIC); n_up += 1 } else { comps.pop(); changed = true } } else { comps.push(comp) } } @@ -432,7 +432,7 @@ fn normalize_helper<'a>(v: &'a [u8], is_abs: bool) -> Option<~[&'a [u8]]> { if v == bytes!(".") { return None; } - comps.push(dot_static); + comps.push(DOT_STATIC); } Some(comps) } else { @@ -440,8 +440,8 @@ fn normalize_helper<'a>(v: &'a [u8], is_abs: bool) -> Option<~[&'a [u8]]> { } } -static dot_static: &'static [u8] = bytes!("."); -static dot_dot_static: &'static [u8] = bytes!(".."); +static DOT_STATIC: &'static [u8] = bytes!("."); +static DOT_DOT_STATIC: &'static [u8] = bytes!(".."); #[cfg(test)] mod tests { diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index a529aaf0a247b..d02e6b00242bc 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -183,7 +183,7 @@ impl GenericPathUnsafe for Path { None if ".." == self.repr => { let mut s = str::with_capacity(3 + filename.len()); s.push_str(".."); - s.push_char(sep); + s.push_char(SEP); s.push_str(filename); self.update_normalized(s); } @@ -193,7 +193,7 @@ impl GenericPathUnsafe for Path { Some((_,idxa,end)) if self.repr.slice(idxa,end) == ".." => { let mut s = str::with_capacity(end + 1 + filename.len()); s.push_str(self.repr.slice_to(end)); - s.push_char(sep); + s.push_char(SEP); s.push_str(filename); self.update_normalized(s); } @@ -206,7 +206,7 @@ impl GenericPathUnsafe for Path { Some((idxb,_,_)) => { let mut s = str::with_capacity(idxb + 1 + filename.len()); s.push_str(self.repr.slice_to(idxb)); - s.push_char(sep); + s.push_char(SEP); s.push_str(filename); self.update_normalized(s); } @@ -261,11 +261,12 @@ impl GenericPathUnsafe for Path { let mut s = str::with_capacity(me.repr.len() + 1 + pathlen); s.push_str(me.repr); let plen = me.prefix_len(); + // if me is "C:" we don't want to add a path separator match me.prefix { Some(DiskPrefix) if me.repr.len() == plen => (), - _ if !(me.repr.len() > plen && me.repr[me.repr.len()-1] == sep as u8) => { - s.push_char(sep); + _ if !(me.repr.len() > plen && me.repr[me.repr.len()-1] == SEP as u8) => { + s.push_char(SEP); } _ => () } @@ -460,7 +461,7 @@ impl GenericPath for Path { match self.prefix { Some(DiskPrefix) => { let rest = self.repr.slice_from(self.prefix_len()); - rest.len() > 0 && rest[0] == sep as u8 + rest.len() > 0 && rest[0] == SEP as u8 } Some(_) => true, None => false @@ -501,7 +502,7 @@ impl GenericPath for Path { fn path_relative_from(&self, base: &Path) -> Option { fn comp_requires_verbatim(s: &str) -> bool { - s == "." || s == ".." || s.contains_char(sep2) + s == "." || s == ".." || s.contains_char(SEP2) } if !self.equiv_prefix(base) { @@ -619,14 +620,14 @@ impl Path { let s = match self.prefix { Some(_) => { let plen = self.prefix_len(); - if self.repr.len() > plen && self.repr[plen] == sep as u8 { + if self.repr.len() > plen && self.repr[plen] == SEP as u8 { self.repr.slice_from(plen+1) } else { self.repr.slice_from(plen) } } - None if self.repr[0] == sep as u8 => self.repr.slice_from(1), + None if self.repr[0] == SEP as u8 => self.repr.slice_from(1), None => self.repr.as_slice() }; - let ret = s.split_terminator(sep).map(Some); + let ret = s.split_terminator(SEP).map(Some); ret } @@ -703,7 +704,7 @@ impl Path { Some(VerbatimUNCPrefix(x, 0)) if s.len() == 8 + x => { // the server component has no trailing '\' let mut s = s.into_owned(); - s.push_char(sep); + s.push_char(SEP); Some(s) } _ => None @@ -739,7 +740,7 @@ impl Path { if is_abs { // normalize C:/ to C:\ unsafe { - str::raw::as_owned_vec(&mut s)[2] = sep as u8; + str::raw::as_owned_vec(&mut s)[2] = SEP as u8; } } Some(s) @@ -761,7 +762,7 @@ impl Path { } } } else if is_abs && comps.is_empty() { - Some(str::from_char(sep)) + Some(str::from_char(SEP)) } else { let prefix_ = s.slice_to(prefix_len(prefix)); let n = prefix_.len() + @@ -781,7 +782,7 @@ impl Path { Some(UNCPrefix(a,b)) => { s.push_str("\\\\"); s.push_str(prefix_.slice(2, a+2)); - s.push_char(sep); + s.push_char(SEP); s.push_str(prefix_.slice(3+a, 3+a+b)); } Some(_) => s.push_str(prefix_), @@ -795,7 +796,7 @@ impl Path { } } for comp in it { - s.push_char(sep); + s.push_char(SEP); s.push_str(comp); } Some(s) @@ -837,7 +838,7 @@ impl Path { fn has_nonsemantic_trailing_slash(&self) -> bool { is_verbatim(self) && self.repr.len() > self.prefix_len()+1 && - self.repr[self.repr.len()-1] == sep as u8 + self.repr[self.repr.len()-1] == SEP as u8 } fn update_normalized(&mut self, s: S) { @@ -877,36 +878,36 @@ pub fn is_verbatim(path: &Path) -> bool { } /// The standard path separator character -pub static sep: char = '\\'; +pub static SEP: char = '\\'; /// The alternative path separator character -pub static sep2: char = '/'; +pub static SEP2: char = '/'; /// Returns whether the given char is a path separator. /// Allows both the primary separator '\' and the alternative separator '/'. #[inline] pub fn is_sep(c: char) -> bool { - c == sep || c == sep2 + c == SEP || c == SEP2 } /// Returns whether the given char is a path separator. /// Only allows the primary separator '\'; use is_sep to allow '/'. #[inline] pub fn is_sep_verbatim(c: char) -> bool { - c == sep + c == SEP } /// Returns whether the given byte is a path separator. /// Allows both the primary separator '\' and the alternative separator '/'. #[inline] pub fn is_sep_byte(u: &u8) -> bool { - *u as char == sep || *u as char == sep2 + *u as char == SEP || *u as char == SEP2 } /// Returns whether the given byte is a path separator. /// Only allows the primary separator '\'; use is_sep_byte to allow '/'. #[inline] pub fn is_sep_byte_verbatim(u: &u8) -> bool { - *u as char == sep + *u as char == SEP } /// Prefix types for Path diff --git a/src/libstd/rt/logging.rs b/src/libstd/rt/logging.rs index b86a9612d7061..c37885ab4647f 100644 --- a/src/libstd/rt/logging.rs +++ b/src/libstd/rt/logging.rs @@ -25,7 +25,7 @@ struct LogDirective { static MAX_LOG_LEVEL: u32 = 255; static DEFAULT_LOG_LEVEL: u32 = 1; -static log_level_names : &'static[&'static str] = &'static["error", "warn", "info", "debug"]; +static LOG_LEVEL_NAMES : &'static[&'static str] = &'static["error", "warn", "info", "debug"]; /// Parse an individual log level that is either a number or a symbolic log level fn parse_log_level(level: &str) -> Option { @@ -40,7 +40,7 @@ fn parse_log_level(level: &str) -> Option { } } _ => { - let position = log_level_names.iter().position(|&name| name == level); + let position = LOG_LEVEL_NAMES.iter().position(|&name| name == level); match position { Some(position) => { log_level = Some(::cmp::min(MAX_LOG_LEVEL, (position + 1) as u32)) diff --git a/src/libstd/rt/unwind.rs b/src/libstd/rt/unwind.rs index ffe254574eba3..ff0ef325bb569 100644 --- a/src/libstd/rt/unwind.rs +++ b/src/libstd/rt/unwind.rs @@ -123,15 +123,15 @@ mod libunwind { pub type _Unwind_Word = uintptr_t; #[cfg(not(target_arch = "arm"))] - pub static unwinder_private_data_size: int = 2; + pub static UNWINDER_PRIVATE_DATA_SIZE: int = 2; #[cfg(target_arch = "arm")] - pub static unwinder_private_data_size: int = 20; + pub static UNWINDER_PRIVATE_DATA_SIZE: int = 20; pub struct _Unwind_Exception { exception_class: _Unwind_Exception_Class, exception_cleanup: _Unwind_Exception_Cleanup_Fn, - private: [_Unwind_Word, ..unwinder_private_data_size], + private: [_Unwind_Word, ..UNWINDER_PRIVATE_DATA_SIZE], } pub enum _Unwind_Context {} @@ -212,7 +212,7 @@ impl Unwinder { let exception = ~uw::_Unwind_Exception { exception_class: rust_exception_class(), exception_cleanup: exception_cleanup, - private: [0, ..uw::unwinder_private_data_size], + private: [0, ..uw::UNWINDER_PRIVATE_DATA_SIZE], }; let error = uw::_Unwind_RaiseException(cast::transmute(exception)); rtabort!("Could not unwind stack, error = {}", error as int) diff --git a/src/libstd/run.rs b/src/libstd/run.rs index 3595a7d45aca2..d30932877a4b3 100644 --- a/src/libstd/run.rs +++ b/src/libstd/run.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. // @@ -263,7 +263,7 @@ impl Process { * TerminateProcess(..) will be called. */ pub fn destroy(&mut self) { - self.inner.signal(io::process::PleaseExitSignal); + self.inner.signal(io::process::PLEASE_EXIT_SIGNAL); self.finish(); } @@ -275,7 +275,7 @@ impl Process { * TerminateProcess(..) will be called. */ pub fn force_destroy(&mut self) { - self.inner.signal(io::process::MustDieSignal); + self.inner.signal(io::process::MUST_DIE_SIGNAL); self.finish(); } } diff --git a/src/libsyntax/abi.rs b/src/libsyntax/abi.rs index 9194acfcdec45..670e4468a60e1 100644 --- a/src/libsyntax/abi.rs +++ b/src/libsyntax/abi.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. // @@ -15,7 +15,7 @@ pub enum Os { OsWin32, OsMacos, OsLinux, OsAndroid, OsFreebsd, } #[deriving(Eq)] pub enum Abi { - // NB: This ordering MUST match the AbiDatas array below. + // NB: This ordering MUST match the ABI_DATAS array below. // (This is ensured by the test indices_are_correct().) // Single platform ABIs come first (`for_arch()` relies on this) @@ -36,7 +36,7 @@ pub enum Abi { #[deriving(Eq)] pub enum Architecture { // NB. You cannot change the ordering of these - // constants without adjusting IntelBits below. + // constants without adjusting INTEL_BITS below. // (This is ensured by the test indices_are_correct().) X86, X86_64, @@ -44,8 +44,8 @@ pub enum Architecture { Mips } -static IntelBits: u32 = (1 << (X86 as uint)) | (1 << (X86_64 as uint)); -static ArmBits: u32 = (1 << (Arm as uint)); +static INTEL_BITS: u32 = (1 << (X86 as uint)) | (1 << (X86_64 as uint)); +static ARM_BITS: u32 = (1 << (Arm as uint)); struct AbiData { abi: Abi, @@ -69,12 +69,12 @@ pub struct AbiSet { priv bits: u32 // each bit represents one of the abis below } -static AbiDatas: &'static [AbiData] = &[ +static ABI_DATAS: &'static [AbiData] = &[ // Platform-specific ABIs - AbiData {abi: Cdecl, name: "cdecl", abi_arch: Archs(IntelBits)}, - AbiData {abi: Stdcall, name: "stdcall", abi_arch: Archs(IntelBits)}, - AbiData {abi: Fastcall, name:"fastcall", abi_arch: Archs(IntelBits)}, - AbiData {abi: Aapcs, name: "aapcs", abi_arch: Archs(ArmBits)}, + AbiData {abi: Cdecl, name: "cdecl", abi_arch: Archs(INTEL_BITS)}, + AbiData {abi: Stdcall, name: "stdcall", abi_arch: Archs(INTEL_BITS)}, + AbiData {abi: Fastcall, name:"fastcall", abi_arch: Archs(INTEL_BITS)}, + AbiData {abi: Aapcs, name: "aapcs", abi_arch: Archs(ARM_BITS)}, AbiData {abi: Win64, name: "win64", abi_arch: Archs(1 << (X86_64 as uint))}, @@ -94,7 +94,7 @@ fn each_abi(op: |abi: Abi| -> bool) -> bool { * Iterates through each of the defined ABIs. */ - AbiDatas.iter().advance(|abi_data| op(abi_data.abi)) + ABI_DATAS.iter().advance(|abi_data| op(abi_data.abi)) } pub fn lookup(name: &str) -> Option { @@ -117,7 +117,7 @@ pub fn lookup(name: &str) -> Option { } pub fn all_names() -> ~[&'static str] { - AbiDatas.map(|d| d.name) + ABI_DATAS.map(|d| d.name) } impl Abi { @@ -128,7 +128,7 @@ impl Abi { #[inline] pub fn data(&self) -> &'static AbiData { - &AbiDatas[self.index()] + &ABI_DATAS[self.index()] } pub fn name(&self) -> &'static str { @@ -403,16 +403,16 @@ fn abi_to_str_rust() { #[test] fn indices_are_correct() { - for (i, abi_data) in AbiDatas.iter().enumerate() { + for (i, abi_data) in ABI_DATAS.iter().enumerate() { assert_eq!(i, abi_data.abi.index()); } let bits = 1 << (X86 as u32); let bits = bits | 1 << (X86_64 as u32); - assert_eq!(IntelBits, bits); + assert_eq!(INTEL_BITS, bits); let bits = 1 << (Arm as u32); - assert_eq!(ArmBits, bits); + assert_eq!(ARM_BITS, bits); } #[cfg(test)] diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 598e30957e4f2..733924b0bcfa2 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + +#[allow(non_uppercase_statics)]; + use ast::*; use ast; use ast_util; @@ -23,6 +26,7 @@ use std::u32; use std::local_data; use std::num; + pub fn path_name_i(idents: &[Ident]) -> ~str { // FIXME: Bad copies (#2543 -- same for everything else that says "bad") idents.map(|i| token::interner_get(i.name)).connect("::") @@ -321,7 +325,7 @@ pub fn operator_prec(op: ast::BinOp) -> uint { /// Precedence of the `as` operator, which is a binary operator /// not appearing in the prior table. -pub static as_prec: uint = 12u; +pub static AS_PREC: uint = 12u; pub fn empty_generics() -> Generics { Generics {lifetimes: opt_vec::Empty, diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 23d0f4585af29..5b0e6189cc549 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#[allow(non_uppercase_statics)]; + use codemap::{Pos, Span}; use codemap; diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index e79c845b24d48..acd97abca2944 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.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. // @@ -60,7 +60,7 @@ use ast::{ViewItem_, ViewItemExternMod, ViewItemUse}; use ast::{ViewPath, ViewPathGlob, ViewPathList, ViewPathSimple}; use ast::Visibility; use ast; -use ast_util::{as_prec, lit_is_str, operator_prec}; +use ast_util::{AS_PREC, lit_is_str, operator_prec}; use ast_util; use codemap::{Span, BytePos, Spanned, spanned, mk_sp}; use codemap; @@ -2392,7 +2392,7 @@ impl Parser { } } None => { - if as_prec > min_prec && self.eat_keyword(keywords::As) { + if AS_PREC > min_prec && self.eat_keyword(keywords::As) { let rhs = self.parse_ty(true); let _as = self.mk_expr(lhs.span.lo, rhs.span.hi, diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 42313e642838b..63830c6f0ad81 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#[allow(non_uppercase_statics)]; + use ast; use ast::{P, Name, Mrk}; use ast_util; @@ -19,6 +21,7 @@ use std::cast; use std::char; use std::local_data; + #[allow(non_camel_case_types)] #[deriving(Clone, Encodable, Decodable, Eq, IterBytes)] pub enum BinOp { diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index a6fceb086c919..12021541e1969 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.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. // @@ -92,7 +92,7 @@ pub fn rust_printer_annotated(writer: ~io::Writer, ann: @PpAnn) -> State { return State { - s: pp::mk_printer(writer, default_columns), + s: pp::mk_printer(writer, DEFAULT_COLUMNS), cm: None, intr: intr, comments: None, @@ -106,9 +106,9 @@ pub fn rust_printer_annotated(writer: ~io::Writer, }; } -pub static indent_unit: uint = 4u; +pub static INDENT_UNIT: uint = 4u; -pub static default_columns: uint = 78u; +pub static DEFAULT_COLUMNS: uint = 78u; // Requires you to pass an input filename and reader so that // it can scan the input text for comments and literals to @@ -128,7 +128,7 @@ pub fn print_crate(cm: @CodeMap, input ); let mut s = State { - s: pp::mk_printer(out, default_columns), + s: pp::mk_printer(out, DEFAULT_COLUMNS), cm: Some(cm), intr: intr, comments: Some(cmnts), @@ -216,7 +216,7 @@ pub fn block_to_str(blk: &ast::Block, intr: @IdentInterner) -> ~str { let wr = ~MemWriter::new(); let mut s = rust_printer(wr as ~io::Writer, intr); // containing cbox, will be closed by print-block at } - cbox(&mut s, indent_unit); + cbox(&mut s, INDENT_UNIT); // head-ibox, will be closed by print-block after { ibox(&mut s, 0u); print_block(&mut s, blk); @@ -267,7 +267,7 @@ pub fn pclose(s: &mut State) { word(&mut s.s, ")"); } pub fn head(s: &mut State, w: &str) { // outer-box is consistent - cbox(s, indent_unit); + cbox(s, INDENT_UNIT); // head-box is inconsistent ibox(s, w.len() + 1); // keyword that starts the head @@ -294,7 +294,7 @@ pub fn bclose_maybe_open (s: &mut State, span: codemap::Span, } } pub fn bclose(s: &mut State, span: codemap::Span) { - bclose_(s, span, indent_unit); + bclose_(s, span, INDENT_UNIT); } pub fn is_begin(s: &mut State) -> bool { @@ -559,7 +559,7 @@ pub fn print_item(s: &mut State, item: &ast::Item) { bclose(s, item.span); } ast::ItemTy(ty, ref params) => { - ibox(s, indent_unit); + ibox(s, INDENT_UNIT); ibox(s, 0u); word_nbsp(s, visibility_qualified(item.vis, "type")); print_ident(s, item.ident); @@ -641,7 +641,7 @@ pub fn print_item(s: &mut State, item: &ast::Item) { print_path(s, pth, false); word(&mut s.s, "! "); print_ident(s, item.ident); - cbox(s, indent_unit); + cbox(s, INDENT_UNIT); popen(s); print_tts(s, &(tts.as_slice())); pclose(s); @@ -676,7 +676,7 @@ pub fn print_variants(s: &mut State, space_if_not_bol(s); maybe_print_comment(s, v.span.lo); print_outer_attributes(s, v.node.attrs); - ibox(s, indent_unit); + ibox(s, INDENT_UNIT); print_variant(s, v); word(&mut s.s, ","); end(s); @@ -932,11 +932,11 @@ pub fn print_stmt(s: &mut State, st: &ast::Stmt) { } pub fn print_block(s: &mut State, blk: &ast::Block) { - print_possibly_embedded_block(s, blk, BlockNormal, indent_unit); + print_possibly_embedded_block(s, blk, BlockNormal, INDENT_UNIT); } pub fn print_block_unclosed(s: &mut State, blk: &ast::Block) { - print_possibly_embedded_block_(s, blk, BlockNormal, indent_unit, &[], + print_possibly_embedded_block_(s, blk, BlockNormal, INDENT_UNIT, &[], false); } @@ -947,7 +947,7 @@ pub fn print_block_unclosed_indent(s: &mut State, blk: &ast::Block, indented: ui pub fn print_block_with_attrs(s: &mut State, blk: &ast::Block, attrs: &[ast::Attribute]) { - print_possibly_embedded_block_(s, blk, BlockNormal, indent_unit, attrs, + print_possibly_embedded_block_(s, blk, BlockNormal, INDENT_UNIT, attrs, true); } @@ -1018,7 +1018,7 @@ pub fn print_if(s: &mut State, test: &ast::Expr, blk: &ast::Block, match _else.node { // "another else-if" ast::ExprIf(i, t, e) => { - cbox(s, indent_unit - 1u); + cbox(s, INDENT_UNIT - 1u); ibox(s, 0u); word(&mut s.s, " else if "); print_expr(s, i); @@ -1028,7 +1028,7 @@ pub fn print_if(s: &mut State, test: &ast::Expr, blk: &ast::Block, } // "final else" ast::ExprBlock(b) => { - cbox(s, indent_unit - 1u); + cbox(s, INDENT_UNIT - 1u); ibox(s, 0u); word(&mut s.s, " else "); print_block(s, b); @@ -1129,7 +1129,7 @@ pub fn print_call_post(s: &mut State, pub fn print_expr(s: &mut State, expr: &ast::Expr) { fn print_field(s: &mut State, field: &ast::Field) { - ibox(s, indent_unit); + ibox(s, INDENT_UNIT); print_ident(s, field.ident.node); word_space(s, ":"); print_expr(s, field.expr); @@ -1138,7 +1138,7 @@ pub fn print_expr(s: &mut State, expr: &ast::Expr) { fn get_span(field: &ast::Field) -> codemap::Span { return field.span; } maybe_print_comment(s, expr.span.lo); - ibox(s, indent_unit); + ibox(s, INDENT_UNIT); { let ann_node = NodeExpr(s, expr); s.ann.pre(ann_node); @@ -1156,7 +1156,7 @@ pub fn print_expr(s: &mut State, expr: &ast::Expr) { print_expr(s, e); } ast::ExprVec(ref exprs, mutbl) => { - ibox(s, indent_unit); + ibox(s, INDENT_UNIT); word(&mut s.s, "["); if mutbl == ast::MutMutable { word(&mut s.s, "mut"); @@ -1168,7 +1168,7 @@ pub fn print_expr(s: &mut State, expr: &ast::Expr) { } ast::ExprRepeat(element, count, mutbl) => { - ibox(s, indent_unit); + ibox(s, INDENT_UNIT); word(&mut s.s, "["); if mutbl == ast::MutMutable { word(&mut s.s, "mut"); @@ -1188,7 +1188,7 @@ pub fn print_expr(s: &mut State, expr: &ast::Expr) { commasep_cmnt(s, Consistent, (*fields), print_field, get_span); match wth { Some(expr) => { - ibox(s, indent_unit); + ibox(s, INDENT_UNIT); word(&mut s.s, ","); space(&mut s.s); word(&mut s.s, ".."); @@ -1287,7 +1287,7 @@ pub fn print_expr(s: &mut State, expr: &ast::Expr) { print_block(s, blk); } ast::ExprMatch(expr, ref arms) => { - cbox(s, indent_unit); + cbox(s, INDENT_UNIT); ibox(s, 4); word_nbsp(s, "match"); print_expr(s, expr); @@ -1296,7 +1296,7 @@ pub fn print_expr(s: &mut State, expr: &ast::Expr) { let len = arms.len(); for (i, arm) in arms.iter().enumerate() { space(&mut s.s); - cbox(s, indent_unit); + cbox(s, INDENT_UNIT); ibox(s, 0u); let mut first = true; for p in arm.pats.iter() { @@ -1329,7 +1329,7 @@ pub fn print_expr(s: &mut State, expr: &ast::Expr) { ast::ExprBlock(blk) => { // the block will close the pattern's ibox print_block_unclosed_indent( - s, blk, indent_unit); + s, blk, INDENT_UNIT); } _ => { end(s); // close the ibox for the pattern @@ -1346,10 +1346,10 @@ pub fn print_expr(s: &mut State, expr: &ast::Expr) { } } else { // the block will close the pattern's ibox - print_block_unclosed_indent(s, arm.body, indent_unit); + print_block_unclosed_indent(s, arm.body, INDENT_UNIT); } } - bclose_(s, expr.span, indent_unit); + bclose_(s, expr.span, INDENT_UNIT); } ast::ExprFnBlock(decl, body) => { // in do/for blocks we don't want to show an empty @@ -1410,7 +1410,7 @@ pub fn print_expr(s: &mut State, expr: &ast::Expr) { } ast::ExprBlock(blk) => { // containing cbox, will be closed by print-block at } - cbox(s, indent_unit); + cbox(s, INDENT_UNIT); // head-box, will be closed by print-block after { ibox(s, 0u); print_block(s, blk); @@ -1531,11 +1531,11 @@ pub fn print_decl(s: &mut State, decl: &ast::Decl) { match decl.node { ast::DeclLocal(ref loc) => { space_if_not_bol(s); - ibox(s, indent_unit); + ibox(s, INDENT_UNIT); word_nbsp(s, "let"); fn print_local(s: &mut State, loc: &ast::Local) { - ibox(s, indent_unit); + ibox(s, INDENT_UNIT); print_local_decl(s, loc); end(s); match loc.init { @@ -1685,7 +1685,7 @@ pub fn print_pat(s: &mut State, pat: &ast::Pat) { print_path(s, path, true); word(&mut s.s, "{"); fn print_field(s: &mut State, f: &ast::FieldPat) { - cbox(s, indent_unit); + cbox(s, INDENT_UNIT); print_ident(s, f.ident); word_space(s, ":"); print_pat(s, f.pat); @@ -1922,7 +1922,7 @@ pub fn print_generics(s: &mut State, generics: &ast::Generics) { } pub fn print_meta_item(s: &mut State, item: &ast::MetaItem) { - ibox(s, indent_unit); + ibox(s, INDENT_UNIT); match item.node { ast::MetaWord(name) => word(&mut s.s, name), ast::MetaNameValue(name, value) => { @@ -2019,7 +2019,7 @@ pub fn print_mt(s: &mut State, mt: &ast::MutTy) { } pub fn print_arg(s: &mut State, input: &ast::Arg) { - ibox(s, indent_unit); + ibox(s, INDENT_UNIT); match input.ty.node { ast::TyInfer => print_pat(s, input.pat), _ => { @@ -2053,7 +2053,7 @@ pub fn print_ty_fn(s: &mut State, opt_bounds: &Option>, generics: Option<&ast::Generics>, opt_explicit_self: Option) { - ibox(s, indent_unit); + ibox(s, INDENT_UNIT); // Duplicates the logic in `print_fn_header_info()`. This is because that // function prints the sigil in the wrong place. That should be fixed. @@ -2120,7 +2120,7 @@ pub fn print_ty_fn(s: &mut State, ast::TyNil => {} _ => { space_if_not_bol(s); - ibox(s, indent_unit); + ibox(s, INDENT_UNIT); word_space(s, "->"); if decl.cf == ast::NoReturn { word_nbsp(s, "!"); } else { print_type(s, decl.output); } @@ -2216,7 +2216,7 @@ pub fn print_literal(s: &mut State, lit: &ast::Lit) { if val { word(&mut s.s, "true"); } else { word(&mut s.s, "false"); } } ast::LitBinary(arr) => { - ibox(s, indent_unit); + ibox(s, INDENT_UNIT); word(&mut s.s, "["); commasep_cmnt(s, Inconsistent, arr, |s, u| word(&mut s.s, format!("{}", *u)), |_| lit.span); diff --git a/src/test/run-pass/glob-std.rs b/src/test/run-pass/glob-std.rs index 655bc7771938f..38a53bb28abfd 100644 --- a/src/test/run-pass/glob-std.rs +++ b/src/test/run-pass/glob-std.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. // @@ -22,7 +22,7 @@ use std::io; pub fn main() { fn mk_file(path: &str, directory: bool) { if directory { - io::fs::mkdir(&Path::new(path), io::UserRWX); + io::fs::mkdir(&Path::new(path), io::USER_RWX); } else { io::File::create(&Path::new(path)); } diff --git a/src/test/run-pass/rename-directory.rs b/src/test/run-pass/rename-directory.rs index 1e5dfe21cbe88..19935b9af2707 100644 --- a/src/test/run-pass/rename-directory.rs +++ b/src/test/run-pass/rename-directory.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. // @@ -27,7 +27,7 @@ fn rename_directory() { let tmpdir = TempDir::new("rename_directory").expect("rename_directory failed"); let tmpdir = tmpdir.path(); let old_path = tmpdir.join_many(["foo", "bar", "baz"]); - fs::mkdir_recursive(&old_path, io::UserRWX); + fs::mkdir_recursive(&old_path, io::USER_RWX); let test_file = &old_path.join("temp.txt"); /* Write the temp input file */ @@ -48,7 +48,7 @@ fn rename_directory() { assert_eq!(libc::fclose(ostream), (0u as libc::c_int)); let new_path = tmpdir.join_many(["quux", "blat"]); - fs::mkdir_recursive(&new_path, io::UserRWX); + fs::mkdir_recursive(&new_path, io::USER_RWX); fs::rename(&old_path, &new_path.join("newdir")); assert!(new_path.join("newdir").is_dir()); assert!(new_path.join_many(["newdir", "temp.txt"]).exists()); diff --git a/src/test/run-pass/tempfile.rs b/src/test/run-pass/tempfile.rs index eb055342acd24..7752199bc9ff1 100644 --- a/src/test/run-pass/tempfile.rs +++ b/src/test/run-pass/tempfile.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. // @@ -85,17 +85,17 @@ fn recursive_mkdir_rel() { let cwd = os::getcwd(); debug!("recursive_mkdir_rel: Making: {} in cwd {} [{:?}]", path.display(), cwd.display(), path.exists()); - fs::mkdir_recursive(&path, io::UserRWX); + fs::mkdir_recursive(&path, io::USER_RWX); assert!(path.is_dir()); - fs::mkdir_recursive(&path, io::UserRWX); + fs::mkdir_recursive(&path, io::USER_RWX); assert!(path.is_dir()); } fn recursive_mkdir_dot() { let dot = Path::new("."); - fs::mkdir_recursive(&dot, io::UserRWX); + fs::mkdir_recursive(&dot, io::USER_RWX); let dotdot = Path::new(".."); - fs::mkdir_recursive(&dotdot, io::UserRWX); + fs::mkdir_recursive(&dotdot, io::USER_RWX); } fn recursive_mkdir_rel_2() { @@ -103,20 +103,20 @@ fn recursive_mkdir_rel_2() { let cwd = os::getcwd(); debug!("recursive_mkdir_rel_2: Making: {} in cwd {} [{:?}]", path.display(), cwd.display(), path.exists()); - fs::mkdir_recursive(&path, io::UserRWX); + fs::mkdir_recursive(&path, io::USER_RWX); assert!(path.is_dir()); assert!(path.dir_path().is_dir()); let path2 = Path::new("quux/blat"); debug!("recursive_mkdir_rel_2: Making: {} in cwd {}", path2.display(), cwd.display()); - fs::mkdir_recursive(&path2, io::UserRWX); + fs::mkdir_recursive(&path2, io::USER_RWX); assert!(path2.is_dir()); assert!(path2.dir_path().is_dir()); } // Ideally this would be in core, but needs TempFile pub fn test_rmdir_recursive_ok() { - let rwx = io::UserRWX; + let rwx = io::USER_RWX; let tmpdir = TempDir::new("test").expect("test_rmdir_recursive_ok: \ couldn't create temp dir");