about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2015-03-17 15:19:45 +0530
committerManish Goregaokar <manishsmail@gmail.com>2015-03-17 15:19:45 +0530
commit74adeda78a807d4e7e3598fa0b3dd5470bb89fc2 (patch)
tree2c6d0a4848fb5a1d573fbf65f5e2d6640f1b1552 /src/libsyntax
parent285cb8e6d8e4802c3c36d6c00d9c3752c2cc13bd (diff)
parent1fd38c181a5cadb854dd8eb22d1ba1b7f009a12f (diff)
downloadrust-74adeda78a807d4e7e3598fa0b3dd5470bb89fc2.tar.gz
rust-74adeda78a807d4e7e3598fa0b3dd5470bb89fc2.zip
Rollup merge of #23400 - nrc:pub_use, r=eddyb
 r? @eddyb
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/test.rs18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs
index 5e858d8a79f..2a47a696b1c 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,19 @@ 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).
+                    i.map(|mut i| {
+                        i.vis = ast::Public;
+                        i
+                    })
                 }
             }
-        }
+        } else {
+            i
+        };
 
         // We don't want to recurse into anything other than mods, since
         // mods or tests inside of functions will break things