Skip to content

Commit d5da4a5

Browse files
committed
Remove alternative main feature
1 parent 1283c02 commit d5da4a5

File tree

10 files changed

+7
-84
lines changed

10 files changed

+7
-84
lines changed

src/doc/reference.md

-2
Original file line numberDiff line numberDiff line change
@@ -1982,8 +1982,6 @@ type int8_t = i8;
19821982

19831983
### Function-only attributes
19841984

1985-
- `main` - indicates that this function should be passed to the entry point,
1986-
rather than the function in the crate root named `main`.
19871985
- `plugin_registrar` - mark this function as the registration point for
19881986
[compiler plugins][plugin], such as loadable syntax extensions.
19891987
- `start` - indicates that this function should be used as the entry point,

src/librustc/middle/entry.rs

-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ fn entry_point_type(item: &Item, at_root: bool) -> EntryPointType {
9494
ItemFn(..) => {
9595
if attr::contains_name(&item.attrs, "start") {
9696
EntryPointType::Start
97-
} else if attr::contains_name(&item.attrs, "main") {
98-
EntryPointType::MainAttr
9997
} else if item.name == "main" {
10098
if at_root {
10199
// This is a top-level function so can be 'main'

src/libsyntax/entry.rs

-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ pub fn entry_point_type(item: &Item, depth: usize) -> EntryPointType {
2626
ItemKind::Fn(..) => {
2727
if attr::contains_name(&item.attrs, "start") {
2828
EntryPointType::Start
29-
} else if attr::contains_name(&item.attrs, "main") {
30-
EntryPointType::MainAttr
3129
} else if item.ident.name == "main" {
3230
if depth == 1 {
3331
// This is a top-level function so can be 'main'

src/libsyntax/feature_gate.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ declare_features! (
129129

130130
(active, allocator, "1.0.0", Some(27389)),
131131
(active, fundamental, "1.0.0", Some(29635)),
132-
(active, main, "1.0.0", Some(29634)),
133132
(active, needs_allocator, "1.4.0", Some(27389)),
134133
(active, on_unimplemented, "1.0.0", Some(29628)),
135134
(active, plugin, "1.0.0", Some(29597)),
@@ -334,6 +333,7 @@ declare_features! (
334333

335334
declare_features! (
336335
(removed, import_shadowing, "1.0.0", None),
336+
(removed, main, "1.0.0", Some(29634)),
337337
(removed, managed_boxes, "1.0.0", None),
338338
// Allows use of unary negate on unsigned integers, e.g. -e for e: u8
339339
(removed, negate_unsigned, "1.0.0", Some(29645)),
@@ -468,7 +468,6 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG
468468

469469
("cfg", Normal, Ungated),
470470
("cfg_attr", Normal, Ungated),
471-
("main", Normal, Ungated),
472471
("start", Normal, Ungated),
473472
("test", Normal, Ungated),
474473
("bench", Normal, Ungated),
@@ -1106,12 +1105,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
11061105
feature whose signature may change \
11071106
over time");
11081107
}
1109-
if attr::contains_name(&i.attrs[..], "main") {
1110-
gate_feature_post!(&self, main, i.span,
1111-
"declaration of a nonstandard #[main] \
1112-
function may change over time, for now \
1113-
a top-level `fn main()` is required");
1114-
}
11151108
}
11161109

11171110
ast::ItemKind::Struct(..) => {

src/libsyntax/test.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,7 @@ impl fold::Folder for EntryPointCleaner {
202202
id: id,
203203
ident: ident,
204204
attrs: attrs.into_iter()
205-
.filter(|attr| {
206-
!attr.check_name("main") && !attr.check_name("start")
207-
})
205+
.filter(|attr| !attr.check_name("start"))
208206
.chain(iter::once(allow_dead_code))
209207
.collect(),
210208
node: node,

src/test/compile-fail/feature-gate-main.rs

-12
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -7,13 +7,7 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10+
#![feature(main)] //~ ERROR feature has been removed [E0557]
1011

11-
#![feature(main)]
12-
13-
#[main]
14-
fn foo() {} //~ NOTE first #[main] function
15-
16-
#[main]
17-
fn f() {}
18-
//~^ ERROR E0137
19-
//~| NOTE additional #[main] function
12+
#[main] //~ ERROR The attribute `main` is currently unknown to the compiler
13+
pub fn non_main() {}

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

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

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

1515
struct Foo;
1616

@@ -31,9 +31,6 @@ fn live_fn() {}
3131

3232
fn dead_fn() {} //~ ERROR: function is never used
3333

34-
#[main]
35-
fn dead_fn2() {} //~ ERROR: function is never used
36-
3734
fn used_fn() {}
3835

3936
#[start]
@@ -47,5 +44,4 @@ fn start(_: isize, _: *const *const u8) -> isize {
4744
// this is not main
4845
fn main() { //~ ERROR: function is never used
4946
dead_fn();
50-
dead_fn2();
5147
}

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

-19
This file was deleted.

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

-21
This file was deleted.

0 commit comments

Comments
 (0)