File tree Expand file tree Collapse file tree 3 files changed +13
-6
lines changed Expand file tree Collapse file tree 3 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -94,7 +94,6 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult {
94
94
ops:: fix (
95
95
gctx,
96
96
& ws,
97
- & root_manifest,
98
97
& mut ops:: FixOptions {
99
98
edition : args. flag ( "edition" ) ,
100
99
idioms : args. flag ( "edition-idioms" ) ,
Original file line number Diff line number Diff line change @@ -301,6 +301,18 @@ impl<'gctx> Workspace<'gctx> {
301
301
Ok ( ws)
302
302
}
303
303
304
+ /// Reloads the workspace.
305
+ ///
306
+ /// This is useful if the workspace has been updated, such as with `cargo
307
+ /// fix` modifying the `Cargo.toml` file.
308
+ pub fn reload ( & self , gctx : & ' gctx GlobalContext ) -> CargoResult < Workspace < ' gctx > > {
309
+ let mut ws = Workspace :: new ( self . root_manifest ( ) , gctx) ?;
310
+ ws. set_resolve_honors_rust_version ( Some ( self . resolve_honors_rust_version ) ) ;
311
+ ws. set_resolve_feature_unification ( self . resolve_feature_unification ) ;
312
+ ws. set_requested_lockfile_path ( self . requested_lockfile_path . clone ( ) ) ;
313
+ Ok ( ws)
314
+ }
315
+
304
316
fn set_resolve_behavior ( & mut self ) -> CargoResult < ( ) > {
305
317
// - If resolver is specified in the workspace definition, use that.
306
318
// - If the root package specifies the resolver, use that.
Original file line number Diff line number Diff line change @@ -103,7 +103,6 @@ pub struct FixOptions {
103
103
pub fn fix (
104
104
gctx : & GlobalContext ,
105
105
original_ws : & Workspace < ' _ > ,
106
- root_manifest : & Path ,
107
106
opts : & mut FixOptions ,
108
107
) -> CargoResult < ( ) > {
109
108
check_version_control ( gctx, opts) ?;
@@ -120,10 +119,7 @@ pub fn fix(
120
119
121
120
check_resolver_change ( & original_ws, & mut target_data, opts) ?;
122
121
}
123
- let mut ws = Workspace :: new ( & root_manifest, gctx) ?;
124
- ws. set_resolve_honors_rust_version ( Some ( original_ws. resolve_honors_rust_version ( ) ) ) ;
125
- ws. set_resolve_feature_unification ( original_ws. resolve_feature_unification ( ) ) ;
126
- ws. set_requested_lockfile_path ( opts. requested_lockfile_path . clone ( ) ) ;
122
+ let ws = original_ws. reload ( gctx) ?;
127
123
128
124
// Spin up our lock server, which our subprocesses will use to synchronize fixes.
129
125
let lock_server = LockServer :: new ( ) ?;
You can’t perform that action at this time.
0 commit comments