Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

let - else expressions don't work with try stream #89

Closed
Soremwar opened this issue Jan 30, 2023 · 2 comments
Closed

let - else expressions don't work with try stream #89

Soremwar opened this issue Jan 30, 2023 · 2 comments

Comments

@Soremwar
Copy link

fn stream() -> impl Stream<Item = Result<u8, ()>>{
  yield 1;

  let Ok(x) = Err("a") else {
    Err(())?;
  };
}
expected !, found ()
rust-analyzer[type-mismatch](https://rust-analyzer.github.io/manual.html#type-mismatch)
`else` clause of `let...else` does not diverge
  expected type `!`
found unit type `()`
try adding a diverging expression, such as `return` or `panic!(..)`
@taiki-e
Copy link
Member

taiki-e commented Jan 30, 2023

I don't know the exact situation because the example you provided contains neither the stream macro nor the try_stream macro, but it is probably because syn parses let-else as Expr::Verbatim.

In that case, it could be fixed by one of the following: adjusting our code to visit Expr::Verbatim, relanding #53 (see #56), or waiting for syn 2 including dtolnay/syn#1231 to be released.

@taiki-e
Copy link
Member

taiki-e commented Jun 11, 2023

Should be fixed in 0.3.5 which updated syn to 2.

@taiki-e taiki-e closed this as completed Jun 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants