Skip to content

Commit 8320a3a

Browse files
committed
Remove #[start] as well as #[main] in --test
Fixes #11766.
1 parent 0112e7b commit 8320a3a

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

src/libsyntax/test.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ impl fold::Folder for EntryPointCleaner {
202202
let folded = fold::noop_fold_item(i, self).expect_one("noop did something");
203203
self.depth -= 1;
204204

205-
// Remove any #[main] from the AST so it doesn't clash with
206-
// the one we're going to add, but mark it as
205+
// Remove any #[main] or #[start] from the AST so it doesn't
206+
// clash with the one we're going to add, but mark it as
207207
// #[allow(dead_code)] to avoid printing warnings.
208208
let folded = match entry::entry_point_type(&*folded, self.depth) {
209209
EntryPointType::MainNamed |
@@ -221,13 +221,10 @@ impl fold::Folder for EntryPointCleaner {
221221
ast::Item {
222222
id: id,
223223
ident: ident,
224-
attrs: attrs.into_iter().filter_map(|attr| {
225-
if !attr.check_name("main") {
226-
Some(attr)
227-
} else {
228-
None
229-
}
230-
})
224+
attrs: attrs.into_iter()
225+
.filter(|attr| {
226+
!attr.check_name("main") && !attr.check_name("start")
227+
})
231228
.chain(iter::once(allow_dead_code))
232229
.collect(),
233230
node: node,
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// compile-flags: --test
12+
13+
#![feature(start)]
14+
15+
#[start]
16+
fn start(_: isize, _: *const *const u8) -> isize { panic!(); }

0 commit comments

Comments
 (0)