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

#[derive(Debug)] is triggering the unused_results lint #29710

Closed
canndrew opened this issue Nov 9, 2015 · 2 comments
Closed

#[derive(Debug)] is triggering the unused_results lint #29710

canndrew opened this issue Nov 9, 2015 · 2 comments
Labels
A-syntaxext Area: Syntax extensions

Comments

@canndrew
Copy link
Contributor

canndrew commented Nov 9, 2015

The following code fails to build on nightly

#![deny(unused_results)]

#[derive(Debug)]
enum Foo {
    Bar(u32),
}

It generates this error:

<anon>:3:10: 3:15 error: unused result
<anon>:3 #[derive(Debug)]
                  ^~~~~
<anon>:3:10: 3:15 note: in this expansion of #[derive_Debug] (defined in <anon>)
<anon>:1:9: 1:23 note: lint level defined here
<anon>:1 #![deny(unused_results)]
@apasel422
Copy link
Contributor

The expansion is:

#[automatically_derived]
#[allow(unused_qualifications)]
impl ::std::fmt::Debug for Foo {
    fn fmt(&self, __arg_0: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        match (&*self,) {
            (&Foo::Bar(ref __self_0),) => {
                let mut builder = __arg_0.debug_tuple("Bar");
                builder.field(&&(*__self_0));
                builder.finish()
            }
        }
    }
}

The call to builder.field(...) returns self for chaining purposes, but the expansion obviously ignores it.

@apasel422 apasel422 self-assigned this Nov 9, 2015
@apasel422
Copy link
Contributor

This was a result of #29565.

@apasel422 apasel422 removed their assignment Nov 9, 2015
alexcrichton added a commit to alexcrichton/rust that referenced this issue Nov 9, 2015
This should help avoid triggering the unused_results lint which can frequently
be turned on.

Closes rust-lang#29710
bors added a commit that referenced this issue Nov 11, 2015
This should help avoid triggering the unused_results lint which can frequently
be turned on.

Closes #29710
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-syntaxext Area: Syntax extensions
Projects
None yet
Development

No branches or pull requests

2 participants