]> git.lizzy.rs Git - rust.git/blobdiff - src/config/config_type.rs
Release v1.4.2
[rust.git] / src / config / config_type.rs
index 26cd672f83ab64b2c18af9b4b924c842469586ca..7b91f54877d3820cce6e1c058622b19afc8a9175 100644 (file)
@@ -50,23 +50,6 @@ fn doc_hint() -> String {
     }
 }
 
-/// Checks if we're in a nightly build.
-///
-/// The environment variable `CFG_RELEASE_CHANNEL` is set during the rustc bootstrap
-/// to "stable", "beta", or "nightly" depending on what toolchain is being built.
-/// If we are being built as part of the stable or beta toolchains, we want
-/// to disable unstable configuration options.
-///
-/// If we're being built by cargo (e.g., `cargo +nightly install rustfmt-nightly`),
-/// `CFG_RELEASE_CHANNEL` is not set. As we only support being built against the
-/// nightly compiler when installed from crates.io, default to nightly mode.
-#[macro_export]
-macro_rules! is_nightly_channel {
-    () => {
-        option_env!("CFG_RELEASE_CHANNEL").map_or(true, |c| c == "nightly" || c == "dev")
-    };
-}
-
 macro_rules! create_config {
     ($($i:ident: $ty:ty, $def:expr, $stb:expr, $( $dstring:expr ),+ );+ $(;)*) => (
         #[cfg(test)]
@@ -160,7 +143,7 @@ fn fill_from_parsed_config(mut self, parsed: PartialConfig, dir: &Path) -> Confi
                         self.$i.1 = true;
                         self.$i.2 = val;
                     } else {
-                        if is_nightly_channel!() {
+                        if crate::is_nightly_channel!() {
                             self.$i.1 = true;
                             self.$i.2 = val;
                         } else {
@@ -266,11 +249,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();