]> git.lizzy.rs Git - rust.git/blobdiff - src/config/config_type.rs
deps: update rustc-ap to v642.0.0
[rust.git] / src / config / config_type.rs
index 326d81b2113b4b07b6ce14058fb5740e91628b1e..2eff7561392c309fd9a0231cb70b4e8d700f4a20 100644 (file)
@@ -178,6 +178,16 @@ pub(crate) fn is_valid_name(name: &str) -> bool {
                 }
             }
 
+            #[allow(unreachable_pub)]
+            pub fn is_valid_key_val(key: &str, val: &str) -> bool {
+                match key {
+                    $(
+                        stringify!($i) => val.parse::<$ty>().is_ok(),
+                    )+
+                        _ => false,
+                }
+            }
+
             #[allow(unreachable_pub)]
             pub fn used_options(&self) -> PartialConfig {
                 PartialConfig {
@@ -249,11 +259,15 @@ pub fn print_docs(out: &mut dyn Write, include_unstable: bool) {
                             }
                             name_out.push_str(name_raw);
                             name_out.push(' ');
+                            let mut default_str = format!("{}", $def);
+                            if default_str.is_empty() {
+                                default_str = String::from("\"\"");
+                            }
                             writeln!(out,
-                                    "{}{} Default: {:?}{}",
+                                    "{}{} Default: {}{}",
                                     name_out,
                                     <$ty>::doc_hint(),
-                                    $def,
+                                    default_str,
                                     if !$stb { " (unstable)" } else { "" }).unwrap();
                             $(
                                 writeln!(out, "{}{}", space_str, $dstring).unwrap();
@@ -279,10 +293,12 @@ fn set_heuristics(&mut self) {
             fn set_license_template(&mut self) {
                 if self.was_set().license_template_path() {
                     let lt_path = self.license_template_path();
-                    match license::load_and_compile_template(&lt_path) {
-                        Ok(re) => self.license_template = Some(re),
-                        Err(msg) => eprintln!("Warning for license template file {:?}: {}",
-                                              lt_path, msg),
+                    if lt_path.len() > 0 {
+                        match license::load_and_compile_template(&lt_path) {
+                            Ok(re) => self.license_template = Some(re),
+                            Err(msg) => eprintln!("Warning for license template file {:?}: {}",
+                                                lt_path, msg),
+                        }
                     }
                 }
             }