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 {
9494 ops:: fix (
9595 gctx,
9696 & ws,
97- & root_manifest,
9897 & mut ops:: FixOptions {
9998 edition : args. flag ( "edition" ) ,
10099 idioms : args. flag ( "edition-idioms" ) ,
Original file line number Diff line number Diff line change @@ -301,6 +301,18 @@ impl<'gctx> Workspace<'gctx> {
301301 Ok ( ws)
302302 }
303303
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+
304316 fn set_resolve_behavior ( & mut self ) -> CargoResult < ( ) > {
305317 // - If resolver is specified in the workspace definition, use that.
306318 // - 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 {
103103pub fn fix (
104104 gctx : & GlobalContext ,
105105 original_ws : & Workspace < ' _ > ,
106- root_manifest : & Path ,
107106 opts : & mut FixOptions ,
108107) -> CargoResult < ( ) > {
109108 check_version_control ( gctx, opts) ?;
@@ -120,10 +119,7 @@ pub fn fix(
120119
121120 check_resolver_change ( & original_ws, & mut target_data, opts) ?;
122121 }
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) ?;
127123
128124 // Spin up our lock server, which our subprocesses will use to synchronize fixes.
129125 let lock_server = LockServer :: new ( ) ?;
You can’t perform that action at this time.
0 commit comments