about summary refs log tree commit diff
path: root/tests/ui/lang-items
diff options
context:
space:
mode:
authorEduardo Sánchez Muñoz <eduardosm-dev@e64.io>2023-09-17 20:13:05 +0200
committerEduardo Sánchez Muñoz <eduardosm-dev@e64.io>2023-09-19 18:15:23 +0200
commitc599761140ed1e3824a10d556395f178617e076a (patch)
tree56b4e6d6e8da4e6cfbdbcd77186a9a80e79b142b /tests/ui/lang-items
parent0692db1a9082380e027f354912229dfd6af37e78 (diff)
downloadrust-c599761140ed1e3824a10d556395f178617e076a.tar.gz
rust-c599761140ed1e3824a10d556395f178617e076a.zip
rustc_hir_analysis: add a helper to check function the signature mismatches
This function is now used to check `#[panic_handler]`, `start` lang item, `main`, `#[start]` and intrinsic functions.

The diagnosis produced are now closer to the ones produced by trait/impl method signature mismatch.
Diffstat (limited to 'tests/ui/lang-items')
-rw-r--r--tests/ui/lang-items/start_lang_item_args.argc.stderr8
-rw-r--r--tests/ui/lang-items/start_lang_item_args.argv.stderr8
-rw-r--r--tests/ui/lang-items/start_lang_item_args.argv_inner_ptr.stderr11
-rw-r--r--tests/ui/lang-items/start_lang_item_args.main_args.stderr13
-rw-r--r--tests/ui/lang-items/start_lang_item_args.main_ret.stderr13
-rw-r--r--tests/ui/lang-items/start_lang_item_args.main_ty.stderr8
-rw-r--r--tests/ui/lang-items/start_lang_item_args.missing_all_args.stderr9
-rw-r--r--tests/ui/lang-items/start_lang_item_args.missing_ret.stderr8
-rw-r--r--tests/ui/lang-items/start_lang_item_args.missing_sigpipe_arg.stderr9
-rw-r--r--tests/ui/lang-items/start_lang_item_args.rs24
-rw-r--r--tests/ui/lang-items/start_lang_item_args.sigpipe.stderr8
-rw-r--r--tests/ui/lang-items/start_lang_item_args.start_ret.stderr8
-rw-r--r--tests/ui/lang-items/start_lang_item_args.too_many_args.stderr9
13 files changed, 81 insertions, 55 deletions
diff --git a/tests/ui/lang-items/start_lang_item_args.argc.stderr b/tests/ui/lang-items/start_lang_item_args.argc.stderr
index 65c99a93c75..66d4397a293 100644
--- a/tests/ui/lang-items/start_lang_item_args.argc.stderr
+++ b/tests/ui/lang-items/start_lang_item_args.argc.stderr
@@ -1,8 +1,12 @@
-error: parameter 2 of the `start` lang item is incorrect
+error[E0308]: lang item `start` function has wrong type
   --> $DIR/start_lang_item_args.rs:75:38
    |
 LL | fn start<T>(_main: fn() -> T, _argc: i8, _argv: *const *const u8, _sigpipe: u8) -> isize {
-   |                                      ^^ help: change the type from `i8` to `isize`
+   |                                      ^^ expected `isize`, found `i8`
+   |
+   = note: expected signature `fn(fn() -> _, isize, _, _) -> _`
+              found signature `fn(fn() -> _, i8, _, _) -> _`
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/lang-items/start_lang_item_args.argv.stderr b/tests/ui/lang-items/start_lang_item_args.argv.stderr
index f0947a9b3e9..53d776cd846 100644
--- a/tests/ui/lang-items/start_lang_item_args.argv.stderr
+++ b/tests/ui/lang-items/start_lang_item_args.argv.stderr
@@ -1,8 +1,12 @@
-error: parameter 3 of the `start` lang item is incorrect
+error[E0308]: lang item `start` function has wrong type
   --> $DIR/start_lang_item_args.rs:89:52
    |
 LL | fn start<T>(_main: fn() -> T, _argc: isize, _argv: u8, _sigpipe: u8) -> isize {
-   |                                                    ^^ help: change the type from `u8` to `*const *const u8`
+   |                                                    ^^ expected `*const *const u8`, found `u8`
+   |
+   = note: expected signature `fn(fn() -> _, _, *const *const u8, _) -> _`
+              found signature `fn(fn() -> _, _, u8, _) -> _`
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/lang-items/start_lang_item_args.argv_inner_ptr.stderr b/tests/ui/lang-items/start_lang_item_args.argv_inner_ptr.stderr
index 08efd5088f9..7d002e090b5 100644
--- a/tests/ui/lang-items/start_lang_item_args.argv_inner_ptr.stderr
+++ b/tests/ui/lang-items/start_lang_item_args.argv_inner_ptr.stderr
@@ -1,13 +1,12 @@
-error: parameter 3 of the `start` lang item is incorrect
+error[E0308]: lang item `start` function has wrong type
   --> $DIR/start_lang_item_args.rs:82:52
    |
 LL | fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const usize, _sigpipe: u8) -> isize {
-   |                                                    ^^^^^^^^^^^^^^^^^^^
+   |                                                    ^^^^^^^^^^^^^^^^^^^ expected `u8`, found `usize`
    |
-help: change the type from `*const *const usize` to `*const *const u8`
-   |
-LL | fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize {
-   |                                                    ~~~~~~~~~~~~~~~~
+   = note: expected signature `fn(fn() -> _, _, *const *const u8, _) -> _`
+              found signature `fn(fn() -> _, _, *const *const usize, _) -> _`
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/lang-items/start_lang_item_args.main_args.stderr b/tests/ui/lang-items/start_lang_item_args.main_args.stderr
index c20a744661d..91994b9d742 100644
--- a/tests/ui/lang-items/start_lang_item_args.main_args.stderr
+++ b/tests/ui/lang-items/start_lang_item_args.main_args.stderr
@@ -1,13 +1,12 @@
-error: parameter 1 of the `start` lang item is incorrect
-  --> $DIR/start_lang_item_args.rs:61:20
+error[E0308]: lang item `start` function has wrong type
+  --> $DIR/start_lang_item_args.rs:61:1
    |
 LL | fn start<T>(_main: fn(i32) -> T, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize {
-   |                    ^^^^^^^^^^^^
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect number of function parameters
    |
-help: change the type from `fn(i32) -> T` to `fn() -> T`
-   |
-LL | fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize {
-   |                    ~~~~~~~~~
+   = note: expected signature `fn(fn() -> _, _, _, _) -> _`
+              found signature `fn(fn(i32) -> _, _, _, _) -> _`
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/lang-items/start_lang_item_args.main_ret.stderr b/tests/ui/lang-items/start_lang_item_args.main_ret.stderr
index 8f967252f49..4582b69850c 100644
--- a/tests/ui/lang-items/start_lang_item_args.main_ret.stderr
+++ b/tests/ui/lang-items/start_lang_item_args.main_ret.stderr
@@ -1,13 +1,14 @@
-error: parameter 1 of the `start` lang item is incorrect
+error[E0308]: lang item `start` function has wrong type
   --> $DIR/start_lang_item_args.rs:68:20
    |
 LL | fn start<T>(_main: fn() -> u16, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize {
-   |                    ^^^^^^^^^^^
+   |          -         ^^^^^^^^^^^ expected type parameter `T`, found `u16`
+   |          |
+   |          this type parameter
    |
-help: change the type from `fn() -> u16` to `fn() -> T`
-   |
-LL | fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize {
-   |                    ~~~~~~~~~
+   = note: expected signature `fn(fn() -> T, _, _, _) -> _`
+              found signature `fn(fn() -> u16, _, _, _) -> _`
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/lang-items/start_lang_item_args.main_ty.stderr b/tests/ui/lang-items/start_lang_item_args.main_ty.stderr
index deb37b868ea..87940d05e78 100644
--- a/tests/ui/lang-items/start_lang_item_args.main_ty.stderr
+++ b/tests/ui/lang-items/start_lang_item_args.main_ty.stderr
@@ -1,8 +1,12 @@
-error: parameter 1 of the `start` lang item is incorrect
+error[E0308]: lang item `start` function has wrong type
   --> $DIR/start_lang_item_args.rs:54:20
    |
 LL | fn start<T>(_main: u64, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize {
-   |                    ^^^ help: change the type from `u64` to `fn() -> T`
+   |                    ^^^ expected fn pointer, found `u64`
+   |
+   = note: expected signature `fn(fn() -> T, _, _, _) -> _`
+              found signature `fn(u64, _, _, _) -> _`
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/lang-items/start_lang_item_args.missing_all_args.stderr b/tests/ui/lang-items/start_lang_item_args.missing_all_args.stderr
index 004c2a67f62..5363871e202 100644
--- a/tests/ui/lang-items/start_lang_item_args.missing_all_args.stderr
+++ b/tests/ui/lang-items/start_lang_item_args.missing_all_args.stderr
@@ -1,11 +1,12 @@
-error: incorrect number of parameters for the `start` lang item
+error[E0308]: lang item `start` function has wrong type
   --> $DIR/start_lang_item_args.rs:15:1
    |
 LL | fn start<T>() -> isize {
-   | ^^^^^^^^^^^^^^^^^^^^^^
+   | ^^^^^^^^^^^^^^^^^^^^^^ incorrect number of function parameters
    |
-   = note: the `start` lang item should have four parameters, but found 0
-   = note: the `start` lang item should have the signature `fn(fn() -> T, isize, *const *const u8, u8) -> isize`
+   = note: expected signature `fn(fn() -> T, isize, *const *const u8, u8) -> _`
+              found signature `fn() -> _`
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/lang-items/start_lang_item_args.missing_ret.stderr b/tests/ui/lang-items/start_lang_item_args.missing_ret.stderr
index 1d8285b5900..2bb29f911a1 100644
--- a/tests/ui/lang-items/start_lang_item_args.missing_ret.stderr
+++ b/tests/ui/lang-items/start_lang_item_args.missing_ret.stderr
@@ -1,8 +1,12 @@
-error: the return type of the `start` lang item is incorrect
+error[E0308]: lang item `start` function has wrong type
   --> $DIR/start_lang_item_args.rs:29:84
    |
 LL | fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8, _sigpipe: u8) {}
-   |                                                                                    ^ help: change the type from `()` to `isize`
+   |                                                                                    ^ expected `isize`, found `()`
+   |
+   = note: expected signature `fn(fn() -> _, _, _, _) -> isize`
+              found signature `fn(fn() -> _, _, _, _)`
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/lang-items/start_lang_item_args.missing_sigpipe_arg.stderr b/tests/ui/lang-items/start_lang_item_args.missing_sigpipe_arg.stderr
index e545a750f24..f873f7614bd 100644
--- a/tests/ui/lang-items/start_lang_item_args.missing_sigpipe_arg.stderr
+++ b/tests/ui/lang-items/start_lang_item_args.missing_sigpipe_arg.stderr
@@ -1,11 +1,12 @@
-error: incorrect number of parameters for the `start` lang item
+error[E0308]: lang item `start` function has wrong type
   --> $DIR/start_lang_item_args.rs:22:1
    |
 LL | fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8) -> isize {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect number of function parameters
    |
-   = note: the `start` lang item should have four parameters, but found 3
-   = note: the `start` lang item should have the signature `fn(fn() -> T, isize, *const *const u8, u8) -> isize`
+   = note: expected signature `fn(fn() -> T, isize, *const *const u8, u8) -> _`
+              found signature `fn(fn() -> T, isize, *const *const u8) -> _`
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/lang-items/start_lang_item_args.rs b/tests/ui/lang-items/start_lang_item_args.rs
index 0dbfba39cb6..4a0302bcb15 100644
--- a/tests/ui/lang-items/start_lang_item_args.rs
+++ b/tests/ui/lang-items/start_lang_item_args.rs
@@ -13,33 +13,33 @@ pub trait Sized {}
 #[cfg(missing_all_args)]
 #[lang = "start"]
 fn start<T>() -> isize {
-    //[missing_all_args]~^ ERROR incorrect number of parameters
+    //[missing_all_args]~^ ERROR lang item `start` function has wrong type [E0308]
     100
 }
 
 #[cfg(missing_sigpipe_arg)]
 #[lang = "start"]
 fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8) -> isize {
-    //[missing_sigpipe_arg]~^ ERROR incorrect number of parameters
+    //[missing_sigpipe_arg]~^ ERROR lang item `start` function has wrong type [E0308]
     100
 }
 
 #[cfg(missing_ret)]
 #[lang = "start"]
 fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8, _sigpipe: u8) {}
-//[missing_ret]~^ ERROR the return type of the `start` lang item is incorrect
+//[missing_ret]~^ ERROR lang item `start` function has wrong type [E0308]
 
 #[cfg(start_ret)]
 #[lang = "start"]
 fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> u8 {
-    //[start_ret]~^ ERROR the return type of the `start` lang item is incorrect
+    //[start_ret]~^ ERROR lang item `start` function has wrong type [E0308]
     100
 }
 
 #[cfg(too_many_args)]
 #[lang = "start"]
 fn start<T>(
-    //[too_many_args]~^ ERROR incorrect number of parameters
+    //[too_many_args]~^ ERROR lang item `start` function has wrong type [E0308]
     _main: fn() -> T,
     _argc: isize,
     _argv: *const *const u8,
@@ -52,49 +52,49 @@ fn start<T>(
 #[cfg(main_ty)]
 #[lang = "start"]
 fn start<T>(_main: u64, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize {
-    //[main_ty]~^ ERROR parameter 1 of the `start` lang item is incorrect
+    //[main_ty]~^ ERROR lang item `start` function has wrong type [E0308]
     100
 }
 
 #[cfg(main_args)]
 #[lang = "start"]
 fn start<T>(_main: fn(i32) -> T, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize {
-    //[main_args]~^ ERROR parameter 1 of the `start` lang item is incorrect
+    //[main_args]~^ ERROR lang item `start` function has wrong type [E0308]
     100
 }
 
 #[cfg(main_ret)]
 #[lang = "start"]
 fn start<T>(_main: fn() -> u16, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize {
-    //[main_ret]~^ ERROR parameter 1 of the `start` lang item is incorrect
+    //[main_ret]~^ ERROR lang item `start` function has wrong type [E0308]
     100
 }
 
 #[cfg(argc)]
 #[lang = "start"]
 fn start<T>(_main: fn() -> T, _argc: i8, _argv: *const *const u8, _sigpipe: u8) -> isize {
-    //[argc]~^ ERROR parameter 2 of the `start` lang item is incorrect
+    //[argc]~^ ERROR lang item `start` function has wrong type [E0308]
     100
 }
 
 #[cfg(argv_inner_ptr)]
 #[lang = "start"]
 fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const usize, _sigpipe: u8) -> isize {
-    //[argv_inner_ptr]~^ ERROR parameter 3 of the `start` lang item is incorrect
+    //[argv_inner_ptr]~^ ERROR lang item `start` function has wrong type [E0308]
     100
 }
 
 #[cfg(argv)]
 #[lang = "start"]
 fn start<T>(_main: fn() -> T, _argc: isize, _argv: u8, _sigpipe: u8) -> isize {
-    //[argv]~^ ERROR parameter 3 of the `start` lang item is incorrect
+    //[argv]~^ ERROR lang item `start` function has wrong type [E0308]
     100
 }
 
 #[cfg(sigpipe)]
 #[lang = "start"]
 fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8, _sigpipe: i64) -> isize {
-    //[sigpipe]~^ ERROR parameter 4 of the `start` lang item is incorrect
+    //[sigpipe]~^ ERROR lang item `start` function has wrong type [E0308]
     100
 }
 
diff --git a/tests/ui/lang-items/start_lang_item_args.sigpipe.stderr b/tests/ui/lang-items/start_lang_item_args.sigpipe.stderr
index b20ae312801..280d423bd7e 100644
--- a/tests/ui/lang-items/start_lang_item_args.sigpipe.stderr
+++ b/tests/ui/lang-items/start_lang_item_args.sigpipe.stderr
@@ -1,8 +1,12 @@
-error: parameter 4 of the `start` lang item is incorrect
+error[E0308]: lang item `start` function has wrong type
   --> $DIR/start_lang_item_args.rs:96:80
    |
 LL | fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8, _sigpipe: i64) -> isize {
-   |                                                                                ^^^ help: change the type from `i64` to `u8`
+   |                                                                                ^^^ expected `u8`, found `i64`
+   |
+   = note: expected signature `fn(fn() -> _, _, _, u8) -> _`
+              found signature `fn(fn() -> _, _, _, i64) -> _`
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/lang-items/start_lang_item_args.start_ret.stderr b/tests/ui/lang-items/start_lang_item_args.start_ret.stderr
index 935d5f3c8b4..4e4f8a5cdb3 100644
--- a/tests/ui/lang-items/start_lang_item_args.start_ret.stderr
+++ b/tests/ui/lang-items/start_lang_item_args.start_ret.stderr
@@ -1,8 +1,12 @@
-error: the return type of the `start` lang item is incorrect
+error[E0308]: lang item `start` function has wrong type
   --> $DIR/start_lang_item_args.rs:34:87
    |
 LL | fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> u8 {
-   |                                                                                       ^^ help: change the type from `u8` to `isize`
+   |                                                                                       ^^ expected `isize`, found `u8`
+   |
+   = note: expected signature `fn(fn() -> _, _, _, _) -> isize`
+              found signature `fn(fn() -> _, _, _, _) -> u8`
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/lang-items/start_lang_item_args.too_many_args.stderr b/tests/ui/lang-items/start_lang_item_args.too_many_args.stderr
index 30a7ed18a3d..085d4b1f238 100644
--- a/tests/ui/lang-items/start_lang_item_args.too_many_args.stderr
+++ b/tests/ui/lang-items/start_lang_item_args.too_many_args.stderr
@@ -1,4 +1,4 @@
-error: incorrect number of parameters for the `start` lang item
+error[E0308]: lang item `start` function has wrong type
   --> $DIR/start_lang_item_args.rs:41:1
    |
 LL | / fn start<T>(
@@ -8,10 +8,11 @@ LL | |     _argc: isize,
 ...  |
 LL | |     _extra_arg: (),
 LL | | ) -> isize {
-   | |__________^
+   | |__________^ incorrect number of function parameters
    |
-   = note: the `start` lang item should have four parameters, but found 5
-   = note: the `start` lang item should have the signature `fn(fn() -> T, isize, *const *const u8, u8) -> isize`
+   = note: expected signature `fn(fn() -> T, isize, *const *const u8, u8) -> _`
+              found signature `fn(fn() -> T, isize, *const *const u8, u8, ()) -> _`
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0308`.