]> git.lizzy.rs Git - rust.git/commitdiff
Cleanup `fn is_mutable` by removing some unnecessary control-flow breaks.
authorFelix S. Klock II <pnkfelix@pnkfx.org>
Tue, 16 Oct 2018 13:50:44 +0000 (15:50 +0200)
committerFelix S. Klock II <pnkfelix@pnkfx.org>
Tue, 16 Oct 2018 14:58:08 +0000 (16:58 +0200)
(This makes it a little easier to add instrumentation of the entry and
exit by adding `debug!` at the beginning and end, though note that the
function body *does* use the `?` operator...)

src/librustc_mir/borrow_check/mod.rs

index f9a1e1e1108254ce47d12e8581380a836fb4e44a..ae79394dfebe09aa9a423d4b25b1ff0aca394082 100644 (file)
@@ -1943,7 +1943,7 @@ fn add_used_mut<'d>(
         }
     }
 
-    /// Whether this value be written or borrowed mutably.
+    /// Whether this value can be written or borrowed mutably.
     /// Returns the root place if the place passed in is a projection.
     fn is_mutable<'d>(
         &self,
@@ -2021,14 +2021,14 @@ fn is_mutable<'d>(
                             ty::RawPtr(tnm) => {
                                 match tnm.mutbl {
                                     // `*const` raw pointers are not mutable
-                                    hir::MutImmutable => return Err(place),
+                                    hir::MutImmutable => Err(place),
                                     // `*mut` raw pointers are always mutable, regardless of
                                     // context. The users have to check by themselves.
                                     hir::MutMutable => {
-                                        return Ok(RootPlace {
+                                        Ok(RootPlace {
                                             place,
                                             is_local_mutation_allowed,
-                                        });
+                                        })
                                     }
                                 }
                             }