-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thing
Description
I tried the code from https://github.com/tokio-rs/tracing/blob/9ae4676054067dcf99b55cb76fcee3997207de6d/tracing-attributes/tests/async_fn.rs. Here is my attempt at an MCVE, but it doesn't compile:
use async_trait::async_trait;
use tracing_attributes::instrument;
#[async_trait]
pub trait Test {
async fn call();
async fn call_with_self(&self);
async fn call_with_mut_self(&mut self);
}
#[derive(Clone, Debug)]
struct TestImpl;
#[async_trait]
impl Test for TestImpl {
// instrumenting this is currently not possible, see https://github.com/tokio-rs/tracing/issues/864#issuecomment-667508801
//#[instrument(fields(Self=std::any::type_name::<Self>()))]
async fn call() {}
#[instrument(fields(Self=std::any::type_name::<Self>()))]
async fn call_with_self(&self) {}
#[instrument(fields(Self=std::any::type_name::<Self>()))]
async fn call_with_mut_self(self: &mut Self) {}
}I expected to see this happen: cargo +nightly clippy --fix -Zunstable-options turns the code into async fn call_with_mut_self(&mut self) {}
Instead, this happened: Clippy replaces it with async fn call_with_mut_self(&'life0 mut self) {} which fails to compile.
error[E0261]: use of undeclared lifetime name `'life0`
--> tracing-attributes/tests/async_fn.rs:226:38
|
226 | async fn call_with_mut_self(&'life0 mut self) {}
| ^^^^^^ undeclared lifetime
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
help: consider introducing lifetime `'life0` here
|
217 | impl<'life0> Test for TestImpl {
| ^^^^^^^^
help: consider introducing lifetime `'life0` here
|
216 | 'life0, #[async_trait]
| ^^^^^^^
error[E0261]: use of undeclared lifetime name `'life0`
--> tracing-attributes/tests/async_fn.rs:226:38
|
226 | async fn call_with_mut_self(&'life0 mut self) {}
| - ^^^^^^ undeclared lifetime
| |
| help: consider introducing lifetime `'life0` here: `<'life0>`
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
error[E0195]: lifetime parameters or bounds on method `call_with_mut_self` do not match the trait declaration
--> tracing-attributes/tests/async_fn.rs:216:5
|
206 | #[async_trait]
| -------------- lifetimes in impl do not match this method in trait
...
216 | #[async_trait]
| ^^^^^^^^^^^^^^ lifetimes do not match method in trait
|
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
Meta
cargo clippy -V: clippy 0.0.212 (043f6d7 2020-09-25)rustc -V: rustc 1.46.0 (04488afe3 2020-08-24)
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thing