Skip to content

Commit

Permalink
add test for issue 102964
Browse files Browse the repository at this point in the history
  • Loading branch information
Rageking8 committed Oct 12, 2022
1 parent 50f6d33 commit 950ca0c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/test/ui/issues/issue-102964.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use std::rc::Rc;
type Foo<'a, T> = &'a dyn Fn(&T);
type RcFoo<'a, T> = Rc<Foo<'a, T>>;

fn bar_function<T>(function: Foo<T>) -> RcFoo<T> {
//~^ ERROR mismatched types
let rc = Rc::new(function);
}

fn main() {}
19 changes: 19 additions & 0 deletions src/test/ui/issues/issue-102964.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error[E0308]: mismatched types
--> $DIR/issue-102964.rs:5:41
|
LL | fn bar_function<T>(function: Foo<T>) -> RcFoo<T> {
| ------------ ^^^^^^^^ expected struct `Rc`, found `()`
| |
| implicitly returns `()` as its body has no tail or `return` expression
|
= note: expected struct `Rc<&dyn for<'a> Fn(&'a T)>`
found unit type `()`
help: consider returning the local binding `rc`
|
LL ~ let rc = Rc::new(function);
LL + rc
|

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.

0 comments on commit 950ca0c

Please sign in to comment.