File tree 2 files changed +58
-2
lines changed 2 files changed +58
-2
lines changed Original file line number Diff line number Diff line change @@ -73,7 +73,6 @@ use crate::util::cache_lock::CacheLockMode;
73
73
use crate :: util:: errors:: CargoResult ;
74
74
use crate :: util:: CanonicalUrl ;
75
75
use anyhow:: Context as _;
76
- use cargo_util_schemas:: manifest:: RustVersion ;
77
76
use std:: collections:: { HashMap , HashSet } ;
78
77
use tracing:: { debug, trace} ;
79
78
@@ -304,7 +303,14 @@ pub fn resolve_with_previous<'gctx>(
304
303
version_prefs. version_ordering ( VersionOrdering :: MinimumVersionsFirst )
305
304
}
306
305
if ws. resolve_honors_rust_version ( ) {
307
- version_prefs. max_rust_version ( ws. rust_version ( ) . cloned ( ) . map ( RustVersion :: into_partial) ) ;
306
+ let rust_version = if let Some ( ver) = ws. rust_version ( ) {
307
+ ver. clone ( ) . into_partial ( )
308
+ } else {
309
+ let rustc = ws. gctx ( ) . load_global_rustc ( Some ( ws) ) ?;
310
+ let rustc_version = rustc. version . clone ( ) . into ( ) ;
311
+ rustc_version
312
+ } ;
313
+ version_prefs. max_rust_version ( Some ( rust_version) ) ;
308
314
}
309
315
310
316
let avoid_patch_ids = if register_patches {
Original file line number Diff line number Diff line change @@ -370,6 +370,56 @@ fn dependency_rust_version_older_and_newer_than_package() {
370
370
. run ( ) ;
371
371
}
372
372
373
+ #[ cargo_test]
374
+ fn resolve_with_rustc ( ) {
375
+ Package :: new ( "bar" , "1.5.0" )
376
+ . rust_version ( "1.0" )
377
+ . file ( "src/lib.rs" , "fn other_stuff() {}" )
378
+ . publish ( ) ;
379
+ Package :: new ( "bar" , "1.6.0" )
380
+ . rust_version ( "1.2345" )
381
+ . file ( "src/lib.rs" , "fn other_stuff() {}" )
382
+ . publish ( ) ;
383
+
384
+ let p = project ( )
385
+ . file (
386
+ "Cargo.toml" ,
387
+ r#"
388
+ [package]
389
+ name = "foo"
390
+ version = "0.0.1"
391
+ edition = "2015"
392
+ authors = []
393
+ [dependencies]
394
+ bar = "1.0.0"
395
+ "# ,
396
+ )
397
+ . file ( "src/main.rs" , "fn main(){}" )
398
+ . build ( ) ;
399
+
400
+ p. cargo ( "generate-lockfile --ignore-rust-version" )
401
+ . arg ( "-Zmsrv-policy" )
402
+ . masquerade_as_nightly_cargo ( & [ "msrv-policy" ] )
403
+ . with_stderr (
404
+ "\
405
+ [UPDATING] `dummy-registry` index
406
+ [LOCKING] 2 packages
407
+ " ,
408
+ )
409
+ . run ( ) ;
410
+ p. cargo ( "generate-lockfile" )
411
+ . arg ( "-Zmsrv-policy" )
412
+ . masquerade_as_nightly_cargo ( & [ "msrv-policy" ] )
413
+ . with_stderr (
414
+ "\
415
+ [UPDATING] `dummy-registry` index
416
+ [LOCKING] 2 packages
417
+ [ADDING] bar v1.5.0 (latest: v1.6.0)
418
+ " ,
419
+ )
420
+ . run ( ) ;
421
+ }
422
+
373
423
#[ cargo_test]
374
424
fn dependency_rust_version_backtracking ( ) {
375
425
Package :: new ( "has-rust-version" , "1.6.0" )
You can’t perform that action at this time.
0 commit comments