@@ -69,6 +69,7 @@ use crate::core::{GitReference, PackageId, PackageIdSpec, PackageSet, SourceId,
69
69
use crate :: ops;
70
70
use crate :: sources:: PathSource ;
71
71
use crate :: util:: errors:: CargoResult ;
72
+ use crate :: util:: PartialVersion ;
72
73
use crate :: util:: { profile, CanonicalUrl } ;
73
74
use anyhow:: Context as _;
74
75
use std:: collections:: { HashMap , HashSet } ;
@@ -106,8 +107,15 @@ version. This may also occur with an optional dependency that is not enabled.";
106
107
/// This is a simple interface used by commands like `clean`, `fetch`, and
107
108
/// `package`, which don't specify any options or features.
108
109
pub fn resolve_ws < ' a > ( ws : & Workspace < ' a > ) -> CargoResult < ( PackageSet < ' a > , Resolve ) > {
110
+ // TODO `honor_rust_version`
111
+ let max_rust_version = if ws. is_ephemeral ( ) {
112
+ None // TODO
113
+ } else {
114
+ ws. rust_version ( )
115
+ } ;
116
+
109
117
let mut registry = PackageRegistry :: new ( ws. config ( ) ) ?;
110
- let resolve = resolve_with_registry ( ws, & mut registry) ?;
118
+ let resolve = resolve_with_registry ( ws, & mut registry, max_rust_version ) ?;
111
119
let packages = get_resolved_packages ( & resolve, registry) ?;
112
120
Ok ( ( packages, resolve) )
113
121
}
@@ -130,6 +138,7 @@ pub fn resolve_ws_with_opts<'cfg>(
130
138
specs : & [ PackageIdSpec ] ,
131
139
has_dev_units : HasDevUnits ,
132
140
force_all_targets : ForceAllTargets ,
141
+ max_rust_version : Option < PartialVersion > ,
133
142
) -> CargoResult < WorkspaceResolve < ' cfg > > {
134
143
let mut registry = PackageRegistry :: new ( ws. config ( ) ) ?;
135
144
let mut add_patches = true ;
@@ -138,7 +147,7 @@ pub fn resolve_ws_with_opts<'cfg>(
138
147
} else if ws. require_optional_deps ( ) {
139
148
// First, resolve the root_package's *listed* dependencies, as well as
140
149
// downloading and updating all remotes and such.
141
- let resolve = resolve_with_registry ( ws, & mut registry) ?;
150
+ let resolve = resolve_with_registry ( ws, & mut registry, max_rust_version ) ?;
142
151
// No need to add patches again, `resolve_with_registry` has done it.
143
152
add_patches = false ;
144
153
@@ -184,6 +193,7 @@ pub fn resolve_ws_with_opts<'cfg>(
184
193
None ,
185
194
specs,
186
195
add_patches,
196
+ max_rust_version,
187
197
) ?;
188
198
189
199
let pkg_set = get_resolved_packages ( & resolved_with_overrides, registry) ?;
@@ -235,6 +245,7 @@ pub fn resolve_ws_with_opts<'cfg>(
235
245
fn resolve_with_registry < ' cfg > (
236
246
ws : & Workspace < ' cfg > ,
237
247
registry : & mut PackageRegistry < ' cfg > ,
248
+ max_rust_version : Option < PartialVersion > ,
238
249
) -> CargoResult < Resolve > {
239
250
let prev = ops:: load_pkg_lockfile ( ws) ?;
240
251
let mut resolve = resolve_with_previous (
@@ -246,6 +257,7 @@ fn resolve_with_registry<'cfg>(
246
257
None ,
247
258
& [ ] ,
248
259
true ,
260
+ max_rust_version,
249
261
) ?;
250
262
251
263
if !ws. is_ephemeral ( ) && ws. require_optional_deps ( ) {
@@ -278,6 +290,7 @@ pub fn resolve_with_previous<'cfg>(
278
290
to_avoid : Option < & HashSet < PackageId > > ,
279
291
specs : & [ PackageIdSpec ] ,
280
292
register_patches : bool ,
293
+ max_rust_version : Option < PartialVersion > ,
281
294
) -> CargoResult < Resolve > {
282
295
// We only want one Cargo at a time resolving a crate graph since this can
283
296
// involve a lot of frobbing of the global caches.
@@ -505,6 +518,7 @@ pub fn resolve_with_previous<'cfg>(
505
518
ws. unstable_features ( )
506
519
. require ( Feature :: public_dependency ( ) )
507
520
. is_ok ( ) ,
521
+ max_rust_version,
508
522
) ?;
509
523
let patches: Vec < _ > = registry
510
524
. patches ( )
0 commit comments