add test for issue 102964

This commit is contained in:
Rageking8 2022-10-12 22:32:20 +08:00
parent 50f6d337c6
commit 950ca0c302
2 changed files with 29 additions and 0 deletions

View File

@ -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() {}

View File

@ -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`.