I had a variable I'd named "args" in a function. It lead to a whole bunch of compile errors on an unrelated variable when the juniper::graphql_object macro was unpacked.
It would be nice to have an error message that detects reserved words in an argument list.
We should make these hermetic or mangle the names to make it work.
Do you happen to have a quick repro and the error message?
I had a function whose header was basically this:
impl TestMutation {
async fn run_task_test(
context: &Context,
jobname: String,
taskname: String,
fsname: String,
args: String,
fidlist: Vec
) -> juniper::FieldResult
func(fidlist);
};
....
The errors were:
error[E0277]: the type str cannot be indexed by std::vec::Vec<std::string::String>
--> example.rs:57:1
|
57 | #[juniper::graphql_object(Context = Context)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string indices are ranges of usize
|
= help: the trait std::slice::SliceIndex<str> is not implemented for std::vec::Vec<std::string::String>
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> example.rs:57:1
|
57 | #[juniper::graphql_object(Context = Context)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct std::vec::Vec, found &str
|
= note: expected struct std::vec::Vec<std::string::String>
found reference &鈥榮tatic str
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound &_: juniper::FromInputValue is not satisfied
--> example.rs:57:1
|
57 | #[juniper::graphql_object(Context = Context)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait juniper::FromInputValue is not implemented for &_
|
::: /root/.cargo/git/checkouts/juniper-aa5e857cd28538c7/6326acd/juniper/src/ast.rs:153:1
|
153 | pub trait FromInputValue: Sized {
| ------------------------------------------------------- required by this bound in juniper::FromInputValue::from_implicit_null
|
= help: the following implementations were found:
>
and 27 others
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0277, E0308.
For more information about an error, try rustc --explain E0277.
error: could not compile example.
As you can see errors don't really point to "try renaming 'args'" as the solution.