Skip to content

Commit e375a89

Browse files
committedJan 20, 2015
Auto merge of #21257 - alexcrichton:issue-20064, r=pnkfelix
These two attributes are used to change the entry point into a Rust program, but for now they're being put behind feature gates until we have a chance to think about them a little more. The #[start] attribute specifically may have its signature changed. This is a breaking change to due the usage of these attributes generating errors by default now. If your crate is using these attributes, add this to your crate root: #![feature(start)] // if you're using the #[start] attribute #![feature(main)] // if you're using the #[main] attribute cc #20064
2 parents 65b61ff + 38cb91e commit e375a89

26 files changed

+71
-13
lines changed
 

‎src/doc/trpl/unsafe.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ in the same format as C:
447447

448448
```
449449
#![no_std]
450-
#![feature(lang_items)]
450+
#![feature(lang_items, start)]
451451
452452
// Pull in the system libc library for what crt0.o likely requires
453453
extern crate libc;
@@ -475,7 +475,7 @@ compiler's name mangling too:
475475
```ignore
476476
#![no_std]
477477
#![no_main]
478-
#![feature(lang_items)]
478+
#![feature(lang_items, start)]
479479
480480
extern crate libc;
481481
@@ -529,7 +529,7 @@ vectors provided from C, using idiomatic Rust practices.
529529

530530
```
531531
#![no_std]
532-
#![feature(lang_items)]
532+
#![feature(lang_items, start)]
533533
534534
# extern crate libc;
535535
extern crate core;
@@ -653,7 +653,7 @@ sugar for dynamic allocations via `malloc` and `free`:
653653

654654
```
655655
#![no_std]
656-
#![feature(lang_items, box_syntax)]
656+
#![feature(lang_items, box_syntax, start)]
657657
658658
extern crate libc;
659659

‎src/libsyntax/feature_gate.rs

+14
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
7878
("while_let", Accepted),
7979

8080
("plugin", Active),
81+
("start", Active),
82+
("main", Active),
8183

8284
// A temporary feature gate used to enable parser extensions needed
8385
// to bootstrap fix for #5723.
@@ -279,6 +281,18 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
279281
self.gate_feature("plugin_registrar", i.span,
280282
"compiler plugins are experimental and possibly buggy");
281283
}
284+
if attr::contains_name(&i.attrs[], "start") {
285+
self.gate_feature("start", i.span,
286+
"a #[start] function is an experimental \
287+
feature whose signature may change \
288+
over time");
289+
}
290+
if attr::contains_name(&i.attrs[], "main") {
291+
self.gate_feature("main", i.span,
292+
"declaration of a nonstandard #[main] \
293+
function may change over time, for now \
294+
a top-level `fn main()` is required");
295+
}
282296
}
283297

284298
ast::ItemStruct(..) => {
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
#[main]
12+
fn foo() {} //~ ERROR: declaration of a nonstandard #[main] function may change over time
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
#[start]
12+
fn foo() {} //~ ERROR: a #[start] function is an experimental feature
13+

‎src/test/compile-fail/issue-9575.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(start)]
12+
1113
#[start]
1214
fn start(argc: isize, argv: *const *const u8, crate_map: *const u8) -> isize {
1315
//~^ ERROR incorrect number of function parameters

‎src/test/compile-fail/lang-item-missing.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// error-pattern: requires `sized` lang_item
1515

1616
#![no_std]
17+
#![feature(start)]
1718

1819
#[start]
1920
fn start(argc: isize, argv: *const *const u8) -> isize {

‎src/test/compile-fail/lint-dead-code-2.rs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#![allow(unused_variables)]
1212
#![deny(dead_code)]
13+
#![feature(main, start)]
1314

1415
struct Foo;
1516

‎src/test/compile-fail/multiple-main-2.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(main)]
12+
1113
#[main]
1214
fn bar() {
1315
}

‎src/test/compile-fail/multiple-main-3.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(main)]
12+
1113
#[main]
1214
fn main1() {
1315
}

‎src/test/compile-fail/privacy1.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(lang_items)]
11+
#![feature(lang_items, start)]
1212
#![no_std] // makes debugging this test *a lot* easier (during resolve)
1313

1414
#[lang="sized"]

‎src/test/compile-fail/privacy2.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(start)]
1112
#![no_std] // makes debugging this test *a lot* easier (during resolve)
1213

1314
// Test to make sure that globs don't leak in regular `use` statements.

‎src/test/compile-fail/privacy3.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(start)]
1112
#![no_std] // makes debugging this test *a lot* easier (during resolve)
1213

1314
// Test to make sure that private items imported through globs remain private

‎src/test/compile-fail/privacy4.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(lang_items)]
11+
#![feature(lang_items, start)]
1212
#![no_std] // makes debugging this test *a lot* easier (during resolve)
1313

1414
#[lang = "sized"] pub trait Sized {}

‎src/test/run-pass/attr-main-2.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(main)]
1112

1213
pub fn main() {
1314
panic!()

‎src/test/run-pass/attr-main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(main)]
1112

1213
#[main]
1314
fn foo() {

‎src/test/run-pass/attr-start.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(start)]
1112

1213
#[start]
1314
fn start(_argc: int, _argv: *const *const u8) -> int {

‎src/test/run-pass/attr.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(main)]
12+
1113
#[main]
1214
fn foo() {
1315
}

‎src/test/run-pass/intrinsic-alignment.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(intrinsics)]
11+
#![feature(intrinsics, main)]
1212

1313
mod rusti {
1414
extern "rust-intrinsic" {

‎src/test/run-pass/issue-16597-empty.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
// compile-flags:--test
12+
// no-pretty-expanded
1213

1314
// This verifies that the test generation doesn't crash when we have
1415
// no tests - for more information, see PR #16892.

‎src/test/run-pass/issue-20823.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
// compile-flags: --test
12+
// no-pretty-expanded
1213

1314
#![deny(unstable)]
1415

‎src/test/run-pass/lang-item-public.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// ignore-windows #13361
1414

1515
#![no_std]
16-
#![feature(lang_items)]
16+
#![feature(lang_items, start)]
1717

1818
extern crate "lang-item-public" as lang_lib;
1919

‎src/test/run-pass/native-print-no-runtime.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(start)]
1112

1213
#[start]
1314
pub fn main(_: int, _: *const *const u8) -> int {

‎src/test/run-pass/running-with-no-runtime.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(start)]
12+
1113
use std::ffi;
1214
use std::io::process::{Command, ProcessOutput};
1315
use std::os;

‎src/test/run-pass/smallest-hello-world.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// Smallest "hello world" with a libc runtime
1414

1515
#![no_std]
16-
#![feature(intrinsics, lang_items)]
16+
#![feature(intrinsics, lang_items, start)]
1717

1818
extern crate libc;
1919

‎src/test/run-pass/use.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@
99
// option. This file may not be copied, modified, or distributed
1010
// except according to those terms.
1111

12-
1312
#![allow(unused_imports)]
14-
13+
#![feature(start)]
1514
#![no_std]
15+
1616
extern crate std;
1717
extern crate "std" as zed;
1818

19-
2019
use std::str;
2120
use zed::str as x;
2221
mod baz {

‎src/test/run-pass/vec-macro-no-std.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(lang_items)]
11+
#![feature(lang_items, start)]
1212
#![no_std]
1313

1414
extern crate "std" as other;

0 commit comments

Comments
 (0)
Please sign in to comment.