diff --git a/src/test/ui/issues/issue-102964.rs b/src/test/ui/issues/issue-102964.rs new file mode 100644 index 0000000000000..43ff23600766e --- /dev/null +++ b/src/test/ui/issues/issue-102964.rs @@ -0,0 +1,10 @@ +use std::rc::Rc; +type Foo<'a, T> = &'a dyn Fn(&T); +type RcFoo<'a, T> = Rc>; + +fn bar_function(function: Foo) -> RcFoo { + //~^ ERROR mismatched types + let rc = Rc::new(function); +} + +fn main() {} diff --git a/src/test/ui/issues/issue-102964.stderr b/src/test/ui/issues/issue-102964.stderr new file mode 100644 index 0000000000000..4504039097b5d --- /dev/null +++ b/src/test/ui/issues/issue-102964.stderr @@ -0,0 +1,19 @@ +error[E0308]: mismatched types + --> $DIR/issue-102964.rs:5:41 + | +LL | fn bar_function(function: Foo) -> RcFoo { + | ------------ ^^^^^^^^ 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`.