about summary refs log tree commit diff
path: root/src/librustdoc/clean/utils.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/librustdoc/clean/utils.rs')
-rw-r--r--src/librustdoc/clean/utils.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs
index 9c0ed1480fe..1e79bd09128 100644
--- a/src/librustdoc/clean/utils.rs
+++ b/src/librustdoc/clean/utils.rs
@@ -521,3 +521,14 @@ crate fn has_doc_flag(attrs: ty::Attributes<'_>, flag: Symbol) -> bool {
             && attr.meta_item_list().map_or(false, |l| rustc_attr::list_contains_name(&l, flag))
     })
 }
+
+/// Return a channel suitable for using in a `doc.rust-lang.org/{channel}` format string.
+crate fn doc_rust_lang_org_channel() -> &'static str {
+    match env!("CFG_RELEASE_CHANNEL") {
+        "stable" => env!("CFG_RELEASE_NUM"),
+        "beta" => "beta",
+        "nightly" | "dev" => "nightly",
+        // custom build of rustdoc maybe? link to the stable docs just in case
+        _ => "",
+    }
+}