Skip to content

Commit d85d38b

Browse files
committed
Add test
1 parent b1691f6 commit d85d38b

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
struct S<'a>(&'a str);
2+
3+
fn f(inner: fn(&str, &S)) {
4+
}
5+
6+
#[allow(unreachable_code)]
7+
fn main() {
8+
let inner: fn(_, _) = unimplemented!();
9+
f(inner); //~ ERROR mismatched types
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/closure-with-wrong-borrows.rs:9:7
3+
|
4+
LL | f(inner);
5+
| - ^^^^^ one type is more general than the other
6+
| |
7+
| arguments to this function are incorrect
8+
|
9+
= note: expected fn pointer `for<'a, 'b, 'c> fn(&'a str, &'b S<'c>)`
10+
found fn pointer `fn(_, _)`
11+
note: function defined here
12+
--> $DIR/closure-with-wrong-borrows.rs:3:4
13+
|
14+
LL | fn f(inner: fn(&str, &S)) {
15+
| ^ -------------------
16+
help: consider removing the ``
17+
|
18+
LL | f(inner);
19+
|
20+
21+
error: aborting due to previous error
22+
23+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)