Skip to content

remove some compiler warnings #22920

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
Mar 4, 2015
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
1 change: 0 additions & 1 deletion src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
#![feature(unboxed_closures)]
#![feature(unsafe_no_drop_flag)]
#![feature(core)]
#![feature(unique)]
#![cfg_attr(test, feature(test, alloc, rustc_private))]
#![cfg_attr(all(not(feature = "external_funcs"), not(feature = "external_crate")),
feature(libc))]
Expand Down
4 changes: 2 additions & 2 deletions src/libcollections/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2170,8 +2170,8 @@ mod tests {
fn test_connect() {
let v: [Vec<i32>; 0] = [];
assert_eq!(v.connect(&0), []);
assert_eq!([vec![1i], vec![2, 3]].connect(&0), [1, 0, 2, 3]);
assert_eq!([vec![1i], vec![2], vec![3]].connect(&0), [1, 0, 2, 0, 3]);
assert_eq!([vec![1], vec![2, 3]].connect(&0), [1, 0, 2, 3]);
assert_eq!([vec![1], vec![2], vec![3]].connect(&0), [1, 0, 2, 0, 3]);

let v: [&[_]; 2] = [&[1], &[2, 3]];
assert_eq!(v.connect(&0), [1, 0, 2, 3]);
Expand Down
2 changes: 1 addition & 1 deletion src/libcoretest/hash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ struct CustomHasher { output: u64 }

impl Hasher for CustomHasher {
fn finish(&self) -> u64 { self.output }
fn write(&mut self, data: &[u8]) { panic!() }
fn write(&mut self, _: &[u8]) { panic!() }
fn write_u64(&mut self, data: u64) { self.output = data; }
}

Expand Down
6 changes: 2 additions & 4 deletions src/libcoretest/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,13 @@ fn trim_ws() {

mod pattern {
use std::str::Pattern;
use std::str::{Searcher, ReverseSearcher, DoubleEndedSearcher};
use std::str::{Searcher, ReverseSearcher};
use std::str::SearchStep::{self, Match, Reject, Done};

macro_rules! make_test {
($name:ident, $p:expr, $h:expr, [$($e:expr,)*]) => {
mod $name {
use std::str::Pattern;
use std::str::{Searcher, ReverseSearcher, DoubleEndedSearcher};
use std::str::SearchStep::{self, Match, Reject, Done};
use std::str::SearchStep::{Match, Reject};
use super::{cmp_search_to_vec};
#[test]
fn fwd() {
Expand Down
1 change: 0 additions & 1 deletion src/librand/rand_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ impl<T:Rand> Rand for Option<T> {

#[cfg(test)]
mod tests {
use std::prelude::v1::*;
use std::rand::{Rng, thread_rng, Open01, Closed01};

struct ConstantRng(u64);
Expand Down
18 changes: 9 additions & 9 deletions src/librbml/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,32 +140,32 @@ mod tests {
fn test_seekable_mem_writer() {
let mut writer = SeekableMemWriter::new();
assert_eq!(writer.tell(), Ok(0));
writer.write(&[0]).unwrap();
writer.write_all(&[0]).unwrap();
assert_eq!(writer.tell(), Ok(1));
writer.write(&[1, 2, 3]).unwrap();
writer.write(&[4, 5, 6, 7]).unwrap();
writer.write_all(&[1, 2, 3]).unwrap();
writer.write_all(&[4, 5, 6, 7]).unwrap();
assert_eq!(writer.tell(), Ok(8));
let b: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7];
assert_eq!(writer.get_ref(), b);

writer.seek(0, old_io::SeekSet).unwrap();
assert_eq!(writer.tell(), Ok(0));
writer.write(&[3, 4]).unwrap();
writer.write_all(&[3, 4]).unwrap();
let b: &[_] = &[3, 4, 2, 3, 4, 5, 6, 7];
assert_eq!(writer.get_ref(), b);

writer.seek(1, old_io::SeekCur).unwrap();
writer.write(&[0, 1]).unwrap();
writer.write_all(&[0, 1]).unwrap();
let b: &[_] = &[3, 4, 2, 0, 1, 5, 6, 7];
assert_eq!(writer.get_ref(), b);

writer.seek(-1, old_io::SeekEnd).unwrap();
writer.write(&[1, 2]).unwrap();
writer.write_all(&[1, 2]).unwrap();
let b: &[_] = &[3, 4, 2, 0, 1, 5, 6, 1, 2];
assert_eq!(writer.get_ref(), b);

writer.seek(1, old_io::SeekEnd).unwrap();
writer.write(&[1]).unwrap();
writer.write_all(&[1]).unwrap();
let b: &[_] = &[3, 4, 2, 0, 1, 5, 6, 1, 2, 0, 1];
assert_eq!(writer.get_ref(), b);
}
Expand All @@ -174,7 +174,7 @@ mod tests {
fn seek_past_end() {
let mut r = SeekableMemWriter::new();
r.seek(10, old_io::SeekSet).unwrap();
assert!(r.write(&[3]).is_ok());
assert!(r.write_all(&[3]).is_ok());
}

#[test]
Expand All @@ -190,7 +190,7 @@ mod tests {
b.iter(|| {
let mut wr = SeekableMemWriter::new();
for _ in 0..times {
wr.write(&src).unwrap();
wr.write_all(&src).unwrap();
}

let v = wr.unwrap();
Expand Down
5 changes: 2 additions & 3 deletions src/libstd/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,15 +422,14 @@ mod tests {
use prelude::v1::*;
use super::*;
use libc;
use mem;

#[test]
fn c_to_rust() {
let data = b"123\0";
let ptr = data.as_ptr() as *const libc::c_char;
unsafe {
assert_eq!(c_str_to_bytes(&ptr), b"123");
assert_eq!(c_str_to_bytes_with_nul(&ptr), b"123\0");
assert_eq!(CStr::from_ptr(ptr).to_bytes(), b"123");
assert_eq!(CStr::from_ptr(ptr).to_bytes_with_nul(), b"123\0");
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ mod tests {
struct R;

impl Read for R {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
fn read(&mut self, _: &mut [u8]) -> io::Result<usize> {
Err(io::Error::new(io::ErrorKind::Other, "", None))
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
#![feature(macro_reexport)]
#![feature(hash)]
#![feature(unique)]
#![cfg_attr(test, feature(test, rustc_private, env))]
#![cfg_attr(test, feature(test, rustc_private))]

// Don't link to std. We are std.
#![feature(no_std)]
Expand Down
5 changes: 2 additions & 3 deletions src/libstd/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -761,14 +761,13 @@ mod tests {
#[cfg(not(target_os="android"))]
#[test]
fn test_inherit_env() {
use os;
use std::env;
if running_on_valgrind() { return; }

let result = env_cmd().output().unwrap();
let output = String::from_utf8(result.stdout).unwrap();

let r = os::env();
for &(ref k, ref v) in &r {
for (ref k, ref v) in env::vars() {
// don't check windows magical empty-named variables
assert!(k.is_empty() ||
output.contains(format!("{}={}", *k, *v).as_slice()),
Expand Down
6 changes: 3 additions & 3 deletions src/libterm/terminfo/searcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,17 @@ pub fn open(term: &str) -> Result<File, String> {
fn test_get_dbpath_for_term() {
// woefully inadequate test coverage
// note: current tests won't work with non-standard terminfo hierarchies (e.g. OS X's)
use std::os::{setenv, unsetenv};
use std::env;
// FIXME (#9639): This needs to handle non-utf8 paths
fn x(t: &str) -> String {
let p = get_dbpath_for_term(t).expect("no terminfo entry found");
p.as_str().unwrap().to_string()
};
assert!(x("screen") == "/usr/share/terminfo/s/screen");
assert!(get_dbpath_for_term("") == None);
setenv("TERMINFO_DIRS", ":");
env::set_var("TERMINFO_DIRS", ":");
assert!(x("screen") == "/usr/share/terminfo/s/screen");
unsetenv("TERMINFO_DIRS");
env::remove_var("TERMINFO_DIRS");
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions src/libtest/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,8 +732,8 @@ fn should_sort_failures_before_printing_them() {
Pretty(_) => unreachable!()
};

let apos = s.find_str("a").unwrap();
let bpos = s.find_str("b").unwrap();
let apos = s.find("a").unwrap();
let bpos = s.find("b").unwrap();
assert!(apos < bpos);
}

Expand Down