Skip to content

Commit

Permalink
Rollup merge of rust-lang#102967 - Rageking8:add-test-for-issue-10296…
Browse files Browse the repository at this point in the history
…4, r=TaKO8Ki

Add test for issue 102964

Fixes rust-lang#102964
  • Loading branch information
JohnTitor authored Oct 12, 2022
2 parents 7d0eaaa + 950ca0c commit f903ddd
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 f903ddd

Please sign in to comment.