tokio-rs / tracing

Application level tracing for Rust.
https://tracing.rs
MIT License
5.51k stars 723 forks source link

New lint affecting tracing::instrument macro when returning an impl #2613

Open damccull opened 1 year ago

damccull commented 1 year ago

When I updated to the latest clippy via rustup update, I ran into a new lint that doesn't seem to like returning impl SomeTrait: https://rust-lang.github.io/rust-clippy/master/index.html#/let_with_type_underscore

So tracing, when used like this is causing this lint to trigger.

#[tracing::instrument(name = "Login form", skip(flashes))]
pub async fn login_form(flashes: IncomingFlashes) -> impl IntoResponse {
//...
}
sandhose commented 1 year ago

The code which triggers this lint is generated here: https://github.com/tokio-rs/tracing/blob/e603c2a254d157a25a7a1fbfd4da46ad7e05f555/tracing-attributes/src/expand.rs#L60-L73

When the return type is an impl Trait, the #return_type here is _.

I think there are two solutions for this:

mladedav commented 1 year ago

This issue seems to have been fixed #2609.

However, what this did to us is clippy now fails for us because we're using an older rust version, where this lint is not present yet.

I don't think adding a warning to compilation is a breaking change, but it might be worthwhile to also add #![allow(unknown_lints)] for this and future similar cases where we do not want to break all compilations, right?

mladedav commented 1 year ago

This issue has been fixed and can be closed now.