Skip to content

Commit 858c012

Browse files
committed
refactor: rename SourceId:for_alt_registry to for_named_registry
1 parent d6c7b20 commit 858c012

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

src/cargo/core/source_id.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,15 @@ impl SourceId {
218218
/// Creates a SourceId from a remote registry URL when the registry name
219219
/// cannot be determined, e.g. a user passes `--index` directly from CLI.
220220
///
221-
/// Use [`SourceId::for_alt_registry`] if a name can provided, which
221+
/// Use [`SourceId::for_named_registry`] if a name can provided, which
222222
/// generates better messages for cargo.
223223
pub fn for_registry(url: &Url) -> CargoResult<SourceId> {
224224
let kind = Self::remote_source_kind(url);
225225
SourceId::new(kind, url.to_owned(), None)
226226
}
227227

228228
/// Creates a `SourceId` from a remote registry URL with given name.
229-
pub fn for_alt_registry(url: &Url, name: &str) -> CargoResult<SourceId> {
229+
pub fn for_named_registry(url: &Url, name: &str) -> CargoResult<SourceId> {
230230
let kind = Self::remote_source_kind(url);
231231
SourceId::new(kind, url.to_owned(), Some(name))
232232
}
@@ -288,7 +288,7 @@ impl SourceId {
288288
return Self::crates_io(config);
289289
}
290290
let url = config.get_registry_index(key)?;
291-
Self::for_alt_registry(&url, key)
291+
Self::for_named_registry(&url, key)
292292
}
293293

294294
/// Gets this source URL.
@@ -926,7 +926,7 @@ mod tests {
926926
assert_eq!(crate::util::hex::short_hash(&source_id), "fb60813d6cb8df79");
927927

928928
let url = "https://your-crates.io".into_url().unwrap();
929-
let source_id = SourceId::for_alt_registry(&url, "alt").unwrap();
929+
let source_id = SourceId::for_named_registry(&url, "alt").unwrap();
930930
assert_eq!(gen_hash(source_id), 12862859764592646184);
931931
assert_eq!(crate::util::hex::short_hash(&source_id), "09c10fd0cbd74bce");
932932

@@ -936,7 +936,7 @@ mod tests {
936936
assert_eq!(crate::util::hex::short_hash(&source_id), "d1ea0d96f6f759b5");
937937

938938
let url = "sparse+https://your-crates.io".into_url().unwrap();
939-
let source_id = SourceId::for_alt_registry(&url, "alt").unwrap();
939+
let source_id = SourceId::for_named_registry(&url, "alt").unwrap();
940940
assert_eq!(gen_hash(source_id), 5159702466575482972);
941941
assert_eq!(crate::util::hex::short_hash(&source_id), "135d23074253cb78");
942942

src/cargo/sources/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl<'cfg> SourceConfigMap<'cfg> {
112112
base.add(
113113
CRATES_IO_REGISTRY,
114114
SourceConfig {
115-
id: SourceId::for_alt_registry(&url.parse()?, CRATES_IO_REGISTRY)?,
115+
id: SourceId::for_named_registry(&url.parse()?, CRATES_IO_REGISTRY)?,
116116
replace_with: None,
117117
},
118118
)?;
@@ -239,7 +239,7 @@ restore the source replacement configuration to continue the build
239239
let mut srcs = Vec::new();
240240
if let Some(registry) = def.registry {
241241
let url = url(&registry, &format!("source.{}.registry", name))?;
242-
srcs.push(SourceId::for_alt_registry(&url, &name)?);
242+
srcs.push(SourceId::for_named_registry(&url, &name)?);
243243
}
244244
if let Some(local_registry) = def.local_registry {
245245
let path = local_registry.resolve_path(self.config);

src/cargo/util/credential/paseto.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl<'a> Credential for PasetoCredential<'a> {
6565
) -> Result<CredentialResponse, Error> {
6666
let index_url = Url::parse(registry.index_url).context("parsing index url")?;
6767
let sid = if let Some(name) = registry.name {
68-
SourceId::for_alt_registry(&index_url, name)
68+
SourceId::for_named_registry(&index_url, name)
6969
} else {
7070
SourceId::for_registry(&index_url)
7171
}?;

src/cargo/util/credential/token.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl<'a> Credential for TokenCredential<'a> {
3030
) -> Result<CredentialResponse, Error> {
3131
let index_url = Url::parse(registry.index_url).context("parsing index url")?;
3232
let sid = if let Some(name) = registry.name {
33-
SourceId::for_alt_registry(&index_url, name)
33+
SourceId::for_named_registry(&index_url, name)
3434
} else {
3535
SourceId::for_registry(&index_url)
3636
}?;

0 commit comments

Comments
 (0)