Patchwork D3454: Assign to result from block.

login
register
mail settings
Submitter phabricator
Date May 6, 2018, 8:17 a.m.
Message ID <differential-rev-PHID-DREV-kkkjthofkmzgz2wd7rhw-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/31290/
State New
Headers show

Comments

phabricator - May 6, 2018, 8:17 a.m.
kevincox created this revision.
kevincox added a reviewer: indygreg.
Herald added subscribers: mercurial-devel, durin42.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This is more idiomatic because you don't have uninitialized variables and has less typing.

REPOSITORY
  rHG Mercurial

BRANCH
  arcpatch-D3447 (bookmark) on default (branch)

REVISION DETAIL
  https://phab.mercurial-scm.org/D3454

AFFECTED FILES
  rust/hgcli/src/main.rs

CHANGE DETAILS




To: kevincox, indygreg, #hg-reviewers
Cc: durin42, mercurial-devel
phabricator - May 9, 2018, 9:16 p.m.
martinvonz added a comment.


  This doesn't apply. Looks like it's based on a version where exit code is 1 (line 193), but our main.rs seems to have always have had it set to 255.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3454

To: kevincox, indygreg, #hg-reviewers
Cc: martinvonz, durin42, mercurial-devel
phabricator - May 12, 2018, 3:51 a.m.
indygreg accepted this revision.
indygreg added a comment.
This revision is now accepted and ready to land.


  It looks like this is based on top of https://phab.mercurial-scm.org/D3447. So I'll just hook up the dependency and we'll land it as soon as my series is landed.

REPOSITORY
  rHG Mercurial

BRANCH
  arcpatch-D3447 (bookmark) on default (branch)

REVISION DETAIL
  https://phab.mercurial-scm.org/D3454

To: kevincox, indygreg, #hg-reviewers
Cc: martinvonz, durin42, mercurial-devel

Patch

diff --git a/rust/hgcli/src/main.rs b/rust/hgcli/src/main.rs
--- a/rust/hgcli/src/main.rs
+++ b/rust/hgcli/src/main.rs
@@ -177,8 +177,7 @@ 
         python27_sys::PySys_SetArgvEx(args.len() as c_int, argv.as_ptr() as *mut *mut i8, 0);
     }
 
-    let result;
-    {
+    let result = {
         // These need to be dropped before we call Py_Finalize(). Hence the
         // block.
         let gil = Python::acquire_gil();
@@ -189,7 +188,7 @@ 
         // TODO this may cause issues on Windows due to the CRT mismatch.
         // Investigate if we can intercept sys.exit() or SystemExit() to
         // ensure we handle process exit.
-        result = match run_py(&env, py) {
+        match run_py(&env, py) {
             // Print unhandled exceptions and exit code 1, as this is what
             // `python` does.
             Err(err) => {
@@ -205,8 +204,8 @@ 
                 };
                 Err(code)
             }
-        };
-    }
+        }
+    };
 
     unsafe {
         python27_sys::Py_Finalize();