diff options
| author | Rageking8 <tomleetyt@gmail.com> | 2022-10-12 22:32:20 +0800 |
|---|---|---|
| committer | Rageking8 <tomleetyt@gmail.com> | 2022-10-12 22:36:30 +0800 |
| commit | 950ca0c30201471626e1a47a9b7dd7338d9ae4b7 (patch) | |
| tree | 8ed2bd796551e1fb69b28f63ed6c25f83783db7a | |
| parent | 50f6d337c632cbb5bd1dc3a80b5d428cebd8dce4 (diff) | |
| download | rust-950ca0c30201471626e1a47a9b7dd7338d9ae4b7.tar.gz rust-950ca0c30201471626e1a47a9b7dd7338d9ae4b7.zip | |
add test for issue 102964
| -rw-r--r-- | src/test/ui/issues/issue-102964.rs | 10 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-102964.stderr | 19 |
2 files changed, 29 insertions, 0 deletions
diff --git a/src/test/ui/issues/issue-102964.rs b/src/test/ui/issues/issue-102964.rs new file mode 100644 index 00000000000..43ff2360076 --- /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<Foo<'a, T>>; + +fn bar_function<T>(function: Foo<T>) -> RcFoo<T> { + //~^ 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 00000000000..4504039097b --- /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<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`. |
