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
Closed
Labels
A-async-await A-generators A-lint AsyncAwait-Triaged C-bug E-needs-test T-compiler

Comments

@seanmonstar
Copy link
Contributor

@seanmonstar seanmonstar commented Sep 15, 2018

#![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 label Sep 15, 2018
@Nemo157
Copy link
Member

@Nemo157 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-generators C-bug T-compiler labels Apr 18, 2019
@jonas-schievink jonas-schievink added the A-async-await label Feb 18, 2020
@jonas-schievink
Copy link
Member

@jonas-schievink jonas-schievink commented Feb 18, 2020

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 label Feb 18, 2020
@tmandry tmandry added the AsyncAwait-Triaged 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 A-generators A-lint AsyncAwait-Triaged C-bug E-needs-test T-compiler
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants