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

Using await on an internal future makes private type trigger missing_debug_implementations lint #54239

Closed
seanmonstar opened this issue Sep 15, 2018 · 2 comments · Fixed by #69842
Labels
A-async-await Area: Async & Await A-coroutines Area: Coroutines A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@seanmonstar
Copy link
Contributor

#![feature(async_await, await_macro, futures_api)]
#![deny(missing_debug_implementations)]

struct DontLookAtMe(i32);

async fn secret() -> DontLookAtMe {
    DontLookAtMe(41)
}

// Comment this function out to fix the lint...
pub async fn looking() -> i32 {
    await!(secret()).0
}

fn main() {
}

Playground: https://play.rust-lang.org/?gist=0baad2fb680123d124806d6269c15c43&version=nightly&mode=debug&edition=2018

The DontLookAtMe struct isn't public, so it normally shouldn't trigger the missing_debug_implementations lint. But once await! is used on a future that happens to be holding the field somewhere inside, it trips the lint:

error: type does not implement `fmt::Debug`; consider adding #[derive(Debug)] or a manual implementation
 --> src/main.rs:4:1
  |
4 | struct DontLookAtMe(i32);
  | ^^^^^^^^^^^^^^^^^^^^^^^^^
  |
note: lint level defined here
 --> src/main.rs:2:9
  |
2 | #![deny(missing_debug_implementations)]
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

@zackmdavis zackmdavis added the A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. label Sep 15, 2018
@Nemo157
Copy link
Member

Nemo157 commented Oct 8, 2018

Appears to be a generators bug, not specific to async/await:

#![feature(generators, generator_trait)]
#![deny(missing_debug_implementations)]

use std::ops::Generator;

struct DontLookAtMe(i32);

fn secret() -> DontLookAtMe {
    DontLookAtMe(41)
}

// Comment this function out to fix the lint...
pub fn looking() -> impl Generator<Yield = (), Return = i32> {
    || {
        let d = secret();
        yield;
        d.0
    }
}

@jonas-schievink jonas-schievink added A-coroutines Area: Coroutines C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 18, 2019
@jonas-schievink jonas-schievink added the A-async-await Area: Async & Await label Feb 18, 2020
@jonas-schievink
Copy link
Contributor

Updated async/await code:

#![deny(missing_debug_implementations)]

struct DontLookAtMe(i32);

async fn secret() -> DontLookAtMe {
    DontLookAtMe(41)
}

// Comment this function out to fix the lint...
pub async fn looking() -> i32 {
    secret().await.0
}

fn main() {
}

Neither this nor the generator example trigger the lint anymore, so this looks fixed.

@jonas-schievink jonas-schievink added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Feb 18, 2020
@tmandry tmandry added the AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. label Feb 18, 2020
Centril added a commit to Centril/rust that referenced this issue Mar 9, 2020
@bors bors closed this as completed in 7e903f8 Mar 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await Area: Async & Await A-coroutines Area: Coroutines A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants