File tree Expand file tree Collapse file tree 2 files changed +20
-11
lines changed Expand file tree Collapse file tree 2 files changed +20
-11
lines changed Original file line number Diff line number Diff line change @@ -173,11 +173,20 @@ impl<'a> RegistryQueryer<'a> {
173
173
) ) ) ;
174
174
}
175
175
176
- // The dependency should be hard-coded to have the same name and an
177
- // exact version requirement, so both of these assertions should
178
- // never fail.
179
- assert_eq ! ( s. version( ) , summary. version( ) ) ;
180
- assert_eq ! ( s. name( ) , summary. name( ) ) ;
176
+ assert_eq ! (
177
+ s. name( ) ,
178
+ summary. name( ) ,
179
+ "dependency should be hard coded to have the same name"
180
+ ) ;
181
+ if s. version ( ) != summary. version ( ) {
182
+ return Poll :: Ready ( Err ( anyhow:: anyhow!(
183
+ "replacement specification `{}` matched {} and tried to override it with {}\n \
184
+ avoid matching unrelated packages by being more specific",
185
+ spec,
186
+ summary. version( ) ,
187
+ s. version( ) ,
188
+ ) ) ) ;
189
+ }
181
190
182
191
let replace = if s. source_id ( ) == summary. source_id ( ) {
183
192
debug ! ( "Preventing\n {:?}\n from replacing\n {:?}" , summary, s) ;
Original file line number Diff line number Diff line change @@ -1300,7 +1300,7 @@ fn override_plus_dep() {
1300
1300
}
1301
1301
1302
1302
#[ cargo_test]
1303
- fn override_different_metadata ( ) {
1303
+ fn override_generic_matching_other_versions ( ) {
1304
1304
Package :: new ( "bar" , "0.1.0+a" ) . publish ( ) ;
1305
1305
1306
1306
let bar = git:: repo ( & paths:: root ( ) . join ( "override" ) )
@@ -1338,11 +1338,11 @@ fn override_different_metadata() {
1338
1338
"\
1339
1339
[UPDATING] `dummy-registry` index
1340
1340
[UPDATING] git repository `[..]`
1341
- thread 'main' panicked at src/cargo/core/resolver/dep_cache.rs:179:13:
1342
- assertion `left == right` failed
1343
- left: Version { major: 0, minor: 1, patch: 0 }
1344
- right: Version { major: 0, minor: 1, patch: 0, build: BuildMetadata( \" a \" ) }
1345
- note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
1341
+ [ERROR] failed to get `bar` as a dependency of package `foo v0.0.1 ([..]/foo)`
1342
+
1343
+ Caused by:
1344
+ replacement specification `https://github.com/rust-lang/crates.io-index#bar@0.1.0` matched 0.1.0+a and tried to override it with 0.1.0
1345
+ avoid matching unrelated packages by being more specific
1346
1346
" ,
1347
1347
)
1348
1348
. with_status ( 101 )
You can’t perform that action at this time.
0 commit comments