From 432011d1437ce046c25dde8a4db67dac63c19ed0 Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Mon, 16 Mar 2015 09:00:41 +1300 Subject: Fallout in testing. --- src/libsyntax/test.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 5e858d8a79f..991ab77419f 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -121,13 +121,11 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> { debug!("current path: {}", ast_util::path_name_i(&self.cx.path)); - if is_test_fn(&self.cx, &*i) || is_bench_fn(&self.cx, &*i) { + let i = if is_test_fn(&self.cx, &*i) || is_bench_fn(&self.cx, &*i) { match i.node { ast::ItemFn(_, ast::Unsafety::Unsafe, _, _, _) => { let diag = self.cx.span_diagnostic; - diag.span_fatal(i.span, - "unsafe functions cannot be used for \ - tests"); + diag.span_fatal(i.span, "unsafe functions cannot be used for tests"); } _ => { debug!("this is a test function"); @@ -142,9 +140,18 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> { self.tests.push(i.ident); // debug!("have {} test/bench functions", // cx.testfns.len()); + + // Make all tests public so we can call them from outside + // the module (note that the tests are re-exported and must + // be made public themselves to avoid privacy errors). + let mut result = (*i).clone(); + result.vis = ast::Public; + P(result) } } - } + } else { + i + }; // We don't want to recurse into anything other than mods, since // mods or tests inside of functions will break things -- cgit 1.4.1-3-g733a5 From 1fd38c181a5cadb854dd8eb22d1ba1b7f009a12f Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Mon, 16 Mar 2015 17:01:12 +1300 Subject: Reviewer changes --- src/librustc_resolve/build_reduced_graph.rs | 2 +- src/libsyntax/test.rs | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src/libsyntax') diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 0282484ba28..e62300098f6 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -372,7 +372,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> { ItemExternCrate(_) => { // n.b. we don't need to look at the path option here, because cstore already did - for &crate_id in self.session.cstore.find_extern_mod_stmt_cnum(item.id).iter() { + if let Some(crate_id) = self.session.cstore.find_extern_mod_stmt_cnum(item.id) { let def_id = DefId { krate: crate_id, node: 0 }; self.external_exports.insert(def_id); let parent_link = ModuleParentLink(parent.downgrade(), name); diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 991ab77419f..2a47a696b1c 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -144,9 +144,10 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> { // Make all tests public so we can call them from outside // the module (note that the tests are re-exported and must // be made public themselves to avoid privacy errors). - let mut result = (*i).clone(); - result.vis = ast::Public; - P(result) + i.map(|mut i| { + i.vis = ast::Public; + i + }) } } } else { -- cgit 1.4.1-3-g733a5