Skip to content

Commit 498ef7d

Browse files
committed
Use channel-specific link for registry auth error
1 parent 976771d commit 498ef7d

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/cargo/core/features.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -530,15 +530,9 @@ impl Features {
530530
}
531531

532532
let see_docs = || {
533-
let url_channel = match channel().as_str() {
534-
"dev" | "nightly" => "nightly/",
535-
"beta" => "beta/",
536-
_ => "",
537-
};
538533
format!(
539-
"See https://doc.rust-lang.org/{}cargo/{} for more information \
540-
about using this feature.",
541-
url_channel, feature.docs
534+
"See {} for more information about using this feature.",
535+
cargo_docs_link(feature.docs)
542536
)
543537
};
544538

@@ -1231,3 +1225,14 @@ pub fn channel() -> String {
12311225
fn cargo_use_gitoxide_instead_of_git2() -> bool {
12321226
std::env::var_os("__CARGO_USE_GITOXIDE_INSTEAD_OF_GIT2").map_or(false, |value| value == "1")
12331227
}
1228+
1229+
/// Generate a link to Cargo documentation for the current release channel
1230+
/// `path` is the URL component after `https://doc.rust-lang.org/{channel}/cargo/`
1231+
pub fn cargo_docs_link(path: &str) -> String {
1232+
let url_channel = match channel().as_str() {
1233+
"dev" | "nightly" => "nightly/",
1234+
"beta" => "beta/",
1235+
_ => "",
1236+
};
1237+
format!("https://doc.rust-lang.org/{url_channel}cargo/{path}")
1238+
}

src/cargo/util/auth/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Registry authentication support.
22
33
use crate::{
4+
core::features::cargo_docs_link,
45
sources::CRATES_IO_REGISTRY,
56
util::{config::ConfigKey, CanonicalUrl, CargoResult, Config, IntoUrl},
67
};
@@ -219,7 +220,8 @@ fn credential_provider(
219220
if !global_provider_defined && require_cred_provider_config {
220221
bail!(
221222
"authenticated registries require a credential-provider to be configured\n\
222-
see https://doc.rust-lang.org/cargo/reference/registry-authentication.html for details"
223+
see {} for details",
224+
cargo_docs_link("reference/registry-authentication.html")
223225
);
224226
}
225227
Ok(global_providers)

0 commit comments

Comments
 (0)