Skip to content

Commit 23e91c3

Browse files
committed
refactor: use registry_key for getting crates.io key
`registry_key` should always be `crates-io` when `is_crates_io()` is true This also removes the test verifying `Debug` output, whose format doesn't need to be guaranteed.
1 parent 17fdd58 commit 23e91c3

File tree

2 files changed

+1
-40
lines changed

2 files changed

+1
-40
lines changed

src/cargo/core/package_id.rs

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -251,43 +251,6 @@ mod tests {
251251
assert!(PackageId::new("foo", "", repo).is_err());
252252
}
253253

254-
#[test]
255-
fn debug() {
256-
let loc = CRATES_IO_INDEX.into_url().unwrap();
257-
let pkg_id = PackageId::new("foo", "1.0.0", SourceId::for_registry(&loc).unwrap()).unwrap();
258-
assert_eq!(
259-
r#"PackageId { name: "foo", version: "1.0.0", source: "registry `crates-io`" }"#,
260-
format!("{:?}", pkg_id)
261-
);
262-
263-
let expected = r#"
264-
PackageId {
265-
name: "foo",
266-
version: "1.0.0",
267-
source: "registry `crates-io`",
268-
}
269-
"#
270-
.trim();
271-
272-
// Can be removed once trailing commas in Debug have reached the stable
273-
// channel.
274-
let expected_without_trailing_comma = r#"
275-
PackageId {
276-
name: "foo",
277-
version: "1.0.0",
278-
source: "registry `crates-io`"
279-
}
280-
"#
281-
.trim();
282-
283-
let actual = format!("{:#?}", pkg_id);
284-
if actual.ends_with(",\n}") {
285-
assert_eq!(actual, expected);
286-
} else {
287-
assert_eq!(actual, expected_without_trailing_comma);
288-
}
289-
}
290-
291254
#[test]
292255
fn display() {
293256
let loc = CRATES_IO_INDEX.into_url().unwrap();

src/cargo/core/source_id.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,7 @@ impl SourceId {
330330

331331
/// Displays the name of a registry if it has one. Otherwise just the URL.
332332
pub fn display_registry_name(self) -> String {
333-
if self.is_crates_io() {
334-
CRATES_IO_REGISTRY.to_string()
335-
} else if let Some(key) = self.inner.registry_key.as_ref().map(|k| k.key()) {
333+
if let Some(key) = self.inner.registry_key.as_ref().map(|k| k.key()) {
336334
key.into()
337335
} else if self.precise().is_some() {
338336
// We remove `precise` here to retrieve an permissive version of

0 commit comments

Comments
 (0)