Address code review

This commit is contained in:
John Renner
2018-07-31 15:00:45 -07:00
parent 7947c58d2d
commit 549f0fd9f7

View File

@@ -1373,15 +1373,19 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> {
result result
} }
// Ensure that test functions are accessible from the test harness. // Ensure that test functions are accessible from the test harness.
// #[test] fn foo() {}
// becomes:
// #[test] pub fn foo_gensym(){}
// use foo_gensym as foo;
ast::ItemKind::Fn(..) if self.cx.ecfg.should_test => { ast::ItemKind::Fn(..) if self.cx.ecfg.should_test => {
if self.tests_nameable && item.attrs.iter().any(|attr| is_test_or_bench(attr)) { if self.tests_nameable && item.attrs.iter().any(|attr| is_test_or_bench(attr)) {
let orig_vis = item.vis.clone(); let orig_ident = item.ident;
let orig_vis = item.vis.clone();
// Publicize the item under gensymed name to avoid pollution // Publicize the item under gensymed name to avoid pollution
item = item.map(|mut item| { item = item.map(|mut item| {
item.vis = respan(item.vis.span, ast::VisibilityKind::Public); item.vis = respan(item.vis.span, ast::VisibilityKind::Public);
item.ident = Ident::from_interned_str( item.ident = item.ident.gensym();
item.ident.as_interned_str()).gensym();
item item
}); });
@@ -1389,8 +1393,9 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> {
let use_item = self.cx.item_use_simple_( let use_item = self.cx.item_use_simple_(
item.ident.span, item.ident.span,
orig_vis, orig_vis,
Some(Ident::from_interned_str(item.ident.as_interned_str())), Some(orig_ident),
self.cx.path(item.ident.span, vec![Ident::from_str("self"), item.ident])); self.cx.path(item.ident.span,
vec![keywords::SelfValue.ident(), item.ident]));
SmallVector::many( SmallVector::many(
self.fold_unnameable(item).into_iter() self.fold_unnameable(item).into_iter()