Skip to content

Commit 36ea7cd

Browse files
authored
Rollup merge of #102967 - Rageking8:add-test-for-issue-102964, r=TaKO8Ki
Add test for issue 102964 Fixes #102964
2 parents 3c8c997 + 950ca0c commit 36ea7cd

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

Diff for: src/test/ui/issues/issue-102964.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use std::rc::Rc;
2+
type Foo<'a, T> = &'a dyn Fn(&T);
3+
type RcFoo<'a, T> = Rc<Foo<'a, T>>;
4+
5+
fn bar_function<T>(function: Foo<T>) -> RcFoo<T> {
6+
//~^ ERROR mismatched types
7+
let rc = Rc::new(function);
8+
}
9+
10+
fn main() {}

Diff for: src/test/ui/issues/issue-102964.stderr

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/issue-102964.rs:5:41
3+
|
4+
LL | fn bar_function<T>(function: Foo<T>) -> RcFoo<T> {
5+
| ------------ ^^^^^^^^ expected struct `Rc`, found `()`
6+
| |
7+
| implicitly returns `()` as its body has no tail or `return` expression
8+
|
9+
= note: expected struct `Rc<&dyn for<'a> Fn(&'a T)>`
10+
found unit type `()`
11+
help: consider returning the local binding `rc`
12+
|
13+
LL ~ let rc = Rc::new(function);
14+
LL + rc
15+
|
16+
17+
error: aborting due to previous error
18+
19+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)