about summary refs log tree commit diff
path: root/tests/ui/function-pointer
diff options
context:
space:
mode:
authorLaurențiu Nicola <lnicola@dend.ro>2024-12-23 11:27:07 +0200
committerLaurențiu Nicola <lnicola@dend.ro>2024-12-23 11:27:07 +0200
commit9420a0b11a5403af2d08f2a2b3ece9d331b538dd (patch)
tree14d045ee9ceb0d2f0121f789571bb01dfd0dea6b /tests/ui/function-pointer
parent214134902f952ff8f1f2b24db6d3f6f531675742 (diff)
parent0eca4dd3205a01dba4bd7b7c140ec370aff03440 (diff)
downloadrust-9420a0b11a5403af2d08f2a2b3ece9d331b538dd.tar.gz
rust-9420a0b11a5403af2d08f2a2b3ece9d331b538dd.zip
Merge from rust-lang/rust
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`.