Fix some warnings in util.

This commit is contained in:
Simon Sapin 2015-03-18 21:35:06 +01:00
parent d553bfefbb
commit 1e858ecbc6
4 changed files with 13 additions and 8 deletions

View file

@ -6,15 +6,20 @@
#![feature(box_syntax)] #![feature(box_syntax)]
#![feature(collections)] #![feature(collections)]
#![feature(core)] #![feature(core)]
#![feature(env)] #![feature(exit_status)]
#![feature(hash)] #![feature(hash)]
#![feature(int_uint)] #![feature(int_uint)]
#![feature(io)] #![feature(io)]
#![feature(optin_builtin_traits)] #![feature(optin_builtin_traits)]
#![feature(old_io)]
#![feature(old_path)]
#![feature(page_size)]
#![feature(path)] #![feature(path)]
#![feature(path_ext)]
#![feature(plugin)] #![feature(plugin)]
#![feature(rustc_private)] #![feature(rustc_private)]
#![feature(std_misc)] #![feature(std_misc)]
#![feature(str_words)]
#![feature(unicode)] #![feature(unicode)]
#![feature(unsafe_destructor)] #![feature(unsafe_destructor)]

View file

@ -451,12 +451,12 @@ fn get_jemalloc_stat(value_name: &str) -> Option<u64> {
// request. Without that jemalloc gives cached statistics(!) which can be // request. Without that jemalloc gives cached statistics(!) which can be
// highly inaccurate. // highly inaccurate.
let epoch_name = "epoch"; let epoch_name = "epoch";
let epoch_c_name = CString::from_slice(epoch_name.as_bytes()); let epoch_c_name = CString::new(epoch_name).unwrap();
let mut epoch: u64 = 0; let mut epoch: u64 = 0;
let epoch_ptr = &mut epoch as *mut _ as *mut c_void; let epoch_ptr = &mut epoch as *mut _ as *mut c_void;
let mut epoch_len = size_of::<u64>() as size_t; let mut epoch_len = size_of::<u64>() as size_t;
let value_c_name = CString::from_slice(value_name.as_bytes()); let value_c_name = CString::new(value_name).unwrap();
let mut value: size_t = 0; let mut value: size_t = 0;
let value_ptr = &mut value as *mut _ as *mut c_void; let value_ptr = &mut value as *mut _ as *mut c_void;
let mut value_len = size_of::<size_t>() as size_t; let mut value_len = size_of::<size_t>() as size_t;

View file

@ -9,10 +9,10 @@ use cssparser::{self, RGBA, Color};
use libc::c_char; use libc::c_char;
use std::ascii::AsciiExt; use std::ascii::AsciiExt;
use std::borrow::ToOwned; use std::borrow::ToOwned;
use std::ffi::c_str_to_bytes; use std::ffi::CStr;
use std::iter::Filter; use std::iter::Filter;
use std::num::{Int, ToPrimitive}; use std::num::{Int, ToPrimitive};
use std::str::{from_utf8, CharEq, FromStr, Split}; use std::str::{from_utf8, FromStr, Split};
pub type DOMString = String; pub type DOMString = String;
pub type StaticCharVec = &'static [char]; pub type StaticCharVec = &'static [char];
@ -333,5 +333,5 @@ impl Str for LowercaseString {
/// Creates a String from the given null-terminated buffer. /// Creates a String from the given null-terminated buffer.
/// Panics if the buffer does not contain UTF-8. /// Panics if the buffer does not contain UTF-8.
pub unsafe fn c_str_to_string(s: *const c_char) -> String { pub unsafe fn c_str_to_string(s: *const c_char) -> String {
from_utf8(c_str_to_bytes(&s)).unwrap().to_owned() from_utf8(CStr::from_ptr(s).to_bytes()).unwrap().to_owned()
} }

View file

@ -14,7 +14,7 @@ pub fn spawn_named<F>(name: String, f: F)
let builder = thread::Builder::new().name(name); let builder = thread::Builder::new().name(name);
builder.spawn(move || { builder.spawn(move || {
f() f()
}); }).unwrap();
} }
/// Arrange to send a particular message to a channel if the task fails. /// Arrange to send a particular message to a channel if the task fails.
@ -40,7 +40,7 @@ pub fn spawn_named_with_send_on_failure<F, T>(name: &'static str,
dest.send(msg).unwrap(); dest.send(msg).unwrap();
} }
} }
}); }).unwrap();
} }
#[test] #[test]