Auto merge of #84217 - crlf0710:remove_main_attr_pure, r=petrochenkov
Remove #[main] attribute. This removes the #[main] attribute support from the compiler according to the decisions within #29634. For existing use cases within test harness generation, replaced it with a newly-introduced internal attribute `#[rustc_main]`. This is first part extracted from #84062 . Closes #29634. r? `@petrochenkov`
This commit is contained in:
commit
d4bc912c48
29 changed files with 59 additions and 214 deletions
|
|
@ -1,11 +0,0 @@
|
|||
// run-pass
|
||||
|
||||
#![feature(main)]
|
||||
|
||||
pub fn main() {
|
||||
panic!()
|
||||
}
|
||||
|
||||
#[main]
|
||||
fn foo() {
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
// run-pass
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
#![feature(main)]
|
||||
|
||||
#[main]
|
||||
fn foo() {
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
// run-pass
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
#![feature(main)]
|
||||
|
||||
#[main]
|
||||
fn foo() {
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#![feature(main)]
|
||||
|
||||
#[main]
|
||||
fn foo() {}
|
||||
|
||||
#[main]
|
||||
fn f() {}
|
||||
//~^ ERROR E0137
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
error[E0137]: multiple functions with a `#[main]` attribute
|
||||
--> $DIR/E0137.rs:7:1
|
||||
|
|
||||
LL | fn foo() {}
|
||||
| ----------- first `#[main]` function
|
||||
...
|
||||
LL | fn f() {}
|
||||
| ^^^^^^^^^ additional `#[main]` function
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0137`.
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
#[main]
|
||||
fn foo() {} //~ ERROR: declaration of a non-standard `#[main]` function may change over time
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
error[E0658]: declaration of a non-standard `#[main]` function may change over time, for now a top-level `fn main()` is required
|
||||
--> $DIR/feature-gate-main.rs:2:1
|
||||
|
|
||||
LL | fn foo() {}
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #29634 <https://github.com/rust-lang/rust/issues/29634> for more information
|
||||
= help: add `#![feature(main)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
#![macro_export]
|
||||
//~^ ERROR: `macro_export` attribute cannot be used at crate level
|
||||
#![main]
|
||||
//~^ ERROR: `main` attribute cannot be used at crate level
|
||||
#![rustc_main] //~ ERROR: the `#[rustc_main]` attribute is used internally to specify
|
||||
//~^ ERROR: `rustc_main` attribute cannot be used at crate level
|
||||
#![start]
|
||||
//~^ ERROR: `start` attribute cannot be used at crate level
|
||||
#![repr()]
|
||||
|
|
@ -106,24 +106,6 @@ mod export_name {
|
|||
//~| NOTE not a function or static
|
||||
}
|
||||
|
||||
#[main]
|
||||
//~^ ERROR: `main` attribute can only be used on functions
|
||||
mod main {
|
||||
mod inner { #![main] }
|
||||
//~^ ERROR: `main` attribute can only be used on functions
|
||||
|
||||
// for `fn f()` case, see feature-gate-main.rs
|
||||
|
||||
#[main] struct S;
|
||||
//~^ ERROR: `main` attribute can only be used on functions
|
||||
|
||||
#[main] type T = S;
|
||||
//~^ ERROR: `main` attribute can only be used on functions
|
||||
|
||||
#[main] impl S { }
|
||||
//~^ ERROR: `main` attribute can only be used on functions
|
||||
}
|
||||
|
||||
#[start]
|
||||
//~^ ERROR: `start` attribute can only be used on functions
|
||||
mod start {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,11 @@
|
|||
error[E0658]: the `#[rustc_main]` attribute is used internally to specify test entry point function
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:14:1
|
||||
|
|
||||
LL | #![rustc_main]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
|
||||
|
||||
error: attribute must be of the form `#[inline]` or `#[inline(always|never)]`
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:40:5
|
||||
|
|
||||
|
|
@ -8,62 +16,32 @@ LL | #[inline = "2100"] fn f() { }
|
|||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
|
||||
|
||||
error: `main` attribute can only be used on functions
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:109:1
|
||||
|
|
||||
LL | #[main]
|
||||
| ^^^^^^^
|
||||
|
||||
error: `main` attribute can only be used on functions
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:112:17
|
||||
|
|
||||
LL | mod inner { #![main] }
|
||||
| ^^^^^^^^
|
||||
|
||||
error: `main` attribute can only be used on functions
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:117:5
|
||||
|
|
||||
LL | #[main] struct S;
|
||||
| ^^^^^^^
|
||||
|
||||
error: `main` attribute can only be used on functions
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:120:5
|
||||
|
|
||||
LL | #[main] type T = S;
|
||||
| ^^^^^^^
|
||||
|
||||
error: `main` attribute can only be used on functions
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:123:5
|
||||
|
|
||||
LL | #[main] impl S { }
|
||||
| ^^^^^^^
|
||||
|
||||
error: `start` attribute can only be used on functions
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:127:1
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:109:1
|
||||
|
|
||||
LL | #[start]
|
||||
| ^^^^^^^^
|
||||
|
||||
error: `start` attribute can only be used on functions
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:130:17
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:112:17
|
||||
|
|
||||
LL | mod inner { #![start] }
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: `start` attribute can only be used on functions
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:135:5
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:117:5
|
||||
|
|
||||
LL | #[start] struct S;
|
||||
| ^^^^^^^^
|
||||
|
||||
error: `start` attribute can only be used on functions
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:138:5
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:120:5
|
||||
|
|
||||
LL | #[start] type T = S;
|
||||
| ^^^^^^^^
|
||||
|
||||
error: `start` attribute can only be used on functions
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:141:5
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:123:5
|
||||
|
|
||||
LL | #[start] impl S { }
|
||||
| ^^^^^^^^
|
||||
|
|
@ -137,11 +115,11 @@ error: `macro_export` attribute cannot be used at crate level
|
|||
LL | #![macro_export]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `main` attribute cannot be used at crate level
|
||||
error: `rustc_main` attribute cannot be used at crate level
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:14:1
|
||||
|
|
||||
LL | #![main]
|
||||
| ^^^^^^^^
|
||||
LL | #![rustc_main]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: `start` attribute cannot be used at crate level
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:16:1
|
||||
|
|
@ -245,6 +223,7 @@ error: attribute should be applied to a function or static
|
|||
LL | #[export_name = "2200"] impl S { }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ ---------- not a function or static
|
||||
|
||||
error: aborting due to 36 previous errors
|
||||
error: aborting due to 32 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0518`.
|
||||
Some errors have detailed explanations: E0518, E0658.
|
||||
For more information about an error, try `rustc --explain E0518`.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// run-pass
|
||||
// ignore-wasm32-bare seems not important to test here
|
||||
|
||||
#![feature(intrinsics, main)]
|
||||
#![feature(intrinsics)]
|
||||
|
||||
mod rusti {
|
||||
extern "rust-intrinsic" {
|
||||
|
|
@ -21,7 +21,6 @@ mod rusti {
|
|||
target_os = "solaris",
|
||||
target_os = "vxworks"))]
|
||||
mod m {
|
||||
#[main]
|
||||
#[cfg(target_arch = "x86")]
|
||||
pub fn main() {
|
||||
unsafe {
|
||||
|
|
@ -30,7 +29,6 @@ mod m {
|
|||
}
|
||||
}
|
||||
|
||||
#[main]
|
||||
#[cfg(not(target_arch = "x86"))]
|
||||
pub fn main() {
|
||||
unsafe {
|
||||
|
|
@ -42,7 +40,6 @@ mod m {
|
|||
|
||||
#[cfg(target_env = "sgx")]
|
||||
mod m {
|
||||
#[main]
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
pub fn main() {
|
||||
unsafe {
|
||||
|
|
@ -54,7 +51,6 @@ mod m {
|
|||
|
||||
#[cfg(target_os = "windows")]
|
||||
mod m {
|
||||
#[main]
|
||||
pub fn main() {
|
||||
unsafe {
|
||||
assert_eq!(::rusti::pref_align_of::<u64>(), 8);
|
||||
|
|
@ -62,3 +58,7 @@ mod m {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
m::main();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#![allow(unused_variables)]
|
||||
#![deny(dead_code)]
|
||||
#![feature(main, start)]
|
||||
#![feature(rustc_attrs, start)]
|
||||
|
||||
struct Foo;
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ fn live_fn() {}
|
|||
|
||||
fn dead_fn() {} //~ ERROR: function is never used
|
||||
|
||||
#[main]
|
||||
#[rustc_main]
|
||||
fn dead_fn2() {} //~ ERROR: function is never used
|
||||
|
||||
fn used_fn() {}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
mod m {
|
||||
//~^ ERROR `main` function not found
|
||||
// An inferred main entry point (that doesn't use #[main])
|
||||
// An inferred main entry point
|
||||
// must appear at the top of the crate
|
||||
fn main() { }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ error[E0601]: `main` function not found in crate `main_wrong_location`
|
|||
|
|
||||
LL | / mod m {
|
||||
LL | |
|
||||
LL | | // An inferred main entry point (that doesn't use #[main])
|
||||
LL | | // An inferred main entry point
|
||||
LL | | // must appear at the top of the crate
|
||||
LL | | fn main() { }
|
||||
LL | | }
|
||||
|
|
@ -15,7 +15,7 @@ note: here is a function named `main`
|
|||
LL | fn main() { }
|
||||
| ^^^^^^^^^^^^^
|
||||
= note: you have one or more functions named `main` not defined at the crate level
|
||||
= help: either move the `main` function definitions or attach the `#[main]` attribute to one of them
|
||||
= help: consider moving the `main` function definitions
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
#![feature(main)]
|
||||
|
||||
#[main]
|
||||
fn bar() {
|
||||
}
|
||||
|
||||
#[main]
|
||||
fn foo() { //~ ERROR multiple functions with a `#[main]` attribute
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
error[E0137]: multiple functions with a `#[main]` attribute
|
||||
--> $DIR/multiple-main-2.rs:8:1
|
||||
|
|
||||
LL | / fn bar() {
|
||||
LL | | }
|
||||
| |_- first `#[main]` function
|
||||
...
|
||||
LL | / fn foo() {
|
||||
LL | | }
|
||||
| |_^ additional `#[main]` function
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0137`.
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
#![feature(main)]
|
||||
|
||||
#[main]
|
||||
fn main1() {
|
||||
}
|
||||
|
||||
mod foo {
|
||||
#[main]
|
||||
fn main2() { //~ ERROR multiple functions with a `#[main]` attribute
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
error[E0137]: multiple functions with a `#[main]` attribute
|
||||
--> $DIR/multiple-main-3.rs:9:5
|
||||
|
|
||||
LL | / fn main1() {
|
||||
LL | | }
|
||||
| |_- first `#[main]` function
|
||||
...
|
||||
LL | / fn main2() {
|
||||
LL | | }
|
||||
| |_____^ additional `#[main]` function
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0137`.
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
// run-pass
|
||||
// compile-flags: --test
|
||||
|
||||
#![feature(main)]
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
#![deny(dead_code)]
|
||||
|
||||
#[main]
|
||||
#[rustc_main]
|
||||
fn foo() { panic!(); }
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
// run-pass
|
||||
// compile-flags: --test
|
||||
|
||||
#![feature(main)]
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
mod a {
|
||||
fn b() {
|
||||
(|| {
|
||||
#[main]
|
||||
#[rustc_main]
|
||||
fn c() { panic!(); }
|
||||
})();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
// ignore-macos
|
||||
// ignore-windows
|
||||
|
||||
#![feature(main)]
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
#[warn(clippy::main_recursion)]
|
||||
#[allow(unconditional_recursion)]
|
||||
#[main]
|
||||
#[rustc_main]
|
||||
fn a() {
|
||||
println!("Hello, World!");
|
||||
a();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue