From 157ba0038dea24f06d594b6e1190fcd0eb431018 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Sun, 27 Mar 2016 06:04:50 +0530 Subject: [PATCH 1/2] Clarify that ParameterEnvironment::for_item can take impl/trait items too --- src/librustc/ty/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 96a0627c6a4..97c5e4c76da 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -1202,6 +1202,7 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> { } } + /// Construct a parameter environment given an item, impl item, or trait item pub fn for_item(cx: &'a TyCtxt<'tcx>, id: NodeId) -> ParameterEnvironment<'a, 'tcx> { match cx.map.find(id) { Some(ast_map::NodeImplItem(ref impl_item)) => { From a3fdf327e8bda2aaafd597f09c25b2192bb4a287 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Sun, 27 Mar 2016 06:05:00 +0530 Subject: [PATCH 2/2] from_item is the old name --- src/librustc/ty/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 97c5e4c76da..d080724fac9 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -1342,7 +1342,7 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> { } _ => { cx.sess.span_bug(item.span, - "ParameterEnvironment::from_item(): + "ParameterEnvironment::for_item(): can't create a parameter \ environment for this kind of item") } @@ -1353,7 +1353,7 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> { ParameterEnvironment::for_item(cx, cx.map.get_parent(id)) } _ => { - cx.sess.bug(&format!("ParameterEnvironment::from_item(): \ + cx.sess.bug(&format!("ParameterEnvironment::for_item(): \ `{}` is not an item", cx.map.node_to_string(id))) }