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

run_cmd!{} alone with curly braces doesn't compile #40

Closed
allmycode opened this issue Nov 2, 2021 · 1 comment
Closed

run_cmd!{} alone with curly braces doesn't compile #40

allmycode opened this issue Nov 2, 2021 · 1 comment

Comments

@allmycode
Copy link

allmycode commented Nov 2, 2021

This doesn't compile

fn main() -> std::io::Result<()> {
    run_cmd!{ls}?;
    Ok(())
}

compiles says

error: expected expression, found `?`
 --> src/main.rs:4:17
  |
4 |     run_cmd!{ls}?;
  |                 ^ expected expression

error[E0308]: mismatched types
 --> src/main.rs:4:5
  |
4 |     run_cmd!{ls}?;
  |     ^^^^^^^^^^^^ expected `()`, found enum `Result`
  |
  = note: expected unit type `()`
                  found enum `Result<(), std::io::Error>`

while this compiles fine

fn main() -> std::io::Result<()> {
    run_cmd!(ls)?;
    Ok(())
}

This with curly braces compiles too

fn main() -> std::io::Result<()> {
    let _ = run_cmd!{ls}?;
    Ok(())
}
@rust-shell-script
Copy link
Owner

This is not something this library can fix. Fortunately, rustc has already merged a recent fix: rust-lang/rust#88690, and you can use it in nightly rust now. So you just need to wait for it to become stable.

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