Auto merge of #134299 - RalfJung:remove-start, r=compiler-errors
remove support for the (unstable) #[start] attribute As explained by `@Noratrieb:` `#[start]` should be deleted. It's nothing but an accidentally leaked implementation detail that's a not very useful mix between "portable" entrypoint logic and bad abstraction. I think the way the stable user-facing entrypoint should work (and works today on stable) is pretty simple: - `std`-using cross-platform programs should use `fn main()`. the compiler, together with `std`, will then ensure that code ends up at `main` (by having a platform-specific entrypoint that gets directed through `lang_start` in `std` to `main` - but that's just an implementation detail) - `no_std` platform-specific programs should use `#![no_main]` and define their own platform-specific entrypoint symbol with `#[no_mangle]`, like `main`, `_start`, `WinMain` or `my_embedded_platform_wants_to_start_here`. most of them only support a single platform anyways, and need cfg for the different platform's ways of passing arguments or other things *anyways* `#[start]` is in a super weird position of being neither of those two. It tries to pretend that it's cross-platform, but its signature is a total lie. Those arguments are just stubbed out to zero on ~~Windows~~ wasm, for example. It also only handles the platform-specific entrypoints for a few platforms that are supported by `std`, like Windows or Unix-likes. `my_embedded_platform_wants_to_start_here` can't use it, and neither could a libc-less Linux program. So we have an attribute that only works in some cases anyways, that has a signature that's a total lie (and a signature that, as I might want to add, has changed recently, and that I definitely would not be comfortable giving *any* stability guarantees on), and where there's a pretty easy way to get things working without it in the first place. Note that this feature has **not** been RFCed in the first place. *This comment was posted [in May](https://github.com/rust-lang/rust/issues/29633#issuecomment-2088596042) and so far nobody spoke up in that issue with a usecase that would require keeping the attribute.* Closes https://github.com/rust-lang/rust/issues/29633 try-job: x86_64-gnu-nopt try-job: x86_64-msvc-1 try-job: x86_64-msvc-2 try-job: test-various
This commit is contained in:
commit
ed43cbcb88
176 changed files with 454 additions and 1260 deletions
|
@ -1,32 +1,3 @@
|
|||
#### Note: this error code is no longer emitted by the compiler.
|
||||
|
||||
A function with the `start` attribute was declared with type parameters.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0132
|
||||
#![feature(start)]
|
||||
|
||||
#[start]
|
||||
fn f<T>() {}
|
||||
```
|
||||
|
||||
It is not possible to declare type parameters on a function that has the `start`
|
||||
attribute. Such a function must have the following type signature (for more
|
||||
information, view [the unstable book][1]):
|
||||
|
||||
[1]: https://doc.rust-lang.org/unstable-book/language-features/start.html
|
||||
|
||||
```
|
||||
# let _:
|
||||
fn(isize, *const *const u8) -> isize;
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
#![feature(start)]
|
||||
|
||||
#[start]
|
||||
fn my_start(argc: isize, argv: *const *const u8) -> isize {
|
||||
0
|
||||
}
|
||||
```
|
||||
|
|
|
@ -1,25 +1,3 @@
|
|||
#### Note: this error code is no longer emitted by the compiler.
|
||||
|
||||
More than one function was declared with the `#[start]` attribute.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0138
|
||||
#![feature(start)]
|
||||
|
||||
#[start]
|
||||
fn foo(argc: isize, argv: *const *const u8) -> isize {}
|
||||
|
||||
#[start]
|
||||
fn f(argc: isize, argv: *const *const u8) -> isize {}
|
||||
// error: multiple 'start' functions
|
||||
```
|
||||
|
||||
This error indicates that the compiler found multiple functions with the
|
||||
`#[start]` attribute. This is an error because there must be a unique entry
|
||||
point into a Rust program. Example:
|
||||
|
||||
```
|
||||
#![feature(start)]
|
||||
|
||||
#[start]
|
||||
fn foo(argc: isize, argv: *const *const u8) -> isize { 0 } // ok!
|
||||
```
|
||||
|
|
|
@ -1,13 +1,3 @@
|
|||
#### Note: this error code is no longer emitted by the compiler.
|
||||
|
||||
The `start` function was defined with a where clause.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0647
|
||||
#![feature(start)]
|
||||
|
||||
#[start]
|
||||
fn start(_: isize, _: *const *const u8) -> isize where (): Copy {
|
||||
//^ error: `#[start]` function is not allowed to have a where clause
|
||||
0
|
||||
}
|
||||
```
|
||||
|
|
|
@ -24,6 +24,10 @@
|
|||
//
|
||||
// Both columns are necessary because it's not possible in Rust to create a new identifier such as
|
||||
// `E0123` from an integer literal such as `0123`, unfortunately.
|
||||
//
|
||||
// Do *not* remove entries from this list. Instead, just add a note th the corresponding markdown
|
||||
// file saying that this error is not emitted by the compiler any more (see E0001.md for an
|
||||
// example), and remove all code examples that do not build any more.
|
||||
#[macro_export]
|
||||
macro_rules! error_codes {
|
||||
($macro:path) => (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue