]> git.lizzy.rs Git - rust.git/commitdiff
Gen right parameter envirnoment for assoc consts
authorSimonas Kazlauskas <git@kazlauskas.me>
Wed, 11 May 2016 21:30:08 +0000 (00:30 +0300)
committerSimonas Kazlauskas <git@kazlauskas.me>
Wed, 11 May 2016 21:33:01 +0000 (00:33 +0300)
src/librustc/ty/mod.rs

index 005d83da38dbf87dd13f2a443742733bc0a8dd3a..114e81721ab28df812b170c3ddd1f3b348867252 100644 (file)
@@ -1260,7 +1260,7 @@ pub fn for_item(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: NodeId)
         match tcx.map.find(id) {
             Some(ast_map::NodeImplItem(ref impl_item)) => {
                 match impl_item.node {
-                    hir::ImplItemKind::Type(_) => {
+                    hir::ImplItemKind::Type(_) | hir::ImplItemKind::Const(_, _) => {
                         // associated types don't have their own entry (for some reason),
                         // so for now just grab environment for the impl
                         let impl_id = tcx.map.get_parent(id);
@@ -1272,15 +1272,6 @@ pub fn for_item(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: NodeId)
                                                             &predicates,
                                                             tcx.region_maps.item_extent(id))
                     }
-                    hir::ImplItemKind::Const(_, _) => {
-                        let def_id = tcx.map.local_def_id(id);
-                        let scheme = tcx.lookup_item_type(def_id);
-                        let predicates = tcx.lookup_predicates(def_id);
-                        tcx.construct_parameter_environment(impl_item.span,
-                                                            &scheme.generics,
-                                                            &predicates,
-                                                            tcx.region_maps.item_extent(id))
-                    }
                     hir::ImplItemKind::Method(_, ref body) => {
                         let method_def_id = tcx.map.local_def_id(id);
                         match tcx.impl_or_trait_item(method_def_id) {
@@ -1303,7 +1294,7 @@ pub fn for_item(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: NodeId)
             }
             Some(ast_map::NodeTraitItem(trait_item)) => {
                 match trait_item.node {
-                    hir::TypeTraitItem(..) => {
+                    hir::TypeTraitItem(..) | hir::ConstTraitItem(..) => {
                         // associated types don't have their own entry (for some reason),
                         // so for now just grab environment for the trait
                         let trait_id = tcx.map.get_parent(id);
@@ -1315,15 +1306,6 @@ pub fn for_item(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: NodeId)
                                                             &predicates,
                                                             tcx.region_maps.item_extent(id))
                     }
-                    hir::ConstTraitItem(..) => {
-                        let def_id = tcx.map.local_def_id(id);
-                        let scheme = tcx.lookup_item_type(def_id);
-                        let predicates = tcx.lookup_predicates(def_id);
-                        tcx.construct_parameter_environment(trait_item.span,
-                                                            &scheme.generics,
-                                                            &predicates,
-                                                            tcx.region_maps.item_extent(id))
-                    }
                     hir::MethodTraitItem(_, ref body) => {
                         // Use call-site for extent (unless this is a
                         // trait method with no default; then fallback