Skip to content

Clean up rustc warnings. #17970

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 1 commit into from
Oct 14, 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
28 changes: 11 additions & 17 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -947,15 +947,12 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
String::from_chars(c.as_slice())
}

#[cfg(target_os = "windows")]
#[cfg(windows)]
fn prefix_matches( line : &str, prefix : &str ) -> bool {
to_lower(line).as_slice().starts_with(to_lower(prefix).as_slice())
}

#[cfg(any(target_os = "linux",
target_os = "macos",
target_os = "freebsd",
target_os = "dragonfly"))]
#[cfg(unix)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is possibly changing semantics, since this includes android but the previous version did not. Although, maybe this is what we want.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, why the move away from target_os? Is that now deprecated?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I don't think it's necessarily a bad thing, just wondering if I missed the PR that made it a warning to have cfg(target_os=...).)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@huonw This is because that part of code was previously like this

#[cfg(target_os = "linux")]
#[cfg(target_os = "macos")]
...

but d4ba942 was quicker than me in removing warnings on a sequence of #[cfg()] to mean any. Then my change after git rabase only appear to compact/remove target_os clauses. I didn't see any warnings from target_os here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is ok to move to cfg(unix), this looks like it just wouldn't compile on android anyway.

fn prefix_matches( line : &str, prefix : &str ) -> bool {
line.starts_with( prefix )
}
Expand Down Expand Up @@ -1356,24 +1353,21 @@ fn program_output(config: &Config, testfile: &Path, lib_path: &str, prog: String
}

// Linux and mac don't require adjusting the library search path
#[cfg(any(target_os = "linux",
target_os = "macos",
target_os = "freebsd",
target_os = "dragonfly"))]
#[cfg(unix)]
fn make_cmdline(_libpath: &str, prog: &str, args: &[String]) -> String {
format!("{} {}", prog, args.connect(" "))
}

#[cfg(target_os = "windows")]
#[cfg(windows)]
fn make_cmdline(libpath: &str, prog: &str, args: &[String]) -> String {
format!("{} {} {}", lib_path_cmd_prefix(libpath), prog, args.connect(" "))
}

// Build the LD_LIBRARY_PATH variable as it would be seen on the command line
// for diagnostic purposes
#[cfg(target_os = "windows")]
fn lib_path_cmd_prefix(path: &str) -> String {
format!("{}=\"{}\"", util::lib_path_env_var(), util::make_new_path(path))
// Build the LD_LIBRARY_PATH variable as it would be seen on the command line
// for diagnostic purposes
fn lib_path_cmd_prefix(path: &str) -> String {
format!("{}=\"{}\"", util::lib_path_env_var(), util::make_new_path(path))
}

format!("{} {} {}", lib_path_cmd_prefix(libpath), prog, args.connect(" "))
}

