File tree 3 files changed +54
-1
lines changed 3 files changed +54
-1
lines changed Original file line number Diff line number Diff line change @@ -1205,7 +1205,13 @@ impl TomlManifest {
1205
1205
for ( url, deps) in self . patch . iter ( ) . flat_map ( |x| x) {
1206
1206
let url = match & url[ ..] {
1207
1207
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
+ } ) ?,
1209
1215
} ;
1210
1216
patch. insert (
1211
1217
url,
Original file line number Diff line number Diff line change @@ -514,3 +514,47 @@ fn passwords_in_url_forbidden() {
514
514
. with_stderr_contains ( "error: Registry URLs may not contain passwords" )
515
515
. run ( ) ;
516
516
}
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() {
734
734
"\
735
735
error: failed to parse manifest at `[..]`
736
736
737
+ Caused by:
738
+ [patch] entry `some-other-source` should be a URL or registry name
739
+
737
740
Caused by:
738
741
invalid url `some-other-source`: relative URL without a base
739
742
" ,
You can’t perform that action at this time.
0 commit comments