File tree Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,14 @@ impl<'a> RegistryQueryer<'a> {
105105 dep. version_req( )
106106 ) ;
107107
108+ if dep. features ( ) . len ( ) != 0 || !dep. uses_default_features ( ) {
109+ anyhow:: bail!(
110+ "patch for `{}` uses the features mechanism. \
111+ default-features and features will not take effect because the patch dependency does not support this mechanism",
112+ dep. package_name( )
113+ ) ;
114+ }
115+
108116 let mut summaries = self . registry . query_vec ( dep, false ) ?. into_iter ( ) ;
109117 let s = summaries. next ( ) . ok_or_else ( || {
110118 anyhow:: format_err!(
Original file line number Diff line number Diff line change @@ -52,6 +52,55 @@ fn override_simple() {
5252 . run ( ) ;
5353}
5454
55+ #[ cargo_test]
56+ fn override_with_features ( ) {
57+ Package :: new ( "bar" , "0.1.0" ) . publish ( ) ;
58+
59+ let bar = git:: repo ( & paths:: root ( ) . join ( "override" ) )
60+ . file ( "Cargo.toml" , & basic_manifest ( "bar" , "0.1.0" ) )
61+ . file ( "src/lib.rs" , "pub fn bar() {}" )
62+ . build ( ) ;
63+
64+ let p = project ( )
65+ . file (
66+ "Cargo.toml" ,
67+ & format ! (
68+ r#"
69+ [package]
70+ name = "foo"
71+ version = "0.0.1"
72+ authors = []
73+
74+ [dependencies]
75+ bar = "0.1.0"
76+
77+ [replace]
78+ "bar:0.1.0" = {{ git = '{}', features = ["some_feature"] }}
79+ "# ,
80+ bar. url( )
81+ ) ,
82+ )
83+ . file (
84+ "src/lib.rs" ,
85+ "extern crate bar; pub fn foo() { bar::bar(); }" ,
86+ )
87+ . build ( ) ;
88+
89+ p. cargo ( "build" )
90+ . with_status ( 101 )
91+ . with_stderr (
92+ "\
93+ [UPDATING] [..] index
94+ [ERROR] failed to get `bar` as a dependency of package `foo v0.0.1 ([..])`
95+
96+ Caused by:
97+ patch for `bar` uses the features mechanism. default-features and features \
98+ will not take effect because the patch dependency does not support this mechanism
99+ " ,
100+ )
101+ . run ( ) ;
102+ }
103+
55104#[ cargo_test]
56105fn missing_version ( ) {
57106 let p = project ( )
You can’t perform that action at this time.
0 commit comments