Skip to content

Commit

Permalink
add a Source::parse arm for sparse repos (keeping it in the scheme). … (
Browse files Browse the repository at this point in the history
#2950)

Proc macro resolution wasn't working properly for sparse repos. This
fixes #2938.

---------

Co-authored-by: Daniel Wagner-Hall <[email protected]>
Co-authored-by: Daniel Wagner-Hall <[email protected]>
  • Loading branch information
3 people authored Oct 20, 2024
1 parent d08b20d commit 60141ec
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions crate_universe/src/metadata/cargo_tree_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,11 @@ impl Source {
let original_scheme = url.scheme().to_owned();
let scheme_parts: Vec<_> = original_scheme.split('+').collect();
match &scheme_parts[..] {
// e.g. sparse+https://github.com/rust-lang/crates.io-index
["sparse", _] => Ok(Self::Registry {
registry: url.to_string(),
version,
}),
// e.g. registry+https://github.com/rust-lang/crates.io-index
["registry", scheme] => {
let new_url = set_url_scheme_despite_the_url_crate_not_wanting_us_to(&url, scheme)?;
Expand Down Expand Up @@ -936,6 +941,25 @@ mod test {

use super::*;

#[test]
fn parse_sparse_source() {
let source = Source::parse(
"sparse+https://github.com/rust-lang/crates.io-index",
"1.0.1".to_owned(),
)
.unwrap();
// sparse we want to leave the augmented scheme in there.
// cargo_toml::DependencyDetail::registry_index explicitly supports
// sparse+https:
assert_eq!(
source,
Source::Registry {
registry: "sparse+https://github.com/rust-lang/crates.io-index".to_owned(),
version: "1.0.1".to_owned()
}
);
}

#[test]
fn parse_registry_source() {
let source = Source::parse(
Expand Down

0 comments on commit 60141ec

Please sign in to comment.