Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete removal of #[main] attribute from compiler #93753

Merged
merged 1 commit into from
Feb 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
}