]> git.lizzy.rs Git - rust.git/commitdiff
Use `if let` instead of `match`
authorvarkor <github@varkor.com>
Sat, 23 Mar 2019 13:05:36 +0000 (13:05 +0000)
committervarkor <github@varkor.com>
Sat, 23 Mar 2019 13:05:36 +0000 (13:05 +0000)
src/librustc_resolve/lib.rs

index c9b9898fb41328538548e8b3864f242497ca2358..6929d920219a25d5457d80a2543a47b338f0847c 100644 (file)
@@ -951,7 +951,7 @@ enum RibKind<'a> {
     TraitOrImplItemRibKind,
 
     /// We passed through a function definition. Disallow upvars.
-    /// Permit only those const parameters specified in the function's generics.
+    /// Permit only those const parameters that are specified in the function's generics.
     FnItemRibKind,
 
     /// We passed through an item scope. Disallow upvars.
@@ -3924,19 +3924,16 @@ fn adjust_local_def(&mut self,
                     ribs.next();
                 }
                 for rib in ribs {
-                    match rib.kind {
-                        ItemRibKind | FnItemRibKind => {
-                            // This was an attempt to use a const parameter outside its scope.
-                            if record_used {
-                                resolve_error(
-                                    self,
-                                    span,
-                                    ResolutionError::GenericParamsFromOuterFunction(def),
-                                );
-                            }
-                            return Def::Err;
+                    if let ItemRibKind | FnItemRibKind = rib.kind {
+                        // This was an attempt to use a const parameter outside its scope.
+                        if record_used {
+                            resolve_error(
+                                self,
+                                span,
+                                ResolutionError::GenericParamsFromOuterFunction(def),
+                            );
                         }
-                        _ => {}
+                        return Def::Err;
                     }
                 }
             }