File tree Expand file tree Collapse file tree 3 files changed +54
-1
lines changed Expand file tree Collapse file tree 3 files changed +54
-1
lines changed Original file line number Diff line number Diff line change @@ -1205,7 +1205,13 @@ impl TomlManifest {
12051205 for ( url, deps) in self . patch . iter ( ) . flat_map ( |x| x) {
12061206 let url = match & url[ ..] {
12071207 CRATES_IO_REGISTRY => CRATES_IO_INDEX . parse ( ) . unwrap ( ) ,
1208- _ => url. to_url ( ) ?,
1208+ _ => cx
1209+ . config
1210+ . get_registry_index ( url)
1211+ . or_else ( |_| url. to_url ( ) )
1212+ . chain_err ( || {
1213+ format ! ( "[patch] entry `{}` should be a URL or registry name" , url)
1214+ } ) ?,
12091215 } ;
12101216 patch. insert (
12111217 url,
Original file line number Diff line number Diff line change @@ -514,3 +514,47 @@ fn passwords_in_url_forbidden() {
514514 . with_stderr_contains ( "error: Registry URLs may not contain passwords" )
515515 . run ( ) ;
516516}
517+
518+ #[ test]
519+ fn patch_alt_reg ( ) {
520+ Package :: new ( "bar" , "0.1.0" ) . publish ( ) ;
521+ let p = project ( )
522+ . file (
523+ "Cargo.toml" ,
524+ r#"
525+ cargo-features = ["alternative-registries"]
526+
527+ [package]
528+ name = "foo"
529+ version = "0.0.1"
530+
531+ [dependencies]
532+ bar = { version = "0.1.0", registry = "alternative" }
533+
534+ [patch.alternative]
535+ bar = { path = "bar" }
536+ "# ,
537+ )
538+ . file (
539+ "src/lib.rs" ,
540+ "
541+ extern crate bar;
542+ pub fn f() { bar::bar(); }
543+ " ,
544+ )
545+ . file ( "bar/Cargo.toml" , & basic_manifest ( "bar" , "0.1.0" ) )
546+ . file ( "bar/src/lib.rs" , "pub fn bar() {}" )
547+ . build ( ) ;
548+
549+ p. cargo ( "build" )
550+ . masquerade_as_nightly_cargo ( )
551+ . with_stderr (
552+ "\
553+ [UPDATING] `[ROOT][..]` index
554+ [COMPILING] bar v0.1.0 ([CWD]/bar)
555+ [COMPILING] foo v0.0.1 ([CWD])
556+ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
557+ " ,
558+ )
559+ . run ( ) ;
560+ }
Original file line number Diff line number Diff line change @@ -734,6 +734,9 @@ fn non_crates_io() {
734734 "\
735735 error: failed to parse manifest at `[..]`
736736
737+ Caused by:
738+ [patch] entry `some-other-source` should be a URL or registry name
739+
737740Caused by:
738741 invalid url `some-other-source`: relative URL without a base
739742" ,
You can’t perform that action at this time.
0 commit comments