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

unnecessary braces warning while compiling #127

Open
acelot opened this issue Oct 16, 2020 · 3 comments
Open

unnecessary braces warning while compiling #127

acelot opened this issue Oct 16, 2020 · 3 comments
Labels
blocked by rust Bugs that we cannot fix because of a bug in Rust itself

Comments

@acelot
Copy link

acelot commented Oct 16, 2020

I have very simple GraphQL schema:

schema {
    query: Query
}

type Query {
    ping: Boolean! @juniper(infallible: true, ownership: "owned")
}
use juniper_from_schema::graphql_schema_from_file;
use crate::resources::Resources;

graphql_schema_from_file!("schema.graphql");

pub struct Query;

pub struct Context {
    resources: Resources,
}

impl juniper::Context for Context {}

i get error like this when compiling:

warning: unnecessary braces around block return value
 --> src/graphql/schema.rs:4:1
  |
4 | graphql_schema_from_file!("schema.graphql");
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove these braces
  |
  = note: `#[warn(unused_braces)]` on by default

What does it mean?

My Cargo.toml:

[dependencies]
juniper = { git = "https://github.com/graphql-rust/juniper", branch = "master" }
juniper-from-schema = { git = "https://github.com/davidpdrsn/juniper-from-schema", branch = "master" }
@davidpdrsn
Copy link
Owner

Yeah that warning is caused by some generated code. Haven't quite tracked it down yet. Have a hunch it might be coming from juniper itself.

In the meantime you can silence the warnings by adding #![allow(unused_braces)] at the top of your root module.

@acelot acelot closed this as completed Oct 16, 2020
@davidpdrsn
Copy link
Owner

I actually think it makes sense to keep this issue open until its been fixed 😊

@davidpdrsn davidpdrsn reopened this Oct 17, 2020
@davidpdrsn
Copy link
Owner

I've looked into this a bit more and I actually think we're hitting this bug rust-lang/rust#70814. If you replace the call to graphql_schema_from_file! with the exact code it expands into you don't get the warning. Very peculiar.

Afaik there is no good fix other than putting #![allow(unused_braces)] at the top of your module. I've subscribed to rust-lang/rust#70814.

Leaving this issue open for other people who might wonder about the same thing.

@davidpdrsn davidpdrsn added the blocked by rust Bugs that we cannot fix because of a bug in Rust itself label Oct 17, 2020
davidpdrsn added a commit that referenced this issue Oct 17, 2020
@davidpdrsn davidpdrsn changed the title unnecessary braces error while compiling unnecessary braces warning while compiling Nov 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked by rust Bugs that we cannot fix because of a bug in Rust itself
Projects
None yet
Development

No branches or pull requests

2 participants