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

Fix warnings when #[pin_project] used within macro_rules! macros #298

Merged
merged 1 commit into from
Oct 15, 2020

Conversation

taiki-e
Copy link
Owner

@taiki-e taiki-e commented Oct 15, 2020

When #[pin_project] attribute used within macro_rules! macros, the generated code receives warnings.

#![warn(missing_debug_implementations)]

#[pin_project::pin_project] // <- no warning
#[derive(Debug)]
pub struct A {
    #[pin]
    _f: (),
}

macro_rules! mac {
    () => {
        #[pin_project::pin_project] //~WARN type does not implement `Debug`
        #[derive(Debug)]
        pub struct B {
            #[pin]
            _f: (),
        }
    };
}

mac!();

playground

Refs: rust-lang/rust#77973

tests/lint.rs Outdated Show resolved Hide resolved
@Aaron1011
Copy link
Collaborator

The missing_debug_implementations warning seems like a rustc bug.

@taiki-e
Copy link
Owner Author

taiki-e commented Oct 15, 2020

@Aaron1011 I agree. I'll file an issue on rust repo.

@taiki-e
Copy link
Owner Author

taiki-e commented Oct 15, 2020

Filed rust-lang/rust#77973

@Aaron1011
Copy link
Collaborator

Actually, it looks like the warning is actually being emitted for the generated projection struct (__B<'pin>) both with and without the wrapping macro_rules!. Due to the span at pin-project uses, the lint appears to be for the main struct.

However, it looks like the lint normally get suppresed here: https://github.com/rust-lang/rust/blob/7f587168102498a488abf608a86c7fdfa62fb7bb/compiler/rustc_middle/src/lint.rs#L245-L260, due to it being emitted from the external pin-project macro.

@taiki-e
Copy link
Owner Author

taiki-e commented Oct 15, 2020

bors r+

@bors
Copy link
Contributor

bors bot commented Oct 15, 2020

Build succeeded:

@bors bors bot merged commit 315d10f into master Oct 15, 2020
@bors bors bot deleted the warnings branch October 15, 2020 14:26
@taiki-e taiki-e added the A-pin-projection Area: #[pin_project] label Oct 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-pin-projection Area: #[pin_project]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants