File tree 2 files changed +63
-4
lines changed
2 files changed +63
-4
lines changed Original file line number Diff line number Diff line change @@ -316,22 +316,23 @@ fn activate(cx: &mut Context,
316
316
candidate. summary . package_id ( ) . clone ( ) ) ;
317
317
}
318
318
319
- if cx. flag_activated ( & candidate. summary , method) {
320
- return Ok ( None ) ;
321
- }
319
+ let activated = cx. flag_activated ( & candidate. summary , method) ;
322
320
323
321
let candidate = match candidate. replace {
324
322
Some ( replace) => {
325
323
cx. resolve_replacements . insert ( candidate. summary . package_id ( ) . clone ( ) ,
326
324
replace. package_id ( ) . clone ( ) ) ;
327
- if cx. flag_activated ( & replace, method) {
325
+ if cx. flag_activated ( & replace, method) && activated {
328
326
return Ok ( None ) ;
329
327
}
330
328
trace ! ( "activating {} (replacing {})" , replace. package_id( ) ,
331
329
candidate. summary. package_id( ) ) ;
332
330
replace
333
331
}
334
332
None => {
333
+ if activated {
334
+ return Ok ( None )
335
+ }
335
336
trace ! ( "activating {}" , candidate. summary. package_id( ) ) ;
336
337
candidate. summary
337
338
}
Original file line number Diff line number Diff line change @@ -1104,3 +1104,61 @@ warning: path override for crate `foo` has altered the original list of
1104
1104
dependencies; the dependency on `bar` was either added or\
1105
1105
") ) ;
1106
1106
}
1107
+
1108
+ #[ test]
1109
+ fn override_with_default_feature ( ) {
1110
+ Package :: new ( "another" , "0.1.0" ) . publish ( ) ;
1111
+ Package :: new ( "another" , "0.1.1" )
1112
+ . dep ( "bar" , "0.1" )
1113
+ . publish ( ) ;
1114
+ Package :: new ( "bar" , "0.1.0" ) . publish ( ) ;
1115
+
1116
+ let p = project ( "local" )
1117
+ . file ( "Cargo.toml" , r#"
1118
+ [package]
1119
+ name = "local"
1120
+ version = "0.0.1"
1121
+ authors = []
1122
+
1123
+ [dependencies]
1124
+ bar = { path = "bar", default-features = false }
1125
+ another = "0.1"
1126
+ another2 = { path = "another2" }
1127
+
1128
+ [replace]
1129
+ 'bar:0.1.0' = { path = "bar" }
1130
+ "# )
1131
+ . file ( "src/main.rs" , r#"
1132
+ extern crate bar;
1133
+
1134
+ fn main() {
1135
+ bar::bar();
1136
+ }
1137
+ "# )
1138
+ . file ( "bar/Cargo.toml" , r#"
1139
+ [package]
1140
+ name = "bar"
1141
+ version = "0.1.0"
1142
+ authors = []
1143
+
1144
+ [features]
1145
+ default = []
1146
+ "# )
1147
+ . file ( "bar/src/lib.rs" , r#"
1148
+ #[cfg(feature = "default")]
1149
+ pub fn bar() {}
1150
+ "# )
1151
+ . file ( "another2/Cargo.toml" , r#"
1152
+ [package]
1153
+ name = "another2"
1154
+ version = "0.1.0"
1155
+ authors = []
1156
+
1157
+ [dependencies]
1158
+ bar = { version = "0.1", default-features = false }
1159
+ "# )
1160
+ . file ( "another2/src/lib.rs" , "" ) ;
1161
+
1162
+ assert_that ( p. cargo_process ( "run" ) ,
1163
+ execs ( ) . with_status ( 0 ) ) ;
1164
+ }
You can’t perform that action at this time.
0 commit comments