]> git.lizzy.rs Git - rust.git/commitdiff
Remove #[start] as well as #[main] in --test
authorWilliam Throwe <wtt6@cornell.edu>
Mon, 24 Aug 2015 18:33:22 +0000 (14:33 -0400)
committerWilliam Throwe <wtt6@cornell.edu>
Tue, 25 Aug 2015 00:28:24 +0000 (20:28 -0400)
Fixes #11766.

src/libsyntax/test.rs
src/test/run-pass/test-runner-hides-start.rs [new file with mode: 0644]

index 9975e25f4930d57b00c1dff165d993e7319639c4..7fb8cdde31170823cf404a5e9aa8c22cee7d0d1a 100644 (file)
@@ -202,8 +202,8 @@ fn fold_item(&mut self, i: P<ast::Item>) -> SmallVector<P<ast::Item>> {
         let folded = fold::noop_fold_item(i, self).expect_one("noop did something");
         self.depth -= 1;
 
-        // Remove any #[main] from the AST so it doesn't clash with
-        // the one we're going to add, but mark it as
+        // Remove any #[main] or #[start] from the AST so it doesn't
+        // clash with the one we're going to add, but mark it as
         // #[allow(dead_code)] to avoid printing warnings.
         let folded = match entry::entry_point_type(&*folded, self.depth) {
             EntryPointType::MainNamed |
@@ -221,13 +221,10 @@ fn fold_item(&mut self, i: P<ast::Item>) -> SmallVector<P<ast::Item>> {
                     ast::Item {
                         id: id,
                         ident: ident,
-                        attrs: attrs.into_iter().filter_map(|attr| {
-                            if !attr.check_name("main") {
-                                Some(attr)
-                            } else {
-                                None
-                            }
-                        })
+                        attrs: attrs.into_iter()
+                            .filter(|attr| {
+                                !attr.check_name("main") && !attr.check_name("start")
+                            })
                             .chain(iter::once(allow_dead_code))
                             .collect(),
                         node: node,
diff --git a/src/test/run-pass/test-runner-hides-start.rs b/src/test/run-pass/test-runner-hides-start.rs
new file mode 100644 (file)
index 0000000..fc94b19
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// compile-flags: --test
+
+#![feature(start)]
+
+#[start]
+fn start(_: isize, _: *const *const u8) -> isize { panic!(); }