Remove obsolete no-op #[main] attribute from compiler.

This commit is contained in:
Jeremy Banks 2022-02-07 23:40:17 +00:00 committed by GitHub
parent f52c31840d
commit 475e4eeb65
5 changed files with 35 additions and 1 deletions

View file

@ -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),

View file

@ -0,0 +1,2 @@
#[main] //~ ERROR cannot find attribute `main` in this scope
fn main() {}

View file

@ -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

View file

@ -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()
}

View file

@ -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")
}