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
|
@ -261,7 +261,6 @@ trait_selection_oc_fn_lang_correct_type = {$lang_item_name ->
|
|||
*[lang_item_name] lang item `{$lang_item_name}`
|
||||
} function has wrong type
|
||||
trait_selection_oc_fn_main_correct_type = `main` function has wrong type
|
||||
trait_selection_oc_fn_start_correct_type = `#[start]` function has wrong type
|
||||
trait_selection_oc_generic = mismatched types
|
||||
|
||||
trait_selection_oc_if_else_different = `if` and `else` have incompatible types
|
||||
|
@ -396,7 +395,6 @@ trait_selection_subtype = ...so that the {$requirement ->
|
|||
[if_else_different] `if` and `else` have incompatible types
|
||||
[no_else] `if` missing an `else` returns `()`
|
||||
[fn_main_correct_type] `main` function has the correct type
|
||||
[fn_start_correct_type] `#[start]` function has the correct type
|
||||
[fn_lang_correct_type] lang item function has the correct type
|
||||
[intrinsic_correct_type] intrinsic has the correct type
|
||||
[method_correct_type] method receiver has the correct type
|
||||
|
@ -410,7 +408,6 @@ trait_selection_subtype_2 = ...so that {$requirement ->
|
|||
[if_else_different] `if` and `else` have incompatible types
|
||||
[no_else] `if` missing an `else` returns `()`
|
||||
[fn_main_correct_type] `main` function has the correct type
|
||||
[fn_start_correct_type] `#[start]` function has the correct type
|
||||
[fn_lang_correct_type] lang item function has the correct type
|
||||
[intrinsic_correct_type] intrinsic has the correct type
|
||||
[method_correct_type] method receiver has the correct type
|
||||
|
|
|
@ -2318,7 +2318,6 @@ impl<'tcx> ObligationCause<'tcx> {
|
|||
| ObligationCauseCode::MatchExpressionArm(_)
|
||||
| ObligationCauseCode::IfExpression { .. }
|
||||
| ObligationCauseCode::LetElse
|
||||
| ObligationCauseCode::StartFunctionType
|
||||
| ObligationCauseCode::LangFunctionType(_)
|
||||
| ObligationCauseCode::IntrinsicType
|
||||
| ObligationCauseCode::MethodReceiver => FailureCode::Error0308,
|
||||
|
@ -2376,9 +2375,6 @@ impl<'tcx> ObligationCause<'tcx> {
|
|||
ObligationCauseCode::MainFunctionType => {
|
||||
ObligationCauseFailureCode::FnMainCorrectType { span }
|
||||
}
|
||||
ObligationCauseCode::StartFunctionType => {
|
||||
ObligationCauseFailureCode::FnStartCorrectType { span, subdiags }
|
||||
}
|
||||
&ObligationCauseCode::LangFunctionType(lang_item_name) => {
|
||||
ObligationCauseFailureCode::FnLangCorrectType { span, subdiags, lang_item_name }
|
||||
}
|
||||
|
@ -2421,7 +2417,6 @@ impl<'tcx> ObligationCause<'tcx> {
|
|||
"const is compatible with trait"
|
||||
}
|
||||
ObligationCauseCode::MainFunctionType => "`main` function has the correct type",
|
||||
ObligationCauseCode::StartFunctionType => "`#[start]` function has the correct type",
|
||||
ObligationCauseCode::LangFunctionType(_) => "lang item function has the correct type",
|
||||
ObligationCauseCode::IntrinsicType => "intrinsic has the correct type",
|
||||
ObligationCauseCode::MethodReceiver => "method receiver has the correct type",
|
||||
|
@ -2442,7 +2437,6 @@ impl IntoDiagArg for ObligationCauseAsDiagArg<'_> {
|
|||
"const_compat"
|
||||
}
|
||||
ObligationCauseCode::MainFunctionType => "fn_main_correct_type",
|
||||
ObligationCauseCode::StartFunctionType => "fn_start_correct_type",
|
||||
ObligationCauseCode::LangFunctionType(_) => "fn_lang_correct_type",
|
||||
ObligationCauseCode::IntrinsicType => "intrinsic_correct_type",
|
||||
ObligationCauseCode::MethodReceiver => "method_correct_type",
|
||||
|
|
|
@ -2740,7 +2740,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
| ObligationCauseCode::IfExpression { .. }
|
||||
| ObligationCauseCode::IfExpressionWithNoElse
|
||||
| ObligationCauseCode::MainFunctionType
|
||||
| ObligationCauseCode::StartFunctionType
|
||||
| ObligationCauseCode::LangFunctionType(_)
|
||||
| ObligationCauseCode::IntrinsicType
|
||||
| ObligationCauseCode::MethodReceiver
|
||||
|
|
|
@ -1695,13 +1695,6 @@ pub enum ObligationCauseFailureCode {
|
|||
#[primary_span]
|
||||
span: Span,
|
||||
},
|
||||
#[diag(trait_selection_oc_fn_start_correct_type, code = E0308)]
|
||||
FnStartCorrectType {
|
||||
#[primary_span]
|
||||
span: Span,
|
||||
#[subdiagnostic]
|
||||
subdiags: Vec<TypeErrorAdditionalDiags>,
|
||||
},
|
||||
#[diag(trait_selection_oc_fn_lang_correct_type, code = E0308)]
|
||||
FnLangCorrectType {
|
||||
#[primary_span]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue