Skip to content

Commit 475e4ee

Browse files
authored
Remove obsolete no-op #[main] attribute from compiler.
1 parent f52c318 commit 475e4ee

File tree

5 files changed

+35
-1
lines changed

5 files changed

+35
-1
lines changed

compiler/rustc_feature/src/builtin_attrs.rs

-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
339339
),
340340

341341
// Entry point:
342-
ungated!(main, Normal, template!(Word), WarnFollowing),
343342
ungated!(start, Normal, template!(Word), WarnFollowing),
344343
ungated!(no_start, CrateLevel, template!(Word), WarnFollowing),
345344
ungated!(no_main, CrateLevel, template!(Word), WarnFollowing),
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#[main] //~ ERROR cannot find attribute `main` in this scope
2+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: cannot find attribute `main` in this scope
2+
--> $DIR/main-removed-1.rs:1:3
3+
|
4+
LL | #[main]
5+
| ^^^^
6+
|
7+
= note: `main` is in scope, but it is a function, not an attribute
8+
9+
error: aborting due to previous error
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// force-host
2+
// no-prefer-dynamic
3+
4+
#![crate_type = "proc-macro"]
5+
6+
extern crate proc_macro;
7+
use proc_macro::TokenStream;
8+
9+
#[proc_macro_attribute]
10+
pub fn main(_: TokenStream, input: TokenStream) -> TokenStream {
11+
"fn main() { println!(\"Hello Tokyo!\"); }".parse().unwrap()
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// run-pass
2+
// aux-build:tokyo.rs
3+
// compile-flags:--extern tokyo
4+
// edition:2021
5+
6+
use tokyo::main;
7+
8+
#[main]
9+
fn main() {
10+
panic!("the #[main] macro should replace this with non-panicking code")
11+
}

0 commit comments

Comments
 (0)