about summary refs log tree commit diff
path: root/tests/ui/function-pointer
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-12-19 15:26:26 +0100
committerGitHub <noreply@github.com>2024-12-19 15:26:26 +0100
commit4f053b18f53c019f36f79f429bbc01ec5c53e8dc (patch)
tree0f1ebb7dabe79c764d8a643dfc31aaaa30e07041 /tests/ui/function-pointer
parentbfbe72ed02afa7ae4e3ab820f9139b12323bb30d (diff)
parent987656f5096c89377d4b58cda5e659f21437001f (diff)
downloadrust-4f053b18f53c019f36f79f429bbc01ec5c53e8dc.tar.gz
rust-4f053b18f53c019f36f79f429bbc01ec5c53e8dc.zip
Rollup merge of #134506 - oli-obk:push-mrrulszyuslt, r=jieyouxu
Remove a duplicated check that doesn't do anything anymore.

fixes #134005

This code didn't actually `lub` the type of the previous expressions, but just the current type over and over again. Changing it to using the actual expression type does not change anything either, so may as well remove the entire loop.
Diffstat (limited to 'tests/ui/function-pointer')
-rw-r--r--tests/ui/function-pointer/signature-mismatch.rs6
-rw-r--r--tests/ui/function-pointer/signature-mismatch.stderr12
2 files changed, 18 insertions, 0 deletions
diff --git a/tests/ui/function-pointer/signature-mismatch.rs b/tests/ui/function-pointer/signature-mismatch.rs
new file mode 100644
index 00000000000..f269e9bf84b
--- /dev/null
+++ b/tests/ui/function-pointer/signature-mismatch.rs
@@ -0,0 +1,6 @@
+//! This test used to hit an assertion instead of erroring and bailing out.
+
+fn main() {
+    let _ = [std::ops::Add::add, std::ops::Mul::mul, std::ops::Mul::mul as fn(_, &_)];
+    //~^ ERROR: mismatched types
+}
diff --git a/tests/ui/function-pointer/signature-mismatch.stderr b/tests/ui/function-pointer/signature-mismatch.stderr
new file mode 100644
index 00000000000..f02a576e511
--- /dev/null
+++ b/tests/ui/function-pointer/signature-mismatch.stderr
@@ -0,0 +1,12 @@
+error[E0308]: mismatched types
+  --> $DIR/signature-mismatch.rs:4:54
+   |
+LL |     let _ = [std::ops::Add::add, std::ops::Mul::mul, std::ops::Mul::mul as fn(_, &_)];
+   |                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
+   |
+   = note: expected fn pointer `fn(_, _) -> _`
+              found fn pointer `for<'a> fn(_, &'a _) -> ()`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0308`.