Closed
Description
Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=a33eca3ff60c0fa5b2f73dc3e34c362f
fn bing<'a>() -> Option<&'a ()> {
None
}
struct Thing;
impl Thing {
fn bang(&self) -> Option<()> {
bing()
}
}
The current output is:
error[E0308]: mismatched types
--> src/lib.rs:9:9
|
8 | fn bang(&self) -> Option<()> {
| ---------- expected `Option<()>` because of return type
9 | bing()
| ^^^^^^ expected `()`, found `&()`
|
= note: expected enum `Option<()>`
found enum `Option<&()>`
Ideally, there should be a suggestion to add a &
to the inner type
= help: try adding a `&` to the inner type:
|
8 | fn bang(&self) -> Option<&()> {
| +