]> git.lizzy.rs Git - rust.git/commitdiff
Change error handling style for consistency
authorChristian Poveda <christianpoveda@protonmail.com>
Fri, 11 Oct 2019 13:20:32 +0000 (08:20 -0500)
committerChristian Poveda <christianpoveda@protonmail.com>
Fri, 11 Oct 2019 13:20:32 +0000 (08:20 -0500)
src/helpers.rs
src/shims/env.rs

index b2a462ef906753f946c065d5857de4ce0c39d1ca..c7b7853388cc543e4f871a1c8f9f87859c6abe86 100644 (file)
@@ -296,12 +296,12 @@ fn visit_primitive(&mut self, _v: MPlaceTy<'tcx, Tag>) -> InterpResult<'tcx>
     fn eval_libc(&mut self, name: &str) -> InterpResult<'tcx, Scalar<Tag>> {
         self.eval_context_mut()
             .eval_path_scalar(&["libc", name])?
-            .ok_or_else(|| err_unsup_format!("Path libc::{} cannot be resolved.", name).into())
-            .and_then(|scalar| scalar.not_undef())
+            .ok_or_else(|| err_unsup_format!("Path libc::{} cannot be resolved.", name))?
+            .not_undef()
     }
 
     /// Helper function to get a `libc` constant as an `i32`.
     fn eval_libc_i32(&mut self, name: &str) -> InterpResult<'tcx, i32> {
-        self.eval_libc(name).and_then(|scalar| scalar.to_i32())
+        self.eval_libc(name)?.to_i32()
     }
 }
index 8c1645cde738e3ba38c5119ba17469deab3274c8..2ccbc0238e5f90f828ada61665dc18fdabeb0788 100644 (file)
@@ -135,7 +135,7 @@ fn getcwd(
                 let mut bytes = cwd.display().to_string().into_bytes();
                 // If `size` is smaller or equal than the `bytes.len()`, writing `bytes` plus the
                 // required null terminator to memory using the `buf` pointer would cause an
-                // overflow, the desired behavior in this case is to return null.
+                // overflow. The desired behavior in this case is to return null.
                 if (bytes.len() as u64) < size {
                     // We add a `/0` terminator
                     bytes.push(0);