Skip to content

Remove the #[allow(non_uppercase_statics)] attribute from inside bitflags! #17781

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 6, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ fn compose_and_run_compiler(

fn ensure_dir(path: &Path) {
if path.is_dir() { return; }
fs::mkdir(path, io::UserRWX).unwrap();
fs::mkdir(path, io::USER_RWX).unwrap();
}

fn compose_and_run(config: &Config, testfile: &Path,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ pub fn invalid_output_for_target(sess: &Session,
fn is_writeable(p: &Path) -> bool {
match p.stat() {
Err(..) => true,
Ok(m) => m.perm & io::UserWrite == io::UserWrite
Ok(m) => m.perm & io::USER_WRITE == io::USER_WRITE
}
}

Expand Down Expand Up @@ -1322,7 +1322,7 @@ fn add_upstream_rust_crates(cmd: &mut Command, sess: &Session,
// Fix up permissions of the copy, as fs::copy() preserves
// permissions, but the original file may have been installed
// by a package manager and may be read-only.
match fs::chmod(&dst, io::UserRead | io::UserWrite) {
match fs::chmod(&dst, io::USER_READ | io::USER_WRITE) {
Ok(..) => {}
Err(e) => {
sess.err(format!("failed to chmod {} when preparing \
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/save/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1467,7 +1467,7 @@ pub fn process_crate(sess: &Session,
},
};

match fs::mkdir_recursive(&root_path, io::UserRWX) {
match fs::mkdir_recursive(&root_path, io::USER_RWX) {
Err(e) => sess.err(format!("Could not create directory {}: {}",
root_path.display(), e).as_slice()),
_ => (),
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_back/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ mod test {
let linkdir = tmpdir.join("test3");

File::create(&file).unwrap();
mkdir(&dir, io::UserRWX).unwrap();
mkdir(&dir, io::USER_RWX).unwrap();
symlink(&file, &link).unwrap();
symlink(&dir, &linkdir).unwrap();

Expand All @@ -91,8 +91,8 @@ mod test {
let e = d.join("e");
let f = a.join("f");

mkdir_recursive(&b, io::UserRWX).unwrap();
mkdir_recursive(&d, io::UserRWX).unwrap();
mkdir_recursive(&b, io::USER_RWX).unwrap();
mkdir_recursive(&d, io::USER_RWX).unwrap();
File::create(&f).unwrap();
symlink(&Path::new("../d/e"), &c).unwrap();
symlink(&Path::new("../f"), &e).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ fn write(dst: Path, contents: &[u8]) -> io::IoResult<()> {
/// skipping if the directory already exists.
fn mkdir(path: &Path) -> io::IoResult<()> {
if !path.exists() {
fs::mkdir(path, io::UserRWX)
fs::mkdir(path, io::USER_RWX)
} else {
Ok(())
}
Expand Down
41 changes: 18 additions & 23 deletions src/libstd/bitflags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@
/// ```{.rust}
/// bitflags! {
/// flags Flags: u32 {
/// static FlagA = 0x00000001,
/// static FlagB = 0x00000010,
/// static FlagC = 0x00000100,
/// static FlagABC = FlagA.bits
/// | FlagB.bits
/// | FlagC.bits,
/// static FLAG_A = 0x00000001,
/// static FLAG_B = 0x00000010,
/// static FLAG_C = 0x00000100,
/// static FLAG_ABC = FLAG_A.bits
/// | FLAG_B.bits
/// | FLAG_C.bits,
/// }
/// }
///
/// fn main() {
/// let e1 = FlagA | FlagC;
/// let e2 = FlagB | FlagC;
/// assert!((e1 | e2) == FlagABC); // union
/// assert!((e1 & e2) == FlagC); // intersection
/// assert!((e1 - e2) == FlagA); // set difference
/// assert!(!e2 == FlagA); // set complement
/// let e1 = FLAG_A | FLAG_C;
/// let e2 = FLAG_B | FLAG_C;
/// assert!((e1 | e2) == FLAG_ABC); // union
/// assert!((e1 & e2) == FLAG_C); // intersection
/// assert!((e1 - e2) == FLAG_A); // set difference
/// assert!(!e2 == FLAG_A); // set complement
/// }
/// ```
///
Expand All @@ -50,8 +50,8 @@
///
/// bitflags! {
/// flags Flags: u32 {
/// static FlagA = 0x00000001,
/// static FlagB = 0x00000010,
/// static FLAG_A = 0x00000001,
/// static FLAG_B = 0x00000010,
/// }
/// }
///
Expand All @@ -69,7 +69,7 @@
/// }
///
/// fn main() {
/// let mut flags = FlagA | FlagB;
/// let mut flags = FLAG_A | FLAG_B;
/// flags.clear();
/// assert!(flags.is_empty());
/// assert_eq!(format!("{}", flags).as_slice(), "hi!");
Expand Down Expand Up @@ -123,10 +123,7 @@ macro_rules! bitflags {
bits: $T,
}

$(
#[allow(non_uppercase_statics)]
$(#[$Flag_attr])* pub static $Flag: $BitFlags = $BitFlags { bits: $value };
)+
$($(#[$Flag_attr])* pub static $Flag: $BitFlags = $BitFlags { bits: $value };)+

impl $BitFlags {
/// Returns an empty set of flags.
Expand Down Expand Up @@ -243,16 +240,14 @@ macro_rules! bitflags {
bitflags! {
$(#[$attr])*
flags $BitFlags: $T {
$(
#[allow(non_uppercase_statics)]
$(#[$Flag_attr])* static $Flag = $value
),+
$($(#[$Flag_attr])* static $Flag = $value),+
}
}
};
}

#[cfg(test)]
#[allow(non_uppercase_statics)]
mod tests {
use hash;
use option::{Some, None};
Expand Down
66 changes: 33 additions & 33 deletions src/libstd/io/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,9 @@ pub fn unlink(path: &Path) -> IoResult<()> {
Ok(stat) => stat,
Err(..) => return Err(e),
};
if stat.perm.intersects(io::UserWrite) { return Err(e) }
if stat.perm.intersects(io::USER_WRITE) { return Err(e) }

match chmod(path, stat.perm | io::UserWrite) {
match chmod(path, stat.perm | io::USER_WRITE) {
Ok(()) => do_unlink(path),
Err(..) => {
// Try to put it back as we found it
Expand Down Expand Up @@ -501,10 +501,10 @@ pub fn copy(from: &Path, to: &Path) -> IoResult<()> {
/// 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);
/// ```
///
/// # Error
Expand Down Expand Up @@ -578,7 +578,7 @@ pub fn readlink(path: &Path) -> IoResult<Path> {
/// use std::io::fs;
///
/// let p = Path::new("/some/dir");
/// fs::mkdir(&p, io::UserRWX);
/// fs::mkdir(&p, io::USER_RWX);
/// ```
///
/// # Error
Expand Down Expand Up @@ -996,7 +996,7 @@ mod test {
use os;
use rand;
let ret = os::tmpdir().join(format!("rust-{}", rand::random::<u32>()));
check!(io::fs::mkdir(&ret, io::UserRWX));
check!(io::fs::mkdir(&ret, io::USER_RWX));
TempDir(ret)
}

Expand Down Expand Up @@ -1180,7 +1180,7 @@ mod test {
fn file_test_stat_is_correct_on_is_dir() {
let tmpdir = tmpdir();
let filename = &tmpdir.join("file_stat_correct_on_is_dir");
check!(mkdir(filename, io::UserRWX));
check!(mkdir(filename, io::USER_RWX));
let stat_res_fn = check!(stat(filename));
assert!(stat_res_fn.kind == io::TypeDirectory);
let stat_res_meth = check!(filename.stat());
Expand All @@ -1192,7 +1192,7 @@ mod test {
fn file_test_fileinfo_false_when_checking_is_file_on_a_directory() {
let tmpdir = tmpdir();
let dir = &tmpdir.join("fileinfo_false_on_dir");
check!(mkdir(dir, io::UserRWX));
check!(mkdir(dir, io::USER_RWX));
assert!(dir.is_file() == false);
check!(rmdir(dir));
}
Expand All @@ -1212,7 +1212,7 @@ mod test {
let tmpdir = tmpdir();
let dir = &tmpdir.join("before_and_after_dir");
assert!(!dir.exists());
check!(mkdir(dir, io::UserRWX));
check!(mkdir(dir, io::USER_RWX));
assert!(dir.exists());
assert!(dir.is_dir());
check!(rmdir(dir));
Expand All @@ -1224,7 +1224,7 @@ mod test {
use str;
let tmpdir = tmpdir();
let dir = &tmpdir.join("di_readdir");
check!(mkdir(dir, io::UserRWX));
check!(mkdir(dir, io::USER_RWX));
let prefix = "foo";
for n in range(0i,3) {
let f = dir.join(format!("{}.txt", n));
Expand Down Expand Up @@ -1255,14 +1255,14 @@ mod test {
fn file_test_walk_dir() {
let tmpdir = tmpdir();
let dir = &tmpdir.join("walk_dir");
check!(mkdir(dir, io::UserRWX));
check!(mkdir(dir, io::USER_RWX));

let dir1 = &dir.join("01/02/03");
check!(mkdir_recursive(dir1, io::UserRWX));
check!(mkdir_recursive(dir1, io::USER_RWX));
check!(File::create(&dir1.join("04")));

let dir2 = &dir.join("11/12/13");
check!(mkdir_recursive(dir2, io::UserRWX));
check!(mkdir_recursive(dir2, io::USER_RWX));
check!(File::create(&dir2.join("14")));

let mut files = check!(walk_dir(dir));
Expand All @@ -1282,7 +1282,7 @@ mod test {
fn recursive_mkdir() {
let tmpdir = tmpdir();
let dir = tmpdir.join("d1/d2");
check!(mkdir_recursive(&dir, io::UserRWX));
check!(mkdir_recursive(&dir, io::USER_RWX));
assert!(dir.is_dir())
}

Expand All @@ -1292,10 +1292,10 @@ mod test {
let dir = tmpdir.join("d1");
let file = dir.join("f1");

check!(mkdir_recursive(&dir, io::UserRWX));
check!(mkdir_recursive(&dir, io::USER_RWX));
check!(File::create(&file));

let result = mkdir_recursive(&file, io::UserRWX);
let result = mkdir_recursive(&file, io::USER_RWX);

error!(result, "couldn't recursively mkdir");
error!(result, "couldn't create directory");
Expand All @@ -1305,7 +1305,7 @@ mod test {

#[test]
fn recursive_mkdir_slash() {
check!(mkdir_recursive(&Path::new("/"), io::UserRWX));
check!(mkdir_recursive(&Path::new("/"), io::USER_RWX));
}

// FIXME(#12795) depends on lstat to work on windows
Expand All @@ -1318,8 +1318,8 @@ mod test {
let dtt = dt.join("t");
let d2 = tmpdir.join("d2");
let canary = d2.join("do_not_delete");
check!(mkdir_recursive(&dtt, io::UserRWX));
check!(mkdir_recursive(&d2, io::UserRWX));
check!(mkdir_recursive(&dtt, io::USER_RWX));
check!(mkdir_recursive(&d2, io::USER_RWX));
check!(File::create(&canary).write(b"foo"));
check!(symlink(&d2, &dt.join("d2")));
check!(rmdir_recursive(&d1));
Expand All @@ -1337,7 +1337,7 @@ mod test {

let mut dirpath = tmpdir.path().clone();
dirpath.push(format!("test-가一ー你好"));
check!(mkdir(&dirpath, io::UserRWX));
check!(mkdir(&dirpath, io::USER_RWX));
assert!(dirpath.is_dir());

let mut filepath = dirpath;
Expand All @@ -1355,7 +1355,7 @@ mod test {
let tmpdir = tmpdir();
let unicode = tmpdir.path();
let unicode = unicode.join(format!("test-각丁ー再见"));
check!(mkdir(&unicode, io::UserRWX));
check!(mkdir(&unicode, io::USER_RWX));
assert!(unicode.exists());
assert!(!Path::new("test/unicode-bogus-path-각丁ー再见").exists());
}
Expand Down Expand Up @@ -1436,12 +1436,12 @@ mod test {
let out = tmpdir.join("out.txt");

check!(File::create(&input));
check!(chmod(&input, io::UserRead));
check!(chmod(&input, io::USER_READ));
check!(copy(&input, &out));
assert!(!check!(out.stat()).perm.intersects(io::UserWrite));
assert!(!check!(out.stat()).perm.intersects(io::USER_WRITE));

check!(chmod(&input, io::UserFile));
check!(chmod(&out, io::UserFile));
check!(chmod(&input, io::USER_FILE));
check!(chmod(&out, io::USER_FILE));
}

#[cfg(not(windows))] // FIXME(#10264) operation not permitted?
Expand Down Expand Up @@ -1517,16 +1517,16 @@ mod test {
let file = tmpdir.join("in.txt");

check!(File::create(&file));
assert!(check!(stat(&file)).perm.contains(io::UserWrite));
check!(chmod(&file, io::UserRead));
assert!(!check!(stat(&file)).perm.contains(io::UserWrite));
assert!(check!(stat(&file)).perm.contains(io::USER_WRITE));
check!(chmod(&file, io::USER_READ));
assert!(!check!(stat(&file)).perm.contains(io::USER_WRITE));

match chmod(&tmpdir.join("foo"), io::UserRWX) {
match chmod(&tmpdir.join("foo"), io::USER_RWX) {
Ok(..) => fail!("wanted a failure"),
Err(..) => {}
}

check!(chmod(&file, io::UserFile));
check!(chmod(&file, io::USER_FILE));
}

#[test]
Expand Down Expand Up @@ -1677,7 +1677,7 @@ mod test {
let tmpdir = tmpdir();
let path = tmpdir.join("file");
check!(File::create(&path));
check!(chmod(&path, io::UserRead));
check!(chmod(&path, io::USER_READ));
check!(unlink(&path));
}
}
Loading