about summary refs log tree commit diff
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2021-09-30 18:05:20 -0700
committerGitHub <noreply@github.com>2021-09-30 18:05:20 -0700
commit730d86f521c6ccbe3c68f8f48243d289c4a124ba (patch)
treeb7075e5ecad956c1bc9b9c17ec0d8cf4546876b7
parent23d5457e6d8d4d1d943d8368af680545fb6222b2 (diff)
parent87ba8d24d608276a54a7fcbf00627353e64a5813 (diff)
downloadrust-730d86f521c6ccbe3c68f8f48243d289c4a124ba.tar.gz
rust-730d86f521c6ccbe3c68f8f48243d289c4a124ba.zip
Rollup merge of #88782 - asquared31415:issue-79559, r=cjgillot
Fix ICE when `start` lang item has wrong generics

In my previous pr #87875 I missed the requirements on the `start` lang item due to its relative difficulty to test and opting for more conservative estimates.  This fixes that by updating the requirement to be exactly one generic type.

The `start` lang item should have exactly one generic type for the return type of the `main` fn ptr passed to it.  I believe having zero would previously *sometimes* compile (often with the use of `fn() -> ()` as the fn ptr but it was likely UB to call if the return type of `main` was not `()` as far as I know) however it also sometimes would not for various errors including ICEs and LLVM errors depending on exact situations.  Having more than 1 generic has always failed with an ICE because only the one generic type is expected and provided.

Fixes #79559, fixes #73584, fixes #83117 (all duplicates)
Relevant to #9307

r? ````@cjgillot````
-rw-r--r--tests/ui/def_id_nocore.rs5
-rw-r--r--tests/ui/def_id_nocore.stderr2
2 files changed, 4 insertions, 3 deletions
diff --git a/tests/ui/def_id_nocore.rs b/tests/ui/def_id_nocore.rs
index cba7666c2d8..1ed78547a60 100644
--- a/tests/ui/def_id_nocore.rs
+++ b/tests/ui/def_id_nocore.rs
@@ -15,11 +15,12 @@ pub trait Copy {}
 pub unsafe trait Freeze {}
 
 #[lang = "start"]
-#[start]
-fn start(_argc: isize, _argv: *const *const u8) -> isize {
+fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8) -> isize {
     0
 }
 
+fn main() {}
+
 struct A;
 
 impl A {
diff --git a/tests/ui/def_id_nocore.stderr b/tests/ui/def_id_nocore.stderr
index 702684f6b43..6210d7c6cfd 100644
--- a/tests/ui/def_id_nocore.stderr
+++ b/tests/ui/def_id_nocore.stderr
@@ -1,5 +1,5 @@
 error: methods called `as_*` usually take `self` by reference or `self` by mutable reference
-  --> $DIR/def_id_nocore.rs:26:19
+  --> $DIR/def_id_nocore.rs:27:19
    |
 LL |     pub fn as_ref(self) -> &'static str {
    |                   ^^^^