Skip to content

Commit

Permalink
Remove obsolete no-op #[main] attribute from compiler.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyBanks authored Feb 8, 2022
1 parent f52c318 commit 475e4ee
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 1 deletion.
1 change: 0 additions & 1 deletion compiler/rustc_feature/src/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
),

// Entry point:
ungated!(main, Normal, template!(Word), WarnFollowing),
ungated!(start, Normal, template!(Word), WarnFollowing),
ungated!(no_start, CrateLevel, template!(Word), WarnFollowing),
ungated!(no_main, CrateLevel, template!(Word), WarnFollowing),
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/attributes/main-removed-1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#[main] //~ ERROR cannot find attribute `main` in this scope
fn main() {}
10 changes: 10 additions & 0 deletions src/test/ui/attributes/main-removed-1.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: cannot find attribute `main` in this scope
--> $DIR/main-removed-1.rs:1:3
|
LL | #[main]
| ^^^^
|
= note: `main` is in scope, but it is a function, not an attribute

error: aborting due to previous error

12 changes: 12 additions & 0 deletions src/test/ui/attributes/main-removed-2/auxiliary/tokyo.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// force-host
// no-prefer-dynamic

#![crate_type = "proc-macro"]

extern crate proc_macro;
use proc_macro::TokenStream;

#[proc_macro_attribute]
pub fn main(_: TokenStream, input: TokenStream) -> TokenStream {
"fn main() { println!(\"Hello Tokyo!\"); }".parse().unwrap()
}
11 changes: 11 additions & 0 deletions src/test/ui/attributes/main-removed-2/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// run-pass
// aux-build:tokyo.rs
// compile-flags:--extern tokyo
// edition:2021

use tokyo::main;

#[main]
fn main() {
panic!("the #[main] macro should replace this with non-panicking code")
}

0 comments on commit 475e4ee

Please sign in to comment.