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

#[span(err)] fails if the value of the arg is err #155

Closed
KodrAus opened this issue Oct 21, 2024 · 0 comments · Fixed by #160
Closed

#[span(err)] fails if the value of the arg is err #155

KodrAus opened this issue Oct 21, 2024 · 0 comments · Fixed by #160
Labels

Comments

@KodrAus
Copy link
Contributor

KodrAus commented Oct 21, 2024

fn err(err: &Error) -> &(dyn std::error::Error + 'static) {
    &**err
}

#[emit::span(err, "add {a} and {b}")]
fn add(a: String, b: String) -> Result<String, Error> {
    let a = parse(&a)?;
    let b = parse(&b)?;

    let r = a + b;

    Ok::<String, Error>(format(r))
}

will end up expanding to a match arm like:

Err(err) => (err)(&err)

where we've shadowed the err variable. We need to bind the err control parameter to an alternative identifier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant