about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-01-16 12:57:20 -0800
committerAlex Crichton <alex@alexcrichton.com>2015-01-18 18:25:55 -0800
commit46366faf613685eeeacf896ee9d284b28d4a3046 (patch)
tree12f1d95596a0eb6fbe15e659071777bdd0413ec5 /src
parentdcaeb6aa23ecba2dc2af870668a9239136d20fa3 (diff)
downloadrust-46366faf613685eeeacf896ee9d284b28d4a3046.tar.gz
rust-46366faf613685eeeacf896ee9d284b28d4a3046.zip
rustc_resolve: De-indent by breaking out of match
Helps reduce some rightward drift
Diffstat (limited to 'src')
-rw-r--r--src/librustc_resolve/build_reduced_graph.rs202
1 files changed, 101 insertions, 101 deletions
diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs
index 8d62c5e1ca0..56b05f9e726 100644
--- a/src/librustc_resolve/build_reduced_graph.rs
+++ b/src/librustc_resolve/build_reduced_graph.rs
@@ -412,118 +412,118 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
                     }
                 };
 
-                match mod_name {
+                let mod_name = match mod_name {
+                    Some(mod_name) => mod_name,
                     None => {
                         self.resolve_error(ty.span,
                                            "inherent implementations may \
                                             only be implemented in the same \
                                             module as the type they are \
-                                            implemented for")
+                                            implemented for");
+                        return parent.clone();
                     }
-                    Some(mod_name) => {
-                        // Create the module and add all methods.
-                        let parent_opt = parent.children.borrow().get(&mod_name).cloned();
-                        let new_parent = match parent_opt {
-                            // It already exists
-                            Some(ref child) if child.get_module_if_available()
-                                .is_some() &&
-                                (child.get_module().kind.get() == ImplModuleKind ||
-                                 child.get_module().kind.get() == TraitModuleKind) => {
-                                    child.get_module()
-                                }
-                            Some(ref child) if child.get_module_if_available()
-                                .is_some() &&
-                                child.get_module().kind.get() ==
-                                EnumModuleKind => child.get_module(),
-                            // Create the module
-                            _ => {
-                                let name_bindings =
-                                    self.add_child(mod_name, parent, ForbidDuplicateModules, sp);
-
-                                let parent_link = self.get_parent_link(parent, name);
-                                let def_id = local_def(item.id);
-                                let ns = TypeNS;
-                                let is_public =
-                                    !name_bindings.defined_in_namespace(ns) ||
-                                    name_bindings.defined_in_public_namespace(ns);
-
-                                name_bindings.define_module(parent_link,
-                                                            Some(def_id),
-                                                            ImplModuleKind,
-                                                            false,
-                                                            is_public,
-                                                            sp);
-
-                                name_bindings.get_module()
-                            }
-                        };
+                };
 
-                        // For each implementation item...
-                        for impl_item in impl_items.iter() {
-                            match *impl_item {
-                                MethodImplItem(ref method) => {
-                                    // Add the method to the module.
-                                    let name = method.pe_ident().name;
-                                    let method_name_bindings =
-                                        self.add_child(name,
-                                                       &new_parent,
-                                                       ForbidDuplicateValues,
-                                                       method.span);
-                                    let def = match method.pe_explicit_self()
-                                        .node {
-                                            SelfStatic => {
-                                                // Static methods become
-                                                // `DefStaticMethod`s.
-                                                DefStaticMethod(local_def(method.id),
-                                                                FromImpl(local_def(item.id)))
-                                            }
-                                            _ => {
-                                                // Non-static methods become
-                                                // `DefMethod`s.
-                                                DefMethod(local_def(method.id),
-                                                          None,
-                                                          FromImpl(local_def(item.id)))
-                                            }
-                                        };
+                // Create the module and add all methods.
+                let parent_opt = parent.children.borrow().get(&mod_name).cloned();
+                let new_parent = match parent_opt {
+                    // It already exists
+                    Some(ref child) if child.get_module_if_available()
+                        .is_some() &&
+                        (child.get_module().kind.get() == ImplModuleKind ||
+                         child.get_module().kind.get() == TraitModuleKind) => {
+                            child.get_module()
+                        }
+                    Some(ref child) if child.get_module_if_available()
+                        .is_some() &&
+                        child.get_module().kind.get() ==
+                        EnumModuleKind => child.get_module(),
+                    // Create the module
+                    _ => {
+                        let name_bindings =
+                            self.add_child(mod_name, parent, ForbidDuplicateModules, sp);
+
+                        let parent_link = self.get_parent_link(parent, name);
+                        let def_id = local_def(item.id);
+                        let ns = TypeNS;
+                        let is_public =
+                            !name_bindings.defined_in_namespace(ns) ||
+                            name_bindings.defined_in_public_namespace(ns);
+
+                        name_bindings.define_module(parent_link,
+                                                    Some(def_id),
+                                                    ImplModuleKind,
+                                                    false,
+                                                    is_public,
+                                                    sp);
 
-                                    // NB: not IMPORTABLE
-                                    let modifiers = if method.pe_vis() == ast::Public {
-                                        PUBLIC
-                                    } else {
-                                        DefModifiers::empty()
-                                    };
-                                    method_name_bindings.define_value(
-                                        def,
-                                        method.span,
-                                        modifiers);
-                                }
-                                TypeImplItem(ref typedef) => {
-                                    // Add the typedef to the module.
-                                    let name = typedef.ident.name;
-                                    let typedef_name_bindings =
-                                        self.add_child(
-                                            name,
-                                            &new_parent,
-                                            ForbidDuplicateTypesAndModules,
-                                            typedef.span);
-                                    let def = DefAssociatedTy(local_def(
-                                        typedef.id));
-                                    // NB: not IMPORTABLE
-                                    let modifiers = if typedef.vis == ast::Public {
-                                        PUBLIC
-                                    } else {
-                                        DefModifiers::empty()
-                                    };
-                                    typedef_name_bindings.define_type(
-                                        def,
-                                        typedef.span,
-                                        modifiers);
-                                }
-                            }
+                        name_bindings.get_module()
+                    }
+                };
+
+                // For each implementation item...
+                for impl_item in impl_items.iter() {
+                    match *impl_item {
+                        MethodImplItem(ref method) => {
+                            // Add the method to the module.
+                            let name = method.pe_ident().name;
+                            let method_name_bindings =
+                                self.add_child(name,
+                                               &new_parent,
+                                               ForbidDuplicateValues,
+                                               method.span);
+                            let def = match method.pe_explicit_self()
+                                .node {
+                                    SelfStatic => {
+                                        // Static methods become
+                                        // `DefStaticMethod`s.
+                                        DefStaticMethod(local_def(method.id),
+                                                        FromImpl(local_def(item.id)))
+                                    }
+                                    _ => {
+                                        // Non-static methods become
+                                        // `DefMethod`s.
+                                        DefMethod(local_def(method.id),
+                                                  None,
+                                                  FromImpl(local_def(item.id)))
+                                    }
+                                };
+
+                            // NB: not IMPORTABLE
+                            let modifiers = if method.pe_vis() == ast::Public {
+                                PUBLIC
+                            } else {
+                                DefModifiers::empty()
+                            };
+                            method_name_bindings.define_value(
+                                def,
+                                method.span,
+                                modifiers);
+                        }
+                        TypeImplItem(ref typedef) => {
+                            // Add the typedef to the module.
+                            let name = typedef.ident.name;
+                            let typedef_name_bindings =
+                                self.add_child(
+                                    name,
+                                    &new_parent,
+                                    ForbidDuplicateTypesAndModules,
+                                    typedef.span);
+                            let def = DefAssociatedTy(local_def(
+                                typedef.id));
+                            // NB: not IMPORTABLE
+                            let modifiers = if typedef.vis == ast::Public {
+                                PUBLIC
+                            } else {
+                                DefModifiers::empty()
+                            };
+                            typedef_name_bindings.define_type(
+                                def,
+                                typedef.span,
+                                modifiers);
                         }
                     }
                 }
-
                 parent.clone()
             }