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

rust-lang/rust#70814: code using quote generates false lint warnings for unused_braces in juniper::graphql_object #626

Closed
grantperry opened this issue Apr 19, 2020 · 7 comments

Comments

@grantperry
Copy link
Contributor

One liner function definitions causes a lint warning about unused braces. Removing said braces, creates invalid rust.
rust-lang/rust#70814

warning: unnecessary braces around block return value
   --> src/models/user.rs:137:63
    |
137 |     fn ticket(&self, context : &SharedContext) -> Option<Ticket> { self.get_ticket(context) }
    |                                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove these braces

Minimum example

#[juniper::graphql_object]
impl Obj {
    fn ticket(&self) -> &str { &self.field }
}

I expect no lint errors.

cargo 1.44.0-nightly (ebda5065e 2020-04-16)

@grantperry grantperry added bug Something isn't working needs-triage labels Apr 19, 2020
@LegNeato LegNeato added blocked and removed bug Something isn't working needs-triage labels Apr 29, 2020
@LegNeato
Copy link
Member

Looks like this is going to be fixed in clippy.

@Igosuki
Copy link

Igosuki commented Sep 2, 2021

More than a year later and still hasn't been fixed in clippy

@Igosuki
Copy link

Igosuki commented Sep 2, 2021

As a reference anyone landing here, add a linter allowance in the mod #![allow(unused_braces)]

@tyranron
Copy link
Member

tyranron commented Sep 3, 2021

@Igosuki this should be already resolved in master due to using #[automatically_derived] attribute in #971.

@tyranron tyranron removed the blocked label Sep 3, 2021
@tyranron tyranron closed this as completed Sep 3, 2021
@Igosuki
Copy link

Igosuki commented Sep 4, 2021 via email

@twiclo
Copy link

twiclo commented Sep 20, 2022

I'm experiencing this on juniper 0.15.10. Any suggestions? (Other than the allow macro)

@tyranron
Copy link
Member

@twiclo unfortunately, juniper 0.15.10 doesn't include #971, it's only in master for the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants