Skip to content

Commit

Permalink
Gen right parameter envirnoment for assoc consts
Browse files Browse the repository at this point in the history
  • Loading branch information
nagisa committed May 11, 2016
1 parent fd70788 commit 5af829b
Showing 1 changed file with 2 additions and 20 deletions.
22 changes: 2 additions & 20 deletions src/librustc/ty/mod.rs
Expand Up @@ -1260,7 +1260,7 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> {
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);
Expand All @@ -1272,15 +1272,6 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> {
&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) {
Expand All @@ -1303,7 +1294,7 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> {
}
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);
Expand All @@ -1315,15 +1306,6 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> {
&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
Expand Down

0 comments on commit 5af829b

Please sign in to comment.