diff --git a/src/doc/trpl/unsafe.md b/src/doc/trpl/unsafe.md index de6d311be57..53450aa5a6b 100644 --- a/src/doc/trpl/unsafe.md +++ b/src/doc/trpl/unsafe.md @@ -447,7 +447,7 @@ in the same format as C: ``` #![no_std] -#![feature(lang_items)] +#![feature(lang_items, start)] // Pull in the system libc library for what crt0.o likely requires extern crate libc; @@ -475,7 +475,7 @@ compiler's name mangling too: ```ignore #![no_std] #![no_main] -#![feature(lang_items)] +#![feature(lang_items, start)] extern crate libc; @@ -529,7 +529,7 @@ vectors provided from C, using idiomatic Rust practices. ``` #![no_std] -#![feature(lang_items)] +#![feature(lang_items, start)] # extern crate libc; extern crate core; @@ -653,7 +653,7 @@ sugar for dynamic allocations via `malloc` and `free`: ``` #![no_std] -#![feature(lang_items, box_syntax)] +#![feature(lang_items, box_syntax, start)] extern crate libc; diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 9231d4ad659..13b7944998a 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -78,6 +78,8 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[ ("while_let", Accepted), ("plugin", Active), + ("start", Active), + ("main", Active), // A temporary feature gate used to enable parser extensions needed // to bootstrap fix for #5723. @@ -279,6 +281,18 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> { self.gate_feature("plugin_registrar", i.span, "compiler plugins are experimental and possibly buggy"); } + if attr::contains_name(&i.attrs[], "start") { + self.gate_feature("start", i.span, + "a #[start] function is an experimental \ + feature whose signature may change \ + over time"); + } + if attr::contains_name(&i.attrs[], "main") { + self.gate_feature("main", i.span, + "declaration of a nonstandard #[main] \ + function may change over time, for now \ + a top-level `fn main()` is required"); + } } ast::ItemStruct(..) => { diff --git a/src/test/compile-fail/feature-gate-main.rs b/src/test/compile-fail/feature-gate-main.rs new file mode 100644 index 00000000000..db1c1a94417 --- /dev/null +++ b/src/test/compile-fail/feature-gate-main.rs @@ -0,0 +1,12 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[main] +fn foo() {} //~ ERROR: declaration of a nonstandard #[main] function may change over time diff --git a/src/test/compile-fail/feature-gate-start.rs b/src/test/compile-fail/feature-gate-start.rs new file mode 100644 index 00000000000..6a9acf04290 --- /dev/null +++ b/src/test/compile-fail/feature-gate-start.rs @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[start] +fn foo() {} //~ ERROR: a #[start] function is an experimental feature + diff --git a/src/test/compile-fail/issue-9575.rs b/src/test/compile-fail/issue-9575.rs index b7537f2a932..94dd787f086 100644 --- a/src/test/compile-fail/issue-9575.rs +++ b/src/test/compile-fail/issue-9575.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(start)] + #[start] fn start(argc: isize, argv: *const *const u8, crate_map: *const u8) -> isize { //~^ ERROR incorrect number of function parameters diff --git a/src/test/compile-fail/lang-item-missing.rs b/src/test/compile-fail/lang-item-missing.rs index 793d9c77c3b..61d55fd0964 100644 --- a/src/test/compile-fail/lang-item-missing.rs +++ b/src/test/compile-fail/lang-item-missing.rs @@ -14,6 +14,7 @@ // error-pattern: requires `sized` lang_item #![no_std] +#![feature(start)] #[start] fn start(argc: isize, argv: *const *const u8) -> isize { diff --git a/src/test/compile-fail/lint-dead-code-2.rs b/src/test/compile-fail/lint-dead-code-2.rs index e8b85ffd69a..4a0e4f4319e 100644 --- a/src/test/compile-fail/lint-dead-code-2.rs +++ b/src/test/compile-fail/lint-dead-code-2.rs @@ -10,6 +10,7 @@ #![allow(unused_variables)] #![deny(dead_code)] +#![feature(main, start)] struct Foo; diff --git a/src/test/compile-fail/multiple-main-2.rs b/src/test/compile-fail/multiple-main-2.rs index e3dbc67b7a9..d9c232d7dac 100644 --- a/src/test/compile-fail/multiple-main-2.rs +++ b/src/test/compile-fail/multiple-main-2.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(main)] + #[main] fn bar() { } diff --git a/src/test/compile-fail/multiple-main-3.rs b/src/test/compile-fail/multiple-main-3.rs index 58cc148568e..866a59e7a4f 100644 --- a/src/test/compile-fail/multiple-main-3.rs +++ b/src/test/compile-fail/multiple-main-3.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(main)] + #[main] fn main1() { } diff --git a/src/test/compile-fail/privacy1.rs b/src/test/compile-fail/privacy1.rs index 9dafae3d87d..b2ee62ddabe 100644 --- a/src/test/compile-fail/privacy1.rs +++ b/src/test/compile-fail/privacy1.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(lang_items)] +#![feature(lang_items, start)] #![no_std] // makes debugging this test *a lot* easier (during resolve) #[lang="sized"] diff --git a/src/test/compile-fail/privacy2.rs b/src/test/compile-fail/privacy2.rs index b59905776d3..b3d7321edab 100644 --- a/src/test/compile-fail/privacy2.rs +++ b/src/test/compile-fail/privacy2.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(start)] #![no_std] // makes debugging this test *a lot* easier (during resolve) // Test to make sure that globs don't leak in regular `use` statements. diff --git a/src/test/compile-fail/privacy3.rs b/src/test/compile-fail/privacy3.rs index 80219b70e07..245a9c21a6b 100644 --- a/src/test/compile-fail/privacy3.rs +++ b/src/test/compile-fail/privacy3.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(start)] #![no_std] // makes debugging this test *a lot* easier (during resolve) // Test to make sure that private items imported through globs remain private diff --git a/src/test/compile-fail/privacy4.rs b/src/test/compile-fail/privacy4.rs index 3f17d463890..e35089b8606 100644 --- a/src/test/compile-fail/privacy4.rs +++ b/src/test/compile-fail/privacy4.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(lang_items)] +#![feature(lang_items, start)] #![no_std] // makes debugging this test *a lot* easier (during resolve) #[lang = "sized"] pub trait Sized {} diff --git a/src/test/run-pass/attr-main-2.rs b/src/test/run-pass/attr-main-2.rs index 2f5e72491be..fd0ae0729af 100644 --- a/src/test/run-pass/attr-main-2.rs +++ b/src/test/run-pass/attr-main-2.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(main)] pub fn main() { panic!() diff --git a/src/test/run-pass/attr-main.rs b/src/test/run-pass/attr-main.rs index cf8940b4d5b..29b504bed53 100644 --- a/src/test/run-pass/attr-main.rs +++ b/src/test/run-pass/attr-main.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(main)] #[main] fn foo() { diff --git a/src/test/run-pass/attr-start.rs b/src/test/run-pass/attr-start.rs index 3bea7e84807..2bf09404200 100644 --- a/src/test/run-pass/attr-start.rs +++ b/src/test/run-pass/attr-start.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(start)] #[start] fn start(_argc: int, _argv: *const *const u8) -> int { diff --git a/src/test/run-pass/attr.rs b/src/test/run-pass/attr.rs index 2f30eb8154f..129d69b6e67 100644 --- a/src/test/run-pass/attr.rs +++ b/src/test/run-pass/attr.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(main)] + #[main] fn foo() { } diff --git a/src/test/run-pass/intrinsic-alignment.rs b/src/test/run-pass/intrinsic-alignment.rs index 52fcaf5c3ae..da07e9594c0 100644 --- a/src/test/run-pass/intrinsic-alignment.rs +++ b/src/test/run-pass/intrinsic-alignment.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(intrinsics)] +#![feature(intrinsics, main)] mod rusti { extern "rust-intrinsic" { diff --git a/src/test/run-pass/issue-16597-empty.rs b/src/test/run-pass/issue-16597-empty.rs index c51e33c0104..a6a1c5f16b3 100644 --- a/src/test/run-pass/issue-16597-empty.rs +++ b/src/test/run-pass/issue-16597-empty.rs @@ -9,6 +9,7 @@ // except according to those terms. // compile-flags:--test +// no-pretty-expanded // This verifies that the test generation doesn't crash when we have // no tests - for more information, see PR #16892. diff --git a/src/test/run-pass/issue-20823.rs b/src/test/run-pass/issue-20823.rs index 73b7fc264a5..561b6195476 100644 --- a/src/test/run-pass/issue-20823.rs +++ b/src/test/run-pass/issue-20823.rs @@ -9,6 +9,7 @@ // except according to those terms. // compile-flags: --test +// no-pretty-expanded #![deny(unstable)] diff --git a/src/test/run-pass/lang-item-public.rs b/src/test/run-pass/lang-item-public.rs index 81774c73c39..f94f6482759 100644 --- a/src/test/run-pass/lang-item-public.rs +++ b/src/test/run-pass/lang-item-public.rs @@ -13,7 +13,7 @@ // ignore-windows #13361 #![no_std] -#![feature(lang_items)] +#![feature(lang_items, start)] extern crate "lang-item-public" as lang_lib; diff --git a/src/test/run-pass/native-print-no-runtime.rs b/src/test/run-pass/native-print-no-runtime.rs index a7937efd66f..b151eddb94e 100644 --- a/src/test/run-pass/native-print-no-runtime.rs +++ b/src/test/run-pass/native-print-no-runtime.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(start)] #[start] pub fn main(_: int, _: *const *const u8) -> int { diff --git a/src/test/run-pass/running-with-no-runtime.rs b/src/test/run-pass/running-with-no-runtime.rs index d6c25672cdb..7b809235e8d 100644 --- a/src/test/run-pass/running-with-no-runtime.rs +++ b/src/test/run-pass/running-with-no-runtime.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(start)] + use std::ffi; use std::io::process::{Command, ProcessOutput}; use std::os; diff --git a/src/test/run-pass/smallest-hello-world.rs b/src/test/run-pass/smallest-hello-world.rs index 2877aa6bd3b..4913b34c4b3 100644 --- a/src/test/run-pass/smallest-hello-world.rs +++ b/src/test/run-pass/smallest-hello-world.rs @@ -13,7 +13,7 @@ // Smallest "hello world" with a libc runtime #![no_std] -#![feature(intrinsics, lang_items)] +#![feature(intrinsics, lang_items, start)] extern crate libc; diff --git a/src/test/run-pass/use.rs b/src/test/run-pass/use.rs index 67083f53623..a2e1d8a5671 100644 --- a/src/test/run-pass/use.rs +++ b/src/test/run-pass/use.rs @@ -9,14 +9,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - #![allow(unused_imports)] - +#![feature(start)] #![no_std] + extern crate std; extern crate "std" as zed; - use std::str; use zed::str as x; mod baz { diff --git a/src/test/run-pass/vec-macro-no-std.rs b/src/test/run-pass/vec-macro-no-std.rs index 7b2c35aa08d..c6c37017349 100644 --- a/src/test/run-pass/vec-macro-no-std.rs +++ b/src/test/run-pass/vec-macro-no-std.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(lang_items)] +#![feature(lang_items, start)] #![no_std] extern crate "std" as other;