Fix a bunch of clippy lints

This commit is contained in:
Johannes Linke 2016-01-02 16:51:01 +01:00
parent b1ca3d1cdf
commit 6b215f38ee
58 changed files with 281 additions and 356 deletions

View file

@ -581,11 +581,10 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
let is_running_problem_test =
url_opt
.as_ref()
.map(|url|
.map_or(false, |url|
url.starts_with("http://web-platform.test:8000/2dcontext/drawing-images-to-the-canvas/") ||
url.starts_with("http://web-platform.test:8000/_mozilla/mozilla/canvas/") ||
url.starts_with("http://web-platform.test:8000/_mozilla/css/canvas_over_area.html"))
.unwrap_or(false);
url.starts_with("http://web-platform.test:8000/_mozilla/css/canvas_over_area.html"));
let url = match url_opt {
Some(url_string) => {

View file

@ -146,7 +146,7 @@ fn read_prefs() -> Result<HashMap<String, Pref>, ()> {
}
pub fn get_pref(name: &str) -> Arc<PrefValue> {
PREFS.lock().unwrap().get(name).map(|x| x.value().clone()).unwrap_or(Arc::new(PrefValue::Missing))
PREFS.lock().unwrap().get(name).map_or(Arc::new(PrefValue::Missing), |x| x.value().clone())
}
pub fn set_pref(name: &str, value: PrefValue) {

View file

@ -33,7 +33,7 @@ pub fn resources_dir_path() -> PathBuf {
// FIXME: Find a way to not rely on the executable being
// under `<servo source>[/$target_triple]/target/debug`
// or `<servo source>[/$target_triple]/target/release`.
let mut path = env::current_exe().ok().expect("can't get exe path");
let mut path = env::current_exe().expect("can't get exe path");
path.pop();
path.push("resources");
if !path.is_dir() { // resources dir not in same dir as exe?

View file

@ -461,19 +461,17 @@ pub fn parse_legacy_color(mut input: &str) -> Result<RGBA, ()> {
// Step 6.
if input.len() == 4 {
match (input.as_bytes()[0],
hex(input.as_bytes()[1] as char),
hex(input.as_bytes()[2] as char),
hex(input.as_bytes()[3] as char)) {
(b'#', Ok(r), Ok(g), Ok(b)) => {
return Ok(RGBA {
red: (r as f32) * 17.0 / 255.0,
green: (g as f32) * 17.0 / 255.0,
blue: (b as f32) * 17.0 / 255.0,
alpha: 1.0,
})
}
_ => {}
if let (b'#', Ok(r), Ok(g), Ok(b)) =
(input.as_bytes()[0],
hex(input.as_bytes()[1] as char),
hex(input.as_bytes()[2] as char),
hex(input.as_bytes()[3] as char)) {
return Ok(RGBA {
red: (r as f32) * 17.0 / 255.0,
green: (g as f32) * 17.0 / 255.0,
blue: (b as f32) * 17.0 / 255.0,
alpha: 1.0,
})
}
}