servo: Merge #20175 - #20174 removed the option and unwrap (from andreicristianpetcu:remove_optional_from_default_config_dir); r=jdm
authorAndrei Cristian Petcu <andrei@ceata.org>
Fri, 02 Mar 2018 14:39:37 -0500
changeset 461419 35a457fb6b60cff67b54e3334e97fcc9edeeb263
parent 461418 304c6387dab25b59139c20d08fe0f6843b1cbcde
child 461420 88d7a7d93abf2d02ab0167f1bff9a417e4266906
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdm
bugs20175, 20174
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
servo: Merge #20175 - #20174 removed the option and unwrap (from andreicristianpetcu:remove_optional_from_default_config_dir); r=jdm I removed the useless option and the need for unwrap from default_config_dir --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #20174 (github issue number if applicable). - [X] These changes do not require tests because they are used at build time. Source-Repo: https://github.com/servo/servo Source-Revision: 48ff3965cc2e483a33d457e3ddaf9ad10007c275
servo/components/config/basedir.rs
servo/components/config/prefs.rs
servo/components/config/tests/prefs.rs
servo/ports/servo/main.rs
--- a/servo/components/config/basedir.rs
+++ b/servo/components/config/basedir.rs
@@ -12,29 +12,28 @@ use android_injected_glue;
 use std::env;
 #[cfg(target_os = "android")]
 use std::ffi::CStr;
 use std::path::PathBuf;
 #[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))]
 use xdg;
 
 #[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))]
-pub fn default_config_dir() -> Option<PathBuf> {
+pub fn default_config_dir() -> PathBuf {
     let xdg_dirs = xdg::BaseDirectories::with_profile("servo", "default").unwrap();
-    let config_dir = xdg_dirs.get_config_home();
-    Some(config_dir)
+    xdg_dirs.get_config_home()
 }
 
 #[cfg(target_os = "android")]
 #[allow(unsafe_code)]
-pub fn default_config_dir() -> Option<PathBuf> {
+pub fn default_config_dir() -> PathBuf {
     let dir = unsafe {
         CStr::from_ptr((*android_injected_glue::get_app().activity).externalDataPath)
     };
-    Some(PathBuf::from(dir.to_str().unwrap()))
+    PathBuf::from(dir.to_str().unwrap())
 }
 
 #[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))]
 pub fn default_data_dir() -> Option<PathBuf> {
     let xdg_dirs = xdg::BaseDirectories::with_profile("servo", "default").unwrap();
     let data_dir = xdg_dirs.get_data_home();
     Some(data_dir)
 }
@@ -62,30 +61,30 @@ pub fn default_cache_dir() -> Option<Pat
     // There is no equivalent function in NDK/NativeActivity.
     let dir = unsafe {
         CStr::from_ptr((*android_injected_glue::get_app().activity).externalDataPath)
     };
     Some(PathBuf::from(dir.to_str().unwrap()))
 }
 
 #[cfg(target_os = "macos")]
-pub fn default_config_dir() -> Option<PathBuf> {
+pub fn default_config_dir() -> PathBuf {
     let mut config_dir = env::home_dir().unwrap();
     config_dir.push("Library");
     config_dir.push("Application Support");
     config_dir.push("Servo");
-    Some(config_dir)
+    config_dir
 }
 
 #[cfg(target_os = "windows")]
-pub fn default_config_dir() -> Option<PathBuf> {
+pub fn default_config_dir() -> PathBuf {
     let mut config_dir = match env::var_os("APPDATA") {
         Some(appdata_path) => PathBuf::from(appdata_path),
         None => {
             let mut dir = env::home_dir().unwrap();
             dir.push("Appdata");
             dir.push("Roaming");
             dir
         }
     };
     config_dir.push("Servo");
-    Some(config_dir)
+    config_dir
 }
--- a/servo/components/config/prefs.rs
+++ b/servo/components/config/prefs.rs
@@ -179,17 +179,17 @@ pub fn read_prefs_from_file<T>(mut file:
 
 pub fn add_user_prefs() {
     match opts::get().config_dir {
         Some(ref config_path) => {
             let mut path = PathBuf::from(config_path);
             init_user_prefs(&mut path);
         }
         None => {
-            let mut path = default_config_dir().unwrap();
+            let mut path = default_config_dir();
             if path.join("prefs.json").exists() {
                 init_user_prefs(&mut path);
             }
         }
     }
 }
 
 fn init_user_prefs(path: &mut PathBuf) {
--- a/servo/components/config/tests/prefs.rs
+++ b/servo/components/config/tests/prefs.rs
@@ -51,17 +51,17 @@ fn test_get_set_reset_extend() {
 #[test]
 fn test_default_config_dir_create_read_write() {
   let json_str = "{\
   \"layout.writing-mode.enabled\": true,\
   \"extra.stuff\": false,\
   \"shell.homepage\": \"https://google.com\"\
 }";
     let mut expected_json = String::new();
-    let config_path = basedir::default_config_dir().unwrap();
+    let config_path = basedir::default_config_dir();
 
     if !config_path.exists() {
       fs::create_dir_all(&config_path).unwrap();
     }
 
     let json_path = config_path.join("test_config.json");
 
     let mut fd = File::create(&json_path).unwrap();
--- a/servo/ports/servo/main.rs
+++ b/servo/ports/servo/main.rs
@@ -253,17 +253,17 @@ fn setup_logging() {}
 /// Blank lines and those beginning with a '#' are ignored.
 /// Each line should be a separate parameter as would be parsed by the shell.
 /// For example, "servo -p 10 http://en.wikipedia.org/wiki/Rust" would take 4 lines.
 fn args() -> Vec<String> {
     use std::error::Error;
     use std::fs::File;
     use std::io::{BufRead, BufReader};
 
-    let mut params_file = config::basedir::default_config_dir().unwrap();
+    let mut params_file = config::basedir::default_config_dir();
     params_file.push("android_params");
     match File::open(params_file.to_str().unwrap()) {
         Ok(f) => {
             let mut vec = Vec::new();
             let file = BufReader::new(&f);
             for line in file.lines() {
                 let l = line.unwrap().trim().to_owned();
                 // ignore blank lines and those that start with a '#'