fn dump_output(config: &Config, testfile: &Path, out: &str, err: &str) {
Expand Down
1 change: 0 additions & 1 deletion src/liballoc/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ impl<T: Sync + Send> Drop for Weak<T> {
#[allow(experimental)]
mod tests {
use std::clone::Clone;
use std::collections::MutableSeq;
use std::comm::channel;
use std::mem::drop;
use std::ops::Drop;
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/bitv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2659,7 +2659,7 @@ mod tests {
let mut r = rng();
let mut bitv = Bitv::with_capacity(BENCH_BITS, false);
b.iter(|| {
for i in range(0u, 100) {
for _ in range(0u, 100) {
bitv.set((r.next_u32() as uint) % BENCH_BITS, r.gen());
}
&bitv
Expand Down
8 changes: 4 additions & 4 deletions src/libcollections/dlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -890,13 +890,13 @@ mod tests {
}

let v = vec![1i,2,3,4,5];
let u = vec![9i,8,1,2,3,4,5];
let mut u = vec![9i,8,1,2,3,4,5];
let mut m = list_from(v.as_slice());
m.prepend(list_from(u.as_slice()));
check_links(&m);
let sum = u.append(v.as_slice());
assert_eq!(sum.len(), m.len());
for elt in sum.into_iter() {
u.extend(v.as_slice().iter().map(|&b| b));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I redo make check, I got an error here. u should have been mutable since extend(), unlike append(), requires &mut self. Why couldn't I catch this before??

assert_eq!(u.len(), m.len());
for elt in u.into_iter() {
assert_eq!(m.pop_front(), Some(elt))
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/libcollections/ringbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,10 +611,10 @@ mod tests {
assert_eq!(deq.len(), 3);
deq.push_front(a.clone());
assert_eq!(deq.len(), 4);
assert_eq!((*deq.get(0)).clone(), a.clone());
assert_eq!((*deq.get(1)).clone(), b.clone());
assert_eq!((*deq.get(2)).clone(), c.clone());
assert_eq!((*deq.get(3)).clone(), d.clone());
assert_eq!(deq[0].clone(), a.clone());
assert_eq!(deq[1].clone(), b.clone());
assert_eq!(deq[2].clone(), c.clone());
assert_eq!(deq[3].clone(), d.clone());
}

#[test]
Expand All @@ -626,7 +626,7 @@ mod tests {
assert_eq!(deq.len(), 66);

for i in range(0u, 66) {
assert_eq!(*deq.get(i), 65 - i);
assert_eq!(deq[i], 65 - i);
}

let mut deq = RingBuf::new();
Expand All @@ -635,7 +635,7 @@ mod tests {
}

for i in range(0u, 66) {
assert_eq!(*deq.get(i), i);
assert_eq!(deq[i], i);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/libcollections/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,7 @@ mod tests {
use std::slice::{AsSlice, ImmutableSlice};
use string::String;
use vec::Vec;
use slice::CloneableVector;

use unicode::char::UnicodeChar;

Expand Down Expand Up @@ -1504,7 +1505,7 @@ mod tests {
fn vec_str_conversions() {
let s1: String = String::from_str("All mimsy were the borogoves");

let v: Vec<u8> = Vec::from_slice(s1.as_bytes());
let v: Vec<u8> = s1.as_bytes().to_vec();
let s2: String = String::from_str(from_utf8(v.as_slice()).unwrap());
let mut i: uint = 0u;
let n1: uint = s1.len();
Expand Down
25 changes: 14 additions & 11 deletions src/libcollections/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,7 @@ mod tests {
use str::{Str, StrSlice, Owned};
use super::{as_string, String};
use vec::Vec;
use slice::CloneableVector;

#[test]
fn test_as_string() {
Expand All @@ -1051,15 +1052,15 @@ mod tests {

#[test]
fn test_from_utf8() {
let xs = Vec::from_slice(b"hello");
let xs = b"hello".to_vec();
assert_eq!(String::from_utf8(xs), Ok(String::from_str("hello")));

let xs = Vec::from_slice("ศไทย中华Việt Nam".as_bytes());
let xs = "ศไทย中华Việt Nam".as_bytes().to_vec();
assert_eq!(String::from_utf8(xs), Ok(String::from_str("ศไทย中华Việt Nam")));

let xs = Vec::from_slice(b"hello\xFF");
let xs = b"hello\xFF".to_vec();
assert_eq!(String::from_utf8(xs),
Err(Vec::from_slice(b"hello\xFF")));
Err(b"hello\xFF".to_vec()));
}

#[test]
Expand Down Expand Up @@ -1211,7 +1212,8 @@ mod tests {
fn test_push_bytes() {
let mut s = String::from_str("ABC");
unsafe {
s.push_bytes([b'D']);
let mv = s.as_mut_vec();
mv.push_all([b'D']);
}
assert_eq!(s.as_slice(), "ABCD");
}
Expand Down Expand Up @@ -1239,17 +1241,18 @@ mod tests {
}

#[test]
fn test_pop_char() {
fn test_pop() {
let mut data = String::from_str("ประเทศไทย中华b¢€𤭢");
assert_eq!(data.pop_char().unwrap(), '𤭢'); // 4 bytes
assert_eq!(data.pop_char().unwrap(), '€'); // 3 bytes
assert_eq!(data.pop_char().unwrap(), '¢'); // 2 bytes
assert_eq!(data.pop_char().unwrap(), 'b'); // 1 bytes
assert_eq!(data.pop_char().unwrap(), '华');
assert_eq!(data.pop().unwrap(), '𤭢'); // 4 bytes
assert_eq!(data.pop().unwrap(), '€'); // 3 bytes
assert_eq!(data.pop().unwrap(), '¢'); // 2 bytes
assert_eq!(data.pop().unwrap(), 'b'); // 1 bytes
assert_eq!(data.pop().unwrap(), '华');
assert_eq!(data.as_slice(), "ประเทศไทย中");
}

#[test]
#[allow(deprecated)] // use remove(0) instead
fn test_shift_char() {
let mut data = String::from_str("𤭢€¢b华ประเทศไทย中");
assert_eq!(data.shift_char().unwrap(), '𤭢'); // 4 bytes
Expand Down
44 changes: 22 additions & 22 deletions src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2266,8 +2266,8 @@ mod tests {
}

#[test]
fn test_mut_slice_from() {
let mut values = Vec::from_slice([1u8,2,3,4,5]);
fn test_slice_from_mut() {
let mut values = vec![1u8,2,3,4,5];
{
let slice = values.slice_from_mut(2);
assert!(slice == [3, 4, 5]);
Expand All @@ -2280,8 +2280,8 @@ mod tests {
}

#[test]
fn test_mut_slice_to() {
let mut values = Vec::from_slice([1u8,2,3,4,5]);
fn test_slice_to_mut() {
let mut values = vec![1u8,2,3,4,5];
{
let slice = values.slice_to_mut(2);
assert!(slice == [1, 2]);
Expand All @@ -2294,8 +2294,8 @@ mod tests {
}

#[test]
fn test_mut_split_at() {
let mut values = Vec::from_slice([1u8,2,3,4,5]);
fn test_split_at_mut() {
let mut values = vec![1u8,2,3,4,5];
{
let (left, right) = values.split_at_mut(2);
{
Expand All @@ -2315,7 +2315,7 @@ mod tests {
}
}

assert!(values == Vec::from_slice([2u8, 3, 5, 6, 7]));
assert!(values == vec![2u8, 3, 5, 6, 7]);
}

#[test]
Expand Down Expand Up @@ -2355,16 +2355,16 @@ mod tests {

#[test]
fn test_grow_fn() {
let mut v = Vec::from_slice([0u, 1]);
let mut v = vec![0u, 1];
v.grow_fn(3, |i| i);
assert!(v == Vec::from_slice([0u, 1, 0, 1, 2]));
assert!(v == vec![0u, 1, 0, 1, 2]);
}

#[test]
fn test_retain() {
let mut vec = Vec::from_slice([1u, 2, 3, 4]);
let mut vec = vec![1u, 2, 3, 4];
vec.retain(|x| x%2 == 0);
assert!(vec == Vec::from_slice([2u, 4]));
assert!(vec == vec![2u, 4]);
}

#[test]
Expand Down Expand Up @@ -2567,32 +2567,32 @@ mod tests {

#[test]
fn test_move_items() {
let mut vec = vec!(1i, 2, 3);
let mut vec2 : Vec<int> = vec!();
let vec = vec![1, 2, 3];
let mut vec2 : Vec<i32> = vec![];
for i in vec.into_iter() {
vec2.push(i);
}
assert!(vec2 == vec!(1i, 2, 3));
assert!(vec2 == vec![1, 2, 3]);
}

#[test]
fn test_move_items_reverse() {
let mut vec = vec!(1i, 2, 3);
let mut vec2 : Vec<int> = vec!();
let vec = vec![1, 2, 3];
let mut vec2 : Vec<i32> = vec![];
for i in vec.into_iter().rev() {
vec2.push(i);
}
assert!(vec2 == vec!(3i, 2, 1));
assert!(vec2 == vec![3, 2, 1]);
}

#[test]
fn test_move_items_zero_sized() {
let mut vec = vec!((), (), ());
let mut vec2 : Vec<()> = vec!();
let vec = vec![(), (), ()];
let mut vec2 : Vec<()> = vec![];
for i in vec.into_iter() {
vec2.push(i);
}
assert!(vec2 == vec!((), (), ()));
assert!(vec2 == vec![(), (), ()]);
}

#[test]
Expand Down Expand Up @@ -2707,7 +2707,7 @@ mod tests {
b.bytes = src_len as u64;

b.iter(|| {
let dst = Vec::from_slice(src.clone().as_slice());
let dst = src.clone().as_slice().to_vec();
assert_eq!(dst.len(), src_len);
assert!(dst.iter().enumerate().all(|(i, x)| i == *x));
});
Expand Down Expand Up @@ -2871,7 +2871,7 @@ mod tests {

b.iter(|| {
let mut dst = dst.clone();
dst.push_all_move(src.clone());
dst.extend(src.clone().into_iter());
assert_eq!(dst.len(), dst_len + src_len);
assert!(dst.iter().enumerate().all(|(i, x)| i == *x));
});
Expand Down
4 changes: 2 additions & 2 deletions src/libcoretest/char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ fn test_is_digit() {
fn test_escape_default() {
fn string(c: char) -> String {
let mut result = String::new();
escape_default(c, |c| { result.push_char(c); });
escape_default(c, |c| { result.push(c); });
return result;
}
let s = string('\n');
Expand Down Expand Up @@ -152,7 +152,7 @@ fn test_escape_default() {
fn test_escape_unicode() {
fn string(c: char) -> String {
let mut result = String::new();
escape_unicode(c, |c| { result.push_char(c); });
escape_unicode(c, |c| { result.push(c); });
return result;
}
let s = string('\x00');
Expand Down
2 changes: 1 addition & 1 deletion src/libcoretest/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ fn bench_multiple_take(b: &mut Bencher) {
let mut it = range(0u, 42).cycle();
b.iter(|| {
let n = it.next().unwrap();
for m in range(0u, n) {
for _ in range(0u, n) {
it.take(it.next().unwrap()).all(|_| true);
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/libcoretest/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ fn test_transmute() {
}

unsafe {
assert!(Vec::from_slice([76u8]) == transmute("L".to_string()));
assert!(vec![76u8] == transmute("L".to_string()));
}
}

Expand Down
1 change: 1 addition & 0 deletions src/libcoretest/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ fn test_collect() {
}

#[test]
#[allow(deprecated)] // we know fold_ is deprecated
fn test_fold() {
assert_eq!(fold_(range(0i, 0)
.map(|_| Ok::<(), ()>(()))),
Expand Down
2 changes: 1 addition & 1 deletion src/libglob/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ mod test {
}

#[test]
#[ignore(cfg(windows))] // FIXME (#9406)
#[cfg_attr(windows, ignore)] // FIXME (#9406)
fn test_lots_of_files() {
// this is a good test because it touches lots of differently named files
glob("/*/*/*/*").skip(10000).next();
Expand Down
14 changes: 14 additions & 0 deletions src/libgraphviz/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,20 @@ r#"digraph single_edge {
"#);
}

#[test]
fn test_some_labelled() {
let labels : Trivial = SomeNodesLabelled(vec![Some("A"), None]);
let result = test_input(LabelledGraph::new("test_some_labelled", labels,
vec![edge(0, 1, "A-1")]));
assert_eq!(result.unwrap().as_slice(),
r#"digraph test_some_labelled {
N0[label="A"];
N1[label="N1"];
N0 -> N1[label="A-1"];
}
"#);
}

#[test]
fn single_cyclic_node() {
let labels : Trivial = UnlabelledNodes(1);
Expand Down
Loading