1
Fork 0

Rollup merge of #102967 - Rageking8:add-test-for-issue-102964, r=TaKO8Ki

Add test for issue 102964

Fixes #102964
This commit is contained in:
Yuki Okushi 2022-10-13 09:41:26 +09:00 committed by GitHub
commit 36ea7cd88c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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`.