From 782eccba47d392a975dafdb84a561e83686aa891 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Nov 2023 19:00:05 +0100 Subject: [PATCH] Upgrade `syn` crate to 2.0 version (#1157) - replace `proc-macro-error` crate with simplified `common::diagnostic::pollyfill` - migrate `juniper_codegen_tests` to stable Rust Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Kai Ren --- .github/workflows/ci.yml | 12 +- Makefile | 3 +- juniper/Cargo.toml | 4 +- juniper/README.md | 2 +- juniper_codegen/CHANGELOG.md | 5 + juniper_codegen/Cargo.toml | 5 +- juniper_codegen/README.md | 2 +- juniper_codegen/src/common/deprecation.rs | 61 +++- juniper_codegen/src/common/description.rs | 17 +- juniper_codegen/src/common/diagnostic.rs | 283 +++++++++++++++++- juniper_codegen/src/common/field/arg.rs | 6 +- juniper_codegen/src/common/mod.rs | 2 +- juniper_codegen/src/common/parse/attr.rs | 2 +- .../src/common/parse/downcaster.rs | 2 +- juniper_codegen/src/common/parse/mod.rs | 19 +- juniper_codegen/src/common/scalar.rs | 10 +- juniper_codegen/src/graphql_enum/derive.rs | 6 +- .../src/graphql_input_object/derive.rs | 6 +- juniper_codegen/src/graphql_interface/attr.rs | 24 +- .../src/graphql_interface/derive.rs | 8 +- juniper_codegen/src/graphql_object/attr.rs | 18 +- juniper_codegen/src/graphql_object/derive.rs | 16 +- juniper_codegen/src/graphql_scalar/mod.rs | 5 +- juniper_codegen/src/graphql_union/attr.rs | 14 +- juniper_codegen/src/graphql_union/derive.rs | 19 +- juniper_codegen/src/lib.rs | 111 ++++--- juniper_graphql_ws/Cargo.toml | 2 +- juniper_graphql_ws/README.md | 2 +- juniper_hyper/Cargo.toml | 4 +- juniper_hyper/README.md | 2 +- juniper_iron/Cargo.toml | 2 +- juniper_iron/README.md | 2 +- juniper_rocket/Cargo.toml | 4 +- juniper_rocket/README.md | 2 +- juniper_subscriptions/Cargo.toml | 2 +- juniper_subscriptions/README.md | 2 +- juniper_warp/Cargo.toml | 4 +- juniper_warp/README.md | 2 +- .../enum/derive_duplicated_value_names.stderr | 6 +- .../derive_name_double_underscored.stderr | 3 +- .../enum/derive_variant_with_field.stderr | 3 +- .../fail/enum/derive_wrong_item.stderr | 2 +- .../derive_incompatible_field_type.stderr | 79 +++-- .../input-object/derive_no_underscore.stderr | 8 +- .../fail/interface/attr_wrong_item.stderr | 2 +- .../fail/interface/derive_wrong_item.stderr | 9 +- .../attr_field_double_underscored.stderr | 3 +- .../attr_field_non_output_return_type.stderr | 30 +- .../struct/attr_fields_duplicate.stderr | 12 +- .../struct/attr_missing_field.stderr | 24 -- .../attr_name_double_underscored.stderr | 3 +- .../interface/struct/attr_no_fields.stderr | 5 +- .../struct/attr_unnamed_field.stderr | 3 +- .../derive_field_double_underscored.stderr | 3 +- ...derive_field_non_output_return_type.stderr | 30 +- .../struct/derive_fields_duplicate.stderr | 12 +- .../struct/derive_missing_field.stderr | 24 -- .../derive_name_double_underscored.stderr | 3 +- .../interface/struct/derive_no_fields.stderr | 5 +- .../struct/derive_unnamed_field.stderr | 3 +- .../trait/argument_double_underscored.stderr | 3 +- .../trait/argument_non_input_type.stderr | 48 ++- .../trait/field_double_underscored.stderr | 3 +- .../trait/field_non_output_return_type.stderr | 30 +- .../interface/trait/fields_duplicate.stderr | 12 +- .../trait/method_default_impl.stderr | 3 +- .../fail/interface/trait/missing_field.stderr | 24 -- .../trait/name_double_underscored.stderr | 3 +- .../fail/interface/trait/no_fields.stderr | 5 +- .../object/argument_double_underscored.stderr | 3 +- .../object/argument_non_input_type.stderr | 25 +- .../attr_field_double_underscored.stderr | 2 +- .../attr_field_non_output_return_type.stderr | 6 +- .../fail/object/attr_fields_duplicate.stderr | 3 +- .../attr_name_double_underscored.stderr | 3 +- .../codegen/fail/object/attr_no_fields.stderr | 3 +- .../fail/object/attr_wrong_item.stderr | 2 +- .../derive_field_double_underscored.stderr | 3 +- ...derive_field_non_output_return_type.stderr | 30 +- .../object/derive_fields_duplicate.stderr | 11 +- .../derive_name_double_underscored.stderr | 3 +- .../fail/object/derive_no_fields.stderr | 5 +- .../fail/object/derive_wrong_item.stderr | 2 +- ...r_transparent_multiple_named_fields.stderr | 7 +- ...transparent_multiple_unnamed_fields.stderr | 2 +- .../attr_transparent_unit_struct.stderr | 2 +- ...e_transparent_multiple_named_fields.stderr | 8 +- ...transparent_multiple_unnamed_fields.stderr | 5 +- .../derive_transparent_unit_struct.stderr | 5 +- .../attr_with_not_all_resolvers.stderr | 2 +- .../type_alias/attr_without_resolvers.stderr | 2 +- .../scalar_value/missing_attributes.stderr | 14 +- .../codegen/fail/scalar_value/not_enum.stderr | 2 +- .../argument_double_underscored.stderr | 3 +- .../argument_non_input_type.stderr | 25 +- .../field_double_underscored.stderr | 2 +- .../field_non_output_return_type.stderr | 6 +- .../fail/subscription/field_not_async.stderr | 7 +- .../fail/subscription/fields_duplicate.stderr | 3 +- .../name_double_underscored.stderr | 3 +- .../fail/subscription/no_fields.stderr | 3 +- .../fail/subscription/wrong_item.stderr | 2 +- .../codegen/fail/union/attr_wrong_item.stderr | 2 +- .../fail/union/derive_wrong_item.stderr | 2 +- ...s_with_variant_external_resolver_fn.stderr | 3 +- .../union/enum_name_double_underscored.stderr | 3 +- .../codegen/fail/union/enum_no_fields.stderr | 5 +- .../fail/union/enum_non_object_variant.stderr | 31 +- .../fail/union/enum_same_type_pretty.stderr | 10 +- .../union/enum_wrong_variant_field.stderr | 6 +- .../struct_name_double_underscored.stderr | 3 +- .../fail/union/struct_no_fields.stderr | 5 +- .../union/struct_non_object_variant.stderr | 31 +- .../fail/union/struct_same_type_pretty.stderr | 2 +- ...conflicts_with_external_resolver_fn.stderr | 7 +- .../trait_name_double_underscored.stderr | 3 +- .../codegen/fail/union/trait_no_fields.stderr | 5 +- .../union/trait_non_object_variant.stderr | 31 +- .../fail/union/trait_same_type_pretty.stderr | 10 +- .../union/trait_with_attr_on_method.stderr | 5 +- .../trait_wrong_method_input_args.stderr | 5 +- .../trait_wrong_method_return_type.stderr | 5 +- tests/codegen/src/lib.rs | 2 +- 123 files changed, 810 insertions(+), 665 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fe234eee..ce5075b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -141,13 +141,13 @@ jobs: strategy: fail-fast: false matrix: - msrv: ["1.65.0"] + msrv: ["1.73.0"] crate: - juniper_codegen - juniper - juniper_subscriptions - juniper_graphql_ws - #- juniper_actix + - juniper_actix - juniper_hyper #- juniper_iron - juniper_rocket @@ -156,10 +156,6 @@ jobs: - ubuntu - macOS - windows - include: - - { msrv: "1.68.0", crate: "juniper_actix", os: "ubuntu" } - - { msrv: "1.68.0", crate: "juniper_actix", os: "macOS" } - - { msrv: "1.68.0", crate: "juniper_actix", os: "windows" } runs-on: ${{ matrix.os }}-latest steps: - uses: actions/checkout@v4 @@ -217,10 +213,10 @@ jobs: - beta - nightly exclude: - - crate: juniper_codegen_tests - toolchain: stable - crate: juniper_codegen_tests toolchain: beta + - crate: juniper_codegen_tests + toolchain: nightly - crate: juniper_codegen_tests os: macOS - crate: juniper_codegen_tests diff --git a/Makefile b/Makefile index e9656402..eab74dae 100644 --- a/Makefile +++ b/Makefile @@ -120,8 +120,7 @@ ifeq ($(shell rustup component list --toolchain=nightly \ rustup component add --toolchain=nightly rust-src endif endif - cargo $(if $(call eq,$(careful),yes),+nightly careful,\ - $(if $(call eq,$(crate),juniper_codegen_tests),+nightly,)) \ + cargo $(if $(call eq,$(careful),yes),+nightly careful,) \ test $(if $(call eq,$(crate),),--workspace,-p $(crate)) --all-features diff --git a/juniper/Cargo.toml b/juniper/Cargo.toml index 9267a85a..7c474d25 100644 --- a/juniper/Cargo.toml +++ b/juniper/Cargo.toml @@ -2,7 +2,7 @@ name = "juniper" version = "0.16.0-dev" edition = "2021" -rust-version = "1.65" +rust-version = "1.73" description = "GraphQL server library." license = "BSD-2-Clause" authors = [ @@ -68,7 +68,7 @@ time = { version = "0.3", features = ["formatting", "macros", "parsing"], option url = { version = "2.0", optional = true } uuid = { version = "1.3", default-features = false, optional = true } -# Fixes for MSRV check. +# Fixes for `minimal-versions` check. # TODO: Try remove on upgrade of `bigdecimal` crate. num-bigint = { version = "0.4.2", optional = true } # TODO: Try remove on upgrade of `chrono-tz` crate. diff --git a/juniper/README.md b/juniper/README.md index 17ed085b..bd3a77bf 100644 --- a/juniper/README.md +++ b/juniper/README.md @@ -4,7 +4,7 @@ Juniper (GraphQL server library for Rust) [![Crates.io](https://img.shields.io/crates/v/juniper.svg?maxAge=2592000)](https://crates.io/crates/juniper) [![Documentation](https://docs.rs/juniper/badge.svg)](https://docs.rs/juniper) [![CI](https://github.com/graphql-rust/juniper/workflows/CI/badge.svg?branch=master "CI")](https://github.com/graphql-rust/juniper/actions?query=workflow%3ACI+branch%3Amaster) -[![Rust 1.65+](https://img.shields.io/badge/rustc-1.65+-lightgray.svg "Rust 1.65+")](https://blog.rust-lang.org/2022/11/03/Rust-1.65.0.html) +[![Rust 1.73+](https://img.shields.io/badge/rustc-1.73+-lightgray.svg "Rust 1.73+")](https://blog.rust-lang.org/2023/10/05/Rust-1.73.0.html) - [Juniper Book] ([current][Juniper Book] | [edge][Juniper Book edge]) - [Changelog](https://github.com/graphql-rust/juniper/blob/master/juniper/CHANGELOG.md) diff --git a/juniper_codegen/CHANGELOG.md b/juniper_codegen/CHANGELOG.md index aa93555e..aad31ee3 100644 --- a/juniper_codegen/CHANGELOG.md +++ b/juniper_codegen/CHANGELOG.md @@ -38,6 +38,10 @@ All user visible changes to `juniper_codegen` crate will be documented in this f - `#[derive(GraphQLInterface)]` macro allowing using structs as GraphQL interfaces. ([#1026]) +### Changed + +- Migrated to 2 version of `syn` crate. ([#1157]) + ### Fixed - All procedural macros expansion inside `macro_rules!`. ([#1054], [#1051]) @@ -56,6 +60,7 @@ All user visible changes to `juniper_codegen` crate will be documented in this f [#1028]: /../../pull/1028 [#1051]: /../../issues/1051 [#1054]: /../../pull/1054 +[#1157]: /../../pull/1157 diff --git a/juniper_codegen/Cargo.toml b/juniper_codegen/Cargo.toml index c29edb7e..9f90def0 100644 --- a/juniper_codegen/Cargo.toml +++ b/juniper_codegen/Cargo.toml @@ -2,7 +2,7 @@ name = "juniper_codegen" version = "0.16.0-dev" edition = "2021" -rust-version = "1.65" +rust-version = "1.73" description = "Code generation for `juniper` crate." license = "BSD-2-Clause" authors = [ @@ -22,10 +22,9 @@ exclude = ["/release.toml"] proc-macro = true [dependencies] -proc-macro-error = "1.0.2" proc-macro2 = "1.0.4" quote = "1.0.9" -syn = { version = "1.0.90", features = ["extra-traits", "full", "parsing", "visit", "visit-mut"], default-features = false } +syn = { version = "2.0", features = ["extra-traits", "full", "visit", "visit-mut"] } url = "2.0" [dev-dependencies] diff --git a/juniper_codegen/README.md b/juniper_codegen/README.md index c02b2054..f704a31a 100644 --- a/juniper_codegen/README.md +++ b/juniper_codegen/README.md @@ -4,7 +4,7 @@ [![Crates.io](https://img.shields.io/crates/v/juniper_codegen.svg?maxAge=2592000)](https://crates.io/crates/juniper_codegen) [![Documentation](https://docs.rs/juniper_codegen/badge.svg)](https://docs.rs/juniper_codegen) [![CI](https://github.com/graphql-rust/juniper/workflows/CI/badge.svg?branch=master "CI")](https://github.com/graphql-rust/juniper/actions?query=workflow%3ACI+branch%3Amaster) -[![Rust 1.65+](https://img.shields.io/badge/rustc-1.65+-lightgray.svg "Rust 1.65+")](https://blog.rust-lang.org/2022/11/03/Rust-1.65.0.html) +[![Rust 1.73+](https://img.shields.io/badge/rustc-1.73+-lightgray.svg "Rust 1.73+")](https://blog.rust-lang.org/2023/10/05/Rust-1.73.0.html) - [Changelog](https://github.com/graphql-rust/juniper/blob/master/juniper_codegen/CHANGELOG.md) diff --git a/juniper_codegen/src/common/deprecation.rs b/juniper_codegen/src/common/deprecation.rs index fb7af234..f213659c 100644 --- a/juniper_codegen/src/common/deprecation.rs +++ b/juniper_codegen/src/common/deprecation.rs @@ -7,6 +7,7 @@ use proc_macro2::TokenStream; use quote::{quote, ToTokens}; use syn::{ parse::{Parse, ParseStream}, + punctuated::Punctuated, spanned::Spanned as _, token, }; @@ -20,7 +21,7 @@ use crate::common::{parse::ParseBufferExt as _, SpanContainer}; /// [0]: https://spec.graphql.org/October2021#sec--deprecated /// [1]: https://spec.graphql.org/October2021#sec-Language.Fields /// [2]: https://spec.graphql.org/October2021#sec-Enum-Value -#[derive(Debug, Default)] +#[derive(Debug, Default, Eq, PartialEq)] pub(crate) struct Directive { /// Optional [reason][1] attached to this [deprecation][0]. /// @@ -52,8 +53,8 @@ impl Directive { attrs: &[syn::Attribute], ) -> syn::Result>> { for attr in attrs { - return Ok(match attr.parse_meta() { - Ok(syn::Meta::List(ref list)) if list.path.is_ident("deprecated") => { + return Ok(match &attr.meta { + syn::Meta::List(list) if list.path.is_ident("deprecated") => { let directive = Self::parse_from_deprecated_meta_list(list)?; Some(SpanContainer::new( list.path.span(), @@ -61,7 +62,7 @@ impl Directive { directive, )) } - Ok(syn::Meta::Path(ref path)) if path.is_ident("deprecated") => { + syn::Meta::Path(path) if path.is_ident("deprecated") => { Some(SpanContainer::new(path.span(), None, Self::default())) } _ => continue, @@ -77,20 +78,24 @@ impl Directive { /// /// If the `#[deprecated(note = ...)]` attribute has incorrect format. fn parse_from_deprecated_meta_list(list: &syn::MetaList) -> syn::Result { - for meta in &list.nested { - if let syn::NestedMeta::Meta(syn::Meta::NameValue(nv)) = meta { + for meta in list.parse_args_with(Punctuated::::parse_terminated)? { + if let syn::Meta::NameValue(nv) = meta { return if !nv.path.is_ident("note") { Err(syn::Error::new( nv.path.span(), "unrecognized setting on #[deprecated(..)] attribute", )) - } else if let syn::Lit::Str(strlit) = &nv.lit { + } else if let syn::Expr::Lit(syn::ExprLit { + lit: syn::Lit::Str(strlit), + .. + }) = &nv.value + { Ok(Self { reason: Some(strlit.clone()), }) } else { Err(syn::Error::new( - nv.lit.span(), + nv.value.span(), "only strings are allowed for deprecation", )) }; @@ -112,3 +117,43 @@ impl ToTokens for Directive { .to_tokens(into); } } + +#[cfg(test)] +mod parse_from_deprecated_attr_test { + use quote::quote; + use syn::parse_quote; + + use super::Directive; + + #[test] + fn single() { + let desc = + Directive::parse_from_deprecated_attr(&[parse_quote! { #[deprecated(note = "foo")] }]) + .unwrap() + .unwrap() + .into_inner(); + assert_eq!( + quote! { #desc }.to_string(), + quote! { .deprecated(::core::option::Option::Some("foo")) }.to_string(), + ); + } + + #[test] + fn no_reason() { + let desc = Directive::parse_from_deprecated_attr(&[parse_quote! { #[deprecated] }]) + .unwrap() + .unwrap() + .into_inner(); + assert_eq!( + quote! { #desc }.to_string(), + quote! { .deprecated(::core::option::Option::None) }.to_string(), + ); + } + + #[test] + fn not_deprecation() { + let desc = + Directive::parse_from_deprecated_attr(&[parse_quote! { #[blah = "foo"] }]).unwrap(); + assert_eq!(desc, None); + } +} diff --git a/juniper_codegen/src/common/description.rs b/juniper_codegen/src/common/description.rs index cd8d739e..c3c5deae 100644 --- a/juniper_codegen/src/common/description.rs +++ b/juniper_codegen/src/common/description.rs @@ -5,7 +5,10 @@ use proc_macro2::TokenStream; use quote::{quote, ToTokens}; -use syn::parse::{Parse, ParseStream}; +use syn::{ + parse::{Parse, ParseStream}, + spanned::Spanned as _, +}; use crate::common::SpanContainer; @@ -36,16 +39,20 @@ impl Description { ) -> syn::Result>> { let (mut first_span, mut descriptions) = (None, Vec::new()); for attr in attrs { - match attr.parse_meta() { - Ok(syn::Meta::NameValue(ref nv)) if nv.path.is_ident("doc") => { - if let syn::Lit::Str(strlit) = &nv.lit { + match attr.meta { + syn::Meta::NameValue(ref nv) if nv.path.is_ident("doc") => { + if let syn::Expr::Lit(syn::ExprLit { + lit: syn::Lit::Str(strlit), + .. + }) = &nv.value + { if first_span.is_none() { first_span = Some(strlit.span()); } descriptions.push(strlit.value()); } else { return Err(syn::Error::new( - nv.lit.span(), + nv.value.span(), "#[doc] attributes may only have a string literal", )); } diff --git a/juniper_codegen/src/common/diagnostic.rs b/juniper_codegen/src/common/diagnostic.rs index d99bb504..87556bf6 100644 --- a/juniper_codegen/src/common/diagnostic.rs +++ b/juniper_codegen/src/common/diagnostic.rs @@ -1,7 +1,8 @@ use std::fmt; use proc_macro2::Span; -use proc_macro_error::{Diagnostic, Level}; + +pub(crate) use self::polyfill::{abort_if_dirty, emit_error, entry_point, Diagnostic, ResultExt}; /// URL of the GraphQL specification (October 2021 Edition). pub(crate) const SPEC_URL: &str = "https://spec.graphql.org/October2021"; @@ -55,13 +56,11 @@ impl Scope { } pub(crate) fn custom>(&self, span: Span, msg: S) -> Diagnostic { - Diagnostic::spanned(span, Level::Error, format!("{self} {}", msg.as_ref())) - .note(self.spec_link()) + Diagnostic::spanned(span, format!("{self} {}", msg.as_ref())).note(self.spec_link()) } - pub(crate) fn error(&self, err: syn::Error) -> Diagnostic { - Diagnostic::spanned(err.span(), Level::Error, format!("{self} {err}")) - .note(self.spec_link()) + pub(crate) fn error(&self, err: &syn::Error) -> Diagnostic { + Diagnostic::spanned(err.span(), format!("{self} {err}")).note(self.spec_link()) } pub(crate) fn emit_custom>(&self, span: Span, msg: S) { @@ -75,13 +74,279 @@ impl Scope { pub(crate) fn no_double_underscore(&self, field: Span) { Diagnostic::spanned( field, - Level::Error, "All types and directives defined within a schema must not have a name which begins \ with `__` (two underscores), as this is used exclusively by GraphQL’s introspection \ - system." - .into(), + system.", ) .note(format!("{SPEC_URL}#sec-Schema")) .emit(); } } + +mod polyfill { + //! Simplified version of [`proc_macro_error`] machinery for this crate purposes. + //! + //! [`proc_macro_error`]: https://docs.rs/proc-macro-error/1 + + use std::{ + cell::{Cell, RefCell}, + panic::{catch_unwind, resume_unwind, UnwindSafe}, + }; + + use proc_macro2::{Span, TokenStream}; + use quote::{quote, quote_spanned, ToTokens}; + + /// Representation of a single diagnostic message. + #[derive(Debug)] + pub(crate) struct Diagnostic { + span_range: SpanRange, + msg: String, + suggestions: Vec, + } + + impl Diagnostic { + /// Create a new [`Diagnostic`] message that points to the provided [`Span`]. + pub(crate) fn spanned(span: Span, message: impl Into) -> Self { + Self { + span_range: SpanRange { + first: span, + last: span, + }, + msg: message.into(), + suggestions: vec![], + } + } + + /// Attaches a note to the main message of this [`Diagnostic`]. + pub(crate) fn note(mut self, msg: impl Into) -> Self { + self.suggestions.push(msg.into()); + self + } + + /// Aborts macro execution and display this [`Diagnostic`]. + pub(crate) fn abort(self) -> ! { + self.emit(); + abort_now() + } + + /// Display this [`Diagnostic`] while not aborting macro execution. + pub(crate) fn emit(self) { + check_correctness(); + emit_diagnostic(self); + } + } + + impl ToTokens for Diagnostic { + fn to_tokens(&self, ts: &mut TokenStream) { + use std::borrow::Cow; + + fn ensure_lf(buf: &mut String, s: &str) { + if s.ends_with('\n') { + buf.push_str(s); + } else { + buf.push_str(s); + buf.push('\n'); + } + } + + fn diag_to_tokens( + span_range: SpanRange, + msg: &str, + suggestions: &[String], + ) -> TokenStream { + let message = if suggestions.is_empty() { + Cow::Borrowed(msg) + } else { + let mut message = String::new(); + ensure_lf(&mut message, msg); + for note in suggestions { + message.push_str("· note: "); + ensure_lf(&mut message, note); + } + Cow::Owned(message) + }; + + let mut msg = proc_macro2::Literal::string(&message); + msg.set_span(span_range.last); + let group = quote_spanned!(span_range.last=> { #msg } ); + quote_spanned!(span_range.first=> compile_error!#group) + } + + ts.extend(diag_to_tokens( + self.span_range, + &self.msg, + self.suggestions.as_ref(), + )); + } + } + + impl From for Diagnostic { + fn from(err: syn::Error) -> Self { + use proc_macro2::{Delimiter, TokenTree}; + + fn gut_error(ts: &mut impl Iterator) -> Option<(SpanRange, String)> { + let first = ts.next()?.span(); // : + assert_eq!(ts.next().unwrap().to_string(), ":"); + assert_eq!(ts.next().unwrap().to_string(), "core"); + assert_eq!(ts.next().unwrap().to_string(), ":"); + assert_eq!(ts.next().unwrap().to_string(), ":"); + assert_eq!(ts.next().unwrap().to_string(), "compile_error"); + assert_eq!(ts.next().unwrap().to_string(), "!"); + + let lit = match ts.next().unwrap() { + TokenTree::Group(group) => { + // Currently `syn` builds `compile_error!` invocations + // exclusively in `ident{"..."}` (braced) form which is not + // followed by `;` (semicolon). + // + // But if it changes to `ident("...");` (parenthesized) + // or `ident["..."];` (bracketed) form, + // we will need to skip the `;` as well. + // Highly unlikely, but better safe than sorry. + + if group.delimiter() == Delimiter::Parenthesis + || group.delimiter() == Delimiter::Bracket + { + ts.next().unwrap(); // ; + } + + match group.stream().into_iter().next().unwrap() { + TokenTree::Literal(lit) => lit, + tt => unreachable!("Diagnostic::gut_error(): TokenTree::Group: {tt}"), + } + } + tt => unreachable!("Diagnostic::gut_error(): {tt}"), + }; + + let last = lit.span(); + let mut msg = lit.to_string(); + + // "abc" => abc + msg.pop(); + msg.remove(0); + + Some((SpanRange { first, last }, msg)) + } + + let mut ts = err.to_compile_error().into_iter(); + + let (span_range, msg) = gut_error(&mut ts).unwrap(); + + Self { + span_range, + msg, + suggestions: vec![], + } + } + } + + /// Emits a [`syn::Error`] while not aborting macro execution. + pub(crate) fn emit_error(e: syn::Error) { + Diagnostic::from(e).emit() + } + + /// Range of [`Span`]s. + #[derive(Clone, Copy, Debug)] + struct SpanRange { + first: Span, + last: Span, + } + + thread_local! { + static ENTERED_ENTRY_POINT: Cell = Cell::new(0); + } + + /// This is the entry point for a macro to support [`Diagnostic`]s. + pub(crate) fn entry_point(f: F) -> proc_macro::TokenStream + where + F: FnOnce() -> proc_macro::TokenStream + UnwindSafe, + { + ENTERED_ENTRY_POINT.with(|flag| flag.set(flag.get() + 1)); + let caught = catch_unwind(f); + let err_storage = ERR_STORAGE.with(|s| s.replace(Vec::new())); + ENTERED_ENTRY_POINT.with(|flag| flag.set(flag.get() - 1)); + + let gen_error = || { + quote! { #( #err_storage )* } + }; + + match caught { + Ok(ts) => { + if err_storage.is_empty() { + ts + } else { + gen_error().into() + } + } + + Err(boxed) => match boxed.downcast_ref::<&str>() { + Some(p) if *p == "diagnostic::polyfill::abort_now" => gen_error().into(), + _ => resume_unwind(boxed), + }, + } + } + + fn check_correctness() { + if ENTERED_ENTRY_POINT.get() == 0 { + panic!( + "`common::diagnostic` API cannot be used outside of `entry_point()` invocation, \ + perhaps you forgot to invoke it your #[proc_macro] function", + ); + } + } + + thread_local! { + static ERR_STORAGE: RefCell> = RefCell::new(Vec::new()); + } + + /// Emits the provided [`Diagnostic`], while not aborting macro execution. + fn emit_diagnostic(diag: Diagnostic) { + ERR_STORAGE.with(|s| s.borrow_mut().push(diag)); + } + + /// Aborts macro execution. if any [`Diagnostic`]s were emitted before. + pub(crate) fn abort_if_dirty() { + check_correctness(); + ERR_STORAGE.with(|s| { + if !s.borrow().is_empty() { + abort_now() + } + }); + } + + fn abort_now() -> ! { + check_correctness(); + panic!("diagnostic::polyfill::abort_now") + } + + /// Extension of `Result>` with some handy shortcuts. + pub(crate) trait ResultExt { + type Ok; + + /// Behaves like [`Result::unwrap()`]: if `self` is [`Ok`] yield the contained value, + /// otherwise abort macro execution. + fn unwrap_or_abort(self) -> Self::Ok; + + /// Behaves like [`Result::expect()`]: if `self` is [`Ok`] yield the contained value, + /// otherwise abort macro execution. + /// + /// If it aborts then resulting error message will be preceded with the provided `message`. + fn expect_or_abort(self, message: &str) -> Self::Ok; + } + + impl> ResultExt for Result { + type Ok = T; + + fn unwrap_or_abort(self) -> T { + self.unwrap_or_else(|e| e.into().abort()) + } + + fn expect_or_abort(self, message: &str) -> T { + self.unwrap_or_else(|e| { + let mut d = e.into(); + d.msg = format!("{message}: {}", d.msg); + d.abort() + }) + } + } +} diff --git a/juniper_codegen/src/common/field/arg.rs b/juniper_codegen/src/common/field/arg.rs index 20c1b1f6..19fc184c 100644 --- a/juniper_codegen/src/common/field/arg.rs +++ b/juniper_codegen/src/common/field/arg.rs @@ -374,11 +374,11 @@ impl OnMethod { // Remove repeated attributes from the method, to omit incorrect expansion. argument.attrs = mem::take(&mut argument.attrs) .into_iter() - .filter(|attr| !path_eq_single(&attr.path, "graphql")) + .filter(|attr| !path_eq_single(attr.path(), "graphql")) .collect(); let attr = Attr::from_attrs("graphql", &orig_attrs) - .map_err(|e| proc_macro_error::emit_error!(e)) + .map_err(diagnostic::emit_error) .ok()?; if attr.context.is_some() { @@ -397,7 +397,7 @@ impl OnMethod { }; if arg.is_some() { attr.ensure_no_regular_arguments() - .map_err(|e| scope.error(e).emit()) + .map_err(|e| scope.error(&e).emit()) .ok()?; return arg; } diff --git a/juniper_codegen/src/common/mod.rs b/juniper_codegen/src/common/mod.rs index e6e3dd8f..2277dcd5 100644 --- a/juniper_codegen/src/common/mod.rs +++ b/juniper_codegen/src/common/mod.rs @@ -27,5 +27,5 @@ pub(crate) fn filter_attrs<'a>( ) -> impl Iterator + 'a { attrs .iter() - .filter(move |attr| path_eq_single(&attr.path, name)) + .filter(move |attr| path_eq_single(attr.path(), name)) } diff --git a/juniper_codegen/src/common/parse/attr.rs b/juniper_codegen/src/common/parse/attr.rs index 8b3eceec..edb7b8c1 100644 --- a/juniper_codegen/src/common/parse/attr.rs +++ b/juniper_codegen/src/common/parse/attr.rs @@ -28,7 +28,7 @@ pub(crate) fn unite( pub(crate) fn strip(attr_path: &str, attrs: Vec) -> Vec { attrs .into_iter() - .filter(|attr| !path_eq_single(&attr.path, attr_path)) + .filter(|attr| !path_eq_single(attr.path(), attr_path)) .collect() } diff --git a/juniper_codegen/src/common/parse/downcaster.rs b/juniper_codegen/src/common/parse/downcaster.rs index 8c63de21..4a951d92 100644 --- a/juniper_codegen/src/common/parse/downcaster.rs +++ b/juniper_codegen/src/common/parse/downcaster.rs @@ -65,7 +65,7 @@ pub(crate) fn output_type(ret_ty: &syn::ReturnType) -> Result { /// If input arguments are invalid, then returns the [`Span`] to display the corresponding error at. pub(crate) fn context_ty(sig: &syn::Signature) -> Result, Span> { match sig.receiver() { - Some(syn::FnArg::Receiver(rcv)) => { + Some(rcv) => { if rcv.reference.is_none() || rcv.mutability.is_some() { return Err(rcv.span()); } diff --git a/juniper_codegen/src/common/parse/mod.rs b/juniper_codegen/src/common/parse/mod.rs index dc3e89e8..304ec4c5 100644 --- a/juniper_codegen/src/common/parse/mod.rs +++ b/juniper_codegen/src/common/parse/mod.rs @@ -146,8 +146,13 @@ impl TypeExt for syn::Type { match arg { GA::Lifetime(lt) => func(lt), GA::Type(ty) => ty.lifetimes_iter_mut(func), - GA::Binding(b) => b.ty.lifetimes_iter_mut(func), - GA::Constraint(_) | GA::Const(_) => {} + GA::AssocType(a) => a.ty.lifetimes_iter_mut(func), + GA::Constraint(_) | GA::AssocConst(_) | GA::Const(_) => {} + // Following the `syn` idiom for exhaustive matching on `Type`: + // https://docs.rs/syn/2.0.38/src/syn/ty.rs.html#64-79 + // TODO: #[cfg_attr(test, deny(non_exhaustive_omitted_patterns))] + // https://github.com/rust-lang/rust/issues/89554 + _ => unimplemented!(), } } } @@ -188,6 +193,12 @@ impl TypeExt for syn::Type { } iter_path(&mut bound.path, func) } + syn::TypeParamBound::Verbatim(_) => {} + // Following the `syn` idiom for exhaustive matching on `Type`: + // https://docs.rs/syn/2.0.38/src/syn/ty.rs.html#64-79 + // TODO: #[cfg_attr(test, deny(non_exhaustive_omitted_patterns))] + // https://github.com/rust-lang/rust/issues/89554 + _ => unimplemented!(), } } } @@ -204,8 +215,8 @@ impl TypeExt for syn::Type { // These types unlikely will be used as GraphQL types. T::BareFn(_) | T::Infer(_) | T::Macro(_) | T::Never(_) | T::Verbatim(_) => {} - // Following the syn idiom for exhaustive matching on Type: - // https://github.com/dtolnay/syn/blob/1.0.90/src/ty.rs#L67-L87 + // Following the `syn` idiom for exhaustive matching on `Type`: + // https://docs.rs/syn/2.0.38/src/syn/ty.rs.html#64-79 // TODO: #[cfg_attr(test, deny(non_exhaustive_omitted_patterns))] // https://github.com/rust-lang/rust/issues/89554 _ => unimplemented!(), diff --git a/juniper_codegen/src/common/scalar.rs b/juniper_codegen/src/common/scalar.rs index 8f11833d..4622a96a 100644 --- a/juniper_codegen/src/common/scalar.rs +++ b/juniper_codegen/src/common/scalar.rs @@ -3,7 +3,7 @@ //! //! [`ScalarValue`]: juniper::ScalarValue -use proc_macro2::{Span, TokenStream}; +use proc_macro2::TokenStream; use quote::ToTokens; use syn::{ parse::{Parse, ParseStream}, @@ -44,11 +44,11 @@ impl Parse for AttrValue { } } -impl Spanned for AttrValue { - fn span(&self) -> Span { +impl ToTokens for AttrValue { + fn to_tokens(&self, into: &mut TokenStream) { match self { - Self::Concrete(ty) => ty.span(), - Self::Generic(pred) => pred.span(), + Self::Concrete(ty) => ty.to_tokens(into), + Self::Generic(pred) => pred.to_tokens(into), } } } diff --git a/juniper_codegen/src/graphql_enum/derive.rs b/juniper_codegen/src/graphql_enum/derive.rs index f0564a26..01e4bfb0 100644 --- a/juniper_codegen/src/graphql_enum/derive.rs +++ b/juniper_codegen/src/graphql_enum/derive.rs @@ -40,7 +40,7 @@ pub(crate) fn expand(input: TokenStream) -> syn::Result { }) .collect::>(); - proc_macro_error::abort_if_dirty(); + diagnostic::abort_if_dirty(); if values.is_empty() { return Err(ERR.custom_error( @@ -78,7 +78,7 @@ pub(crate) fn expand(input: TokenStream) -> syn::Result { let scalar = scalar::Type::parse(attr.scalar.as_deref(), &ast.generics); - proc_macro_error::abort_if_dirty(); + diagnostic::abort_if_dirty(); let definition = Definition { ident: ast.ident, @@ -99,7 +99,7 @@ pub(crate) fn expand(input: TokenStream) -> syn::Result { /// Returns [`None`] if the parsing fails, or the enum variant is ignored. fn parse_value(v: &syn::Variant, renaming: rename::Policy) -> Option { let attr = VariantAttr::from_attrs("graphql", &v.attrs) - .map_err(|e| proc_macro_error::emit_error!(e)) + .map_err(diagnostic::emit_error) .ok()?; if attr.ignore.is_some() { diff --git a/juniper_codegen/src/graphql_input_object/derive.rs b/juniper_codegen/src/graphql_input_object/derive.rs index 370fc200..e5ac314c 100644 --- a/juniper_codegen/src/graphql_input_object/derive.rs +++ b/juniper_codegen/src/graphql_input_object/derive.rs @@ -36,7 +36,7 @@ pub fn expand(input: TokenStream) -> syn::Result { .filter_map(|f| parse_field(f, renaming, is_internal)) .collect::>(); - proc_macro_error::abort_if_dirty(); + diagnostic::abort_if_dirty(); if !fields.iter().any(|f| !f.ignored) { return Err(ERR.custom_error(data.fields.span(), "expected at least 1 non-ignored field")); @@ -71,7 +71,7 @@ pub fn expand(input: TokenStream) -> syn::Result { let scalar = scalar::Type::parse(attr.scalar.as_deref(), &ast.generics); - proc_macro_error::abort_if_dirty(); + diagnostic::abort_if_dirty(); let definition = Definition { ident: ast.ident, @@ -95,7 +95,7 @@ fn parse_field( is_internal: bool, ) -> Option { let field_attr = FieldAttr::from_attrs("graphql", &f.attrs) - .map_err(|e| proc_macro_error::emit_error!(e)) + .map_err(diagnostic::emit_error) .ok()?; let ident = f.ident.as_ref().or_else(|| err_unnamed_field(f))?; diff --git a/juniper_codegen/src/graphql_interface/attr.rs b/juniper_codegen/src/graphql_interface/attr.rs index 634a1419..cf8cef01 100644 --- a/juniper_codegen/src/graphql_interface/attr.rs +++ b/juniper_codegen/src/graphql_interface/attr.rs @@ -64,7 +64,7 @@ fn expand_on_trait( let scalar = scalar::Type::parse(attr.scalar.as_deref(), &ast.generics); - proc_macro_error::abort_if_dirty(); + diagnostic::abort_if_dirty(); let renaming = attr .rename_fields @@ -76,14 +76,14 @@ fn expand_on_trait( .items .iter_mut() .filter_map(|item| { - if let syn::TraitItem::Method(m) = item { + if let syn::TraitItem::Fn(m) = item { return parse_trait_method(m, &renaming); } None }) .collect::>(); - proc_macro_error::abort_if_dirty(); + diagnostic::abort_if_dirty(); if fields.is_empty() { ERR.emit_custom(trait_span, "must have at least one field"); @@ -92,7 +92,7 @@ fn expand_on_trait( ERR.emit_custom(trait_span, "must have a different name for each field"); } - proc_macro_error::abort_if_dirty(); + diagnostic::abort_if_dirty(); let context = attr .context @@ -146,7 +146,7 @@ fn expand_on_trait( /// Returns [`None`] if the parsing fails, or the method field is ignored. #[must_use] fn parse_trait_method( - method: &mut syn::TraitItemMethod, + method: &mut syn::TraitItemFn, renaming: &rename::Policy, ) -> Option { let method_ident = &method.sig.ident; @@ -155,11 +155,11 @@ fn parse_trait_method( // Remove repeated attributes from the method, to omit incorrect expansion. method.attrs = mem::take(&mut method.attrs) .into_iter() - .filter(|attr| !path_eq_single(&attr.path, "graphql")) + .filter(|attr| !path_eq_single(attr.path(), "graphql")) .collect(); let attr = field::Attr::from_attrs("graphql", &method_attrs) - .map_err(|e| proc_macro_error::emit_error!(e)) + .map_err(diagnostic::emit_error) .ok()?; if attr.ignore.is_some() { @@ -251,7 +251,7 @@ fn expand_on_derive_input( let scalar = scalar::Type::parse(attr.scalar.as_deref(), &ast.generics); - proc_macro_error::abort_if_dirty(); + diagnostic::abort_if_dirty(); let renaming = attr .rename_fields @@ -265,7 +265,7 @@ fn expand_on_derive_input( .filter_map(|f| parse_struct_field(f, &renaming)) .collect::>(); - proc_macro_error::abort_if_dirty(); + diagnostic::abort_if_dirty(); if fields.is_empty() { ERR.emit_custom(struct_span, "must have at least one field"); @@ -274,7 +274,7 @@ fn expand_on_derive_input( ERR.emit_custom(struct_span, "must have a different name for each field"); } - proc_macro_error::abort_if_dirty(); + diagnostic::abort_if_dirty(); let context = attr .context @@ -337,11 +337,11 @@ fn parse_struct_field( // Remove repeated attributes from the method, to omit incorrect expansion. field.attrs = mem::take(&mut field.attrs) .into_iter() - .filter(|attr| !path_eq_single(&attr.path, "graphql")) + .filter(|attr| !path_eq_single(attr.path(), "graphql")) .collect(); let attr = field::Attr::from_attrs("graphql", &field_attrs) - .map_err(|e| proc_macro_error::emit_error!(e)) + .map_err(diagnostic::emit_error) .ok()?; if attr.ignore.is_some() { diff --git a/juniper_codegen/src/graphql_interface/derive.rs b/juniper_codegen/src/graphql_interface/derive.rs index 25bc096b..1ba757e6 100644 --- a/juniper_codegen/src/graphql_interface/derive.rs +++ b/juniper_codegen/src/graphql_interface/derive.rs @@ -42,7 +42,7 @@ pub fn expand(input: TokenStream) -> syn::Result { let scalar = scalar::Type::parse(attr.scalar.as_deref(), &ast.generics); - proc_macro_error::abort_if_dirty(); + diagnostic::abort_if_dirty(); let renaming = attr .rename_fields @@ -56,7 +56,7 @@ pub fn expand(input: TokenStream) -> syn::Result { .filter_map(|f| parse_field(f, &renaming)) .collect::>(); - proc_macro_error::abort_if_dirty(); + diagnostic::abort_if_dirty(); if fields.is_empty() { ERR.emit_custom(struct_span, "must have at least one field"); @@ -65,7 +65,7 @@ pub fn expand(input: TokenStream) -> syn::Result { ERR.emit_custom(struct_span, "must have a different name for each field"); } - proc_macro_error::abort_if_dirty(); + diagnostic::abort_if_dirty(); let context = attr .context @@ -118,7 +118,7 @@ fn parse_field(field: &syn::Field, renaming: &rename::Policy) -> Option Option { @@ -146,11 +146,11 @@ fn parse_field( // Remove repeated attributes from the method, to omit incorrect expansion. method.attrs = mem::take(&mut method.attrs) .into_iter() - .filter(|attr| !path_eq_single(&attr.path, "graphql")) + .filter(|attr| !path_eq_single(attr.path(), "graphql")) .collect(); let attr = field::Attr::from_attrs("graphql", &method_attrs) - .map_err(|e| proc_macro_error::emit_error!(e)) + .map_err(diagnostic::emit_error) .ok()?; if attr.ignore.is_some() { @@ -239,7 +239,7 @@ fn err_invalid_method_receiver(span: &S) -> Option { #[must_use] fn err_no_sync_resolvers(span: &S) -> Option { ERR.custom(span.span(), "synchronous resolvers are not supported") - .note("Specify that this function is async: `async fn foo()`".into()) + .note("Specify that this function is async: `async fn foo()`") .emit(); None } diff --git a/juniper_codegen/src/graphql_object/derive.rs b/juniper_codegen/src/graphql_object/derive.rs index 189ed261..bc378b73 100644 --- a/juniper_codegen/src/graphql_object/derive.rs +++ b/juniper_codegen/src/graphql_object/derive.rs @@ -3,11 +3,15 @@ use std::marker::PhantomData; use proc_macro2::TokenStream; -use proc_macro_error::ResultExt as _; use quote::ToTokens; use syn::{ext::IdentExt as _, parse_quote, spanned::Spanned as _}; -use crate::common::{diagnostic, field, parse::TypeExt as _, rename, scalar, SpanContainer}; +use crate::common::{ + diagnostic::{self, ResultExt as _}, + field, + parse::TypeExt as _, + rename, scalar, SpanContainer, +}; use super::{Attr, Definition, Query}; @@ -52,7 +56,7 @@ fn expand_struct(ast: syn::DeriveInput) -> syn::Result> { let scalar = scalar::Type::parse(attr.scalar.as_deref(), &ast.generics); - proc_macro_error::abort_if_dirty(); + diagnostic::abort_if_dirty(); let renaming = attr .rename_fields @@ -73,7 +77,7 @@ fn expand_struct(ast: syn::DeriveInput) -> syn::Result> { } } - proc_macro_error::abort_if_dirty(); + diagnostic::abort_if_dirty(); if fields.is_empty() { ERR.emit_custom(struct_span, "must have at least one field"); @@ -82,7 +86,7 @@ fn expand_struct(ast: syn::DeriveInput) -> syn::Result> { ERR.emit_custom(struct_span, "must have a different name for each field"); } - proc_macro_error::abort_if_dirty(); + diagnostic::abort_if_dirty(); Ok(Definition { name, @@ -110,7 +114,7 @@ fn expand_struct(ast: syn::DeriveInput) -> syn::Result> { #[must_use] fn parse_field(field: &syn::Field, renaming: &rename::Policy) -> Option { let attr = field::Attr::from_attrs("graphql", &field.attrs) - .map_err(|e| proc_macro_error::emit_error!(e)) + .map_err(diagnostic::emit_error) .ok()?; if attr.ignore.is_some() { diff --git a/juniper_codegen/src/graphql_scalar/mod.rs b/juniper_codegen/src/graphql_scalar/mod.rs index d6af3016..2da7df5c 100644 --- a/juniper_codegen/src/graphql_scalar/mod.rs +++ b/juniper_codegen/src/graphql_scalar/mod.rs @@ -160,8 +160,7 @@ impl Parse for Attr { "parse_token" => { let types; let _ = syn::parenthesized!(types in input); - let parsed_types = - types.parse_terminated::<_, token::Comma>(syn::Type::parse)?; + let parsed_types = types.parse_terminated(syn::Type::parse, token::Comma)?; if parsed_types.is_empty() { return Err(syn::Error::new(ident.span(), "expected at least 1 type.")); @@ -187,7 +186,7 @@ impl Parse for Attr { let predicates; let _ = syn::parenthesized!(predicates in input); let parsed_predicates = predicates - .parse_terminated::<_, token::Comma>(syn::WherePredicate::parse)?; + .parse_terminated(syn::WherePredicate::parse, token::Comma)?; if parsed_predicates.is_empty() { return Err(syn::Error::new( diff --git a/juniper_codegen/src/graphql_union/attr.rs b/juniper_codegen/src/graphql_union/attr.rs index bd7067e3..4e4b4dcb 100644 --- a/juniper_codegen/src/graphql_union/attr.rs +++ b/juniper_codegen/src/graphql_union/attr.rs @@ -58,12 +58,12 @@ fn expand_on_trait( .items .iter_mut() .filter_map(|i| match i { - syn::TraitItem::Method(m) => parse_variant_from_trait_method(m, trait_ident, &attr), + syn::TraitItem::Fn(m) => parse_variant_from_trait_method(m, trait_ident, &attr), _ => None, }) .collect(); - proc_macro_error::abort_if_dirty(); + diagnostic::abort_if_dirty(); emerge_union_variants_from_attr(&mut variants, attr.external_resolvers); @@ -78,7 +78,7 @@ fn expand_on_trait( ); } - proc_macro_error::abort_if_dirty(); + diagnostic::abort_if_dirty(); let context = attr .context @@ -105,12 +105,12 @@ fn expand_on_trait( /// Parses given Rust trait `method` as [GraphQL union][1] variant. /// -/// On failure returns [`None`] and internally fills up [`proc_macro_error`] +/// On failure returns [`None`] and internally fills up [`diagnostic`] /// with the corresponding errors. /// /// [1]: https://spec.graphql.org/October2021#sec-Unions fn parse_variant_from_trait_method( - method: &mut syn::TraitItemMethod, + method: &mut syn::TraitItemFn, trait_ident: &syn::Ident, trait_attr: &Attr, ) -> Option { @@ -119,11 +119,11 @@ fn parse_variant_from_trait_method( // Remove repeated attributes from the method, to omit incorrect expansion. method.attrs = mem::take(&mut method.attrs) .into_iter() - .filter(|attr| !path_eq_single(&attr.path, "graphql")) + .filter(|attr| !path_eq_single(attr.path(), "graphql")) .collect(); let attr = VariantAttr::from_attrs("graphql", &method_attrs) - .map_err(|e| proc_macro_error::emit_error!(e)) + .map_err(diagnostic::emit_error) .ok()?; if let Some(rslvr) = attr.external_resolver { diff --git a/juniper_codegen/src/graphql_union/derive.rs b/juniper_codegen/src/graphql_union/derive.rs index 44f045e3..0a863bb4 100644 --- a/juniper_codegen/src/graphql_union/derive.rs +++ b/juniper_codegen/src/graphql_union/derive.rs @@ -1,11 +1,14 @@ //! Code generation for `#[derive(GraphQLUnion)]` macro. use proc_macro2::TokenStream; -use proc_macro_error::ResultExt as _; use quote::{quote, ToTokens}; use syn::{ext::IdentExt as _, parse_quote, spanned::Spanned as _, Data, Fields}; -use crate::common::{diagnostic, parse::TypeExt as _, scalar, SpanContainer}; +use crate::common::{ + diagnostic::{self, ResultExt as _}, + parse::TypeExt as _, + scalar, SpanContainer, +}; use super::{ all_variants_different, emerge_union_variants_from_attr, Attr, Definition, VariantAttr, @@ -51,13 +54,13 @@ fn expand_enum(ast: syn::DeriveInput) -> syn::Result { let mut variants: Vec<_> = match ast.data { Data::Enum(data) => data.variants, - _ => unreachable!(), + data => unreachable!("graphql_union::derive::expand_enum({data:?})"), } .into_iter() .filter_map(|var| parse_variant_from_enum_variant(var, &enum_ident, &attr)) .collect(); - proc_macro_error::abort_if_dirty(); + diagnostic::abort_if_dirty(); emerge_union_variants_from_attr(&mut variants, attr.external_resolvers); @@ -72,7 +75,7 @@ fn expand_enum(ast: syn::DeriveInput) -> syn::Result { ); } - proc_macro_error::abort_if_dirty(); + diagnostic::abort_if_dirty(); Ok(Definition { name, @@ -91,7 +94,7 @@ fn expand_enum(ast: syn::DeriveInput) -> syn::Result { /// Parses given Rust enum `var`iant as [GraphQL union][1] variant. /// -/// On failure returns [`None`] and internally fills up [`proc_macro_error`] +/// On failure returns [`None`] and internally fills up [`diagnostic`] /// with the corresponding errors. /// /// [1]: https://spec.graphql.org/October2021#sec-Unions @@ -101,7 +104,7 @@ fn parse_variant_from_enum_variant( enum_attr: &Attr, ) -> Option { let attr = VariantAttr::from_attrs("graphql", &var.attrs) - .map_err(|e| proc_macro_error::emit_error!(e)) + .map_err(diagnostic::emit_error) .ok()?; if attr.ignore.is_some() { return None; @@ -205,7 +208,7 @@ fn expand_struct(ast: syn::DeriveInput) -> syn::Result { ); } - proc_macro_error::abort_if_dirty(); + diagnostic::abort_if_dirty(); Ok(Definition { name, diff --git a/juniper_codegen/src/lib.rs b/juniper_codegen/src/lib.rs index d88488c3..f35dff37 100644 --- a/juniper_codegen/src/lib.rs +++ b/juniper_codegen/src/lib.rs @@ -108,7 +108,8 @@ mod graphql_union; mod scalar_value; use proc_macro::TokenStream; -use proc_macro_error::{proc_macro_error, ResultExt as _}; + +use self::common::diagnostic::{self, ResultExt as _}; /// `#[derive(GraphQLInputObject)]` macro for deriving a /// [GraphQL input object][0] implementation for a Rust struct. Each @@ -213,12 +214,13 @@ use proc_macro_error::{proc_macro_error, ResultExt as _}; /// [0]: https://spec.graphql.org/October2021#sec-Input-Objects /// [1]: https://spec.graphql.org/October2021#InputFieldsDefinition /// [2]: https://spec.graphql.org/October2021#sec-Scalars -#[proc_macro_error] #[proc_macro_derive(GraphQLInputObject, attributes(graphql))] pub fn derive_input_object(input: TokenStream) -> TokenStream { - graphql_input_object::derive::expand(input.into()) - .unwrap_or_abort() - .into() + diagnostic::entry_point(|| { + graphql_input_object::derive::expand(input.into()) + .unwrap_or_abort() + .into() + }) } /// `#[derive(GraphQLEnum)]` macro for deriving a [GraphQL enum][0] @@ -342,12 +344,13 @@ pub fn derive_input_object(input: TokenStream) -> TokenStream { /// [`ScalarValue`]: juniper::ScalarValue /// [0]: https://spec.graphql.org/October2021#sec-Enums /// [1]: https://spec.graphql.org/October2021#sec-Enum-Value -#[proc_macro_error] #[proc_macro_derive(GraphQLEnum, attributes(graphql))] pub fn derive_enum(input: TokenStream) -> TokenStream { - graphql_enum::derive::expand(input.into()) - .unwrap_or_abort() - .into() + diagnostic::entry_point(|| { + graphql_enum::derive::expand(input.into()) + .unwrap_or_abort() + .into() + }) } /// `#[derive(GraphQLScalar)]` macro for deriving a [GraphQL scalar][0] @@ -654,12 +657,13 @@ pub fn derive_enum(input: TokenStream) -> TokenStream { /// [0]: https://spec.graphql.org/October2021#sec-Scalars /// [1]: https://rust-unofficial.github.io/patterns/patterns/behavioural/newtype.html /// [`ScalarValue`]: juniper::ScalarValue -#[proc_macro_error] #[proc_macro_derive(GraphQLScalar, attributes(graphql))] pub fn derive_scalar(input: TokenStream) -> TokenStream { - graphql_scalar::derive::expand(input.into()) - .unwrap_or_abort() - .into() + diagnostic::entry_point(|| { + graphql_scalar::derive::expand(input.into()) + .unwrap_or_abort() + .into() + }) } /// `#[graphql_scalar]` macro.is interchangeable with @@ -748,12 +752,13 @@ pub fn derive_scalar(input: TokenStream) -> TokenStream { /// [orphan rules]: https://bit.ly/3glAGC2 /// [`GraphQLScalar`]: juniper::GraphQLScalar /// [`ScalarValue`]: juniper::ScalarValue -#[proc_macro_error] #[proc_macro_attribute] pub fn graphql_scalar(attr: TokenStream, body: TokenStream) -> TokenStream { - graphql_scalar::attr::expand(attr.into(), body.into()) - .unwrap_or_abort() - .into() + diagnostic::entry_point(|| { + graphql_scalar::attr::expand(attr.into(), body.into()) + .unwrap_or_abort() + .into() + }) } /// `#[derive(ScalarValue)]` macro for deriving a [`ScalarValue`] @@ -856,12 +861,13 @@ pub fn graphql_scalar(attr: TokenStream, body: TokenStream) -> TokenStream { /// ``` /// /// [`ScalarValue`]: juniper::ScalarValue -#[proc_macro_error] #[proc_macro_derive(ScalarValue, attributes(value))] pub fn derive_scalar_value(input: TokenStream) -> TokenStream { - scalar_value::expand_derive(input.into()) - .unwrap_or_abort() - .into() + diagnostic::entry_point(|| { + scalar_value::expand_derive(input.into()) + .unwrap_or_abort() + .into() + }) } /// `#[graphql_interface]` macro for generating a [GraphQL interface][1] @@ -1289,12 +1295,13 @@ pub fn derive_scalar_value(input: TokenStream) -> TokenStream { /// [2]: https://doc.rust-lang.org/stable/reference/items/traits.html#object-safety /// [3]: https://doc.rust-lang.org/stable/reference/types/trait-object.html /// [4]: https://doc.rust-lang.org/stable/std/primitive.unit.html -#[proc_macro_error] #[proc_macro_attribute] pub fn graphql_interface(attr: TokenStream, body: TokenStream) -> TokenStream { - self::graphql_interface::attr::expand(attr.into(), body.into()) - .unwrap_or_abort() - .into() + diagnostic::entry_point(|| { + self::graphql_interface::attr::expand(attr.into(), body.into()) + .unwrap_or_abort() + .into() + }) } /// `#[derive(GraphQLInterface)]` macro for generating a [GraphQL interface][1] @@ -1326,12 +1333,13 @@ pub fn graphql_interface(attr: TokenStream, body: TokenStream) -> TokenStream { /// /// [`#[graphql_interface]`]: crate::graphql_interface /// [1]: https://spec.graphql.org/October2021#sec-Interfaces -#[proc_macro_error] #[proc_macro_derive(GraphQLInterface, attributes(graphql))] pub fn derive_interface(body: TokenStream) -> TokenStream { - self::graphql_interface::derive::expand(body.into()) - .unwrap_or_abort() - .into() + diagnostic::entry_point(|| { + self::graphql_interface::derive::expand(body.into()) + .unwrap_or_abort() + .into() + }) } /// `#[derive(GraphQLObject)]` macro for deriving a [GraphQL object][1] @@ -1463,12 +1471,13 @@ pub fn derive_interface(body: TokenStream) -> TokenStream { /// /// [`ScalarValue`]: juniper::ScalarValue /// [1]: https://spec.graphql.org/October2021#sec-Objects -#[proc_macro_error] #[proc_macro_derive(GraphQLObject, attributes(graphql))] pub fn derive_object(body: TokenStream) -> TokenStream { - self::graphql_object::derive::expand(body.into()) - .unwrap_or_abort() - .into() + diagnostic::entry_point(|| { + self::graphql_object::derive::expand(body.into()) + .unwrap_or_abort() + .into() + }) } /// `#[graphql_object]` macro for generating a [GraphQL object][1] @@ -1788,12 +1797,13 @@ pub fn derive_object(body: TokenStream) -> TokenStream { /// [`ScalarValue`]: juniper::ScalarValue /// [0]: https://spec.graphql.org/October2021 /// [1]: https://spec.graphql.org/October2021#sec-Objects -#[proc_macro_error] #[proc_macro_attribute] pub fn graphql_object(attr: TokenStream, body: TokenStream) -> TokenStream { - self::graphql_object::attr::expand(attr.into(), body.into()) - .unwrap_or_abort() - .into() + diagnostic::entry_point(|| { + self::graphql_object::attr::expand(attr.into(), body.into()) + .unwrap_or_abort() + .into() + }) } /// `#[graphql_subscription]` macro for generating a [GraphQL subscription][1] @@ -1841,12 +1851,13 @@ pub fn graphql_object(attr: TokenStream, body: TokenStream) -> TokenStream { /// [`GraphQLSubscriptionValue`]: juniper::GraphQLSubscriptionValue /// [`Stream`]: futures::Stream /// [1]: https://spec.graphql.org/October2021#sec-Subscription -#[proc_macro_error] #[proc_macro_attribute] pub fn graphql_subscription(attr: TokenStream, body: TokenStream) -> TokenStream { - self::graphql_subscription::attr::expand(attr.into(), body.into()) - .unwrap_or_abort() - .into() + diagnostic::entry_point(|| { + self::graphql_subscription::attr::expand(attr.into(), body.into()) + .unwrap_or_abort() + .into() + }) } /// `#[derive(GraphQLUnion)]` macro for deriving a [GraphQL union][1] implementation for enums and @@ -2149,12 +2160,13 @@ pub fn graphql_subscription(attr: TokenStream, body: TokenStream) -> TokenStream /// [`ScalarValue`]: juniper::ScalarValue /// [1]: https://spec.graphql.org/October2021#sec-Unions /// [4]: https://doc.rust-lang.org/stable/std/primitive.unit.html -#[proc_macro_error] #[proc_macro_derive(GraphQLUnion, attributes(graphql))] pub fn derive_union(body: TokenStream) -> TokenStream { - self::graphql_union::derive::expand(body.into()) - .unwrap_or_abort() - .into() + diagnostic::entry_point(|| { + self::graphql_union::derive::expand(body.into()) + .unwrap_or_abort() + .into() + }) } /// `#[graphql_union]` macro for deriving a [GraphQL union][1] implementation for traits. @@ -2441,10 +2453,11 @@ pub fn derive_union(body: TokenStream) -> TokenStream { /// [2]: https://doc.rust-lang.org/stable/reference/items/traits.html#object-safety /// [3]: https://doc.rust-lang.org/stable/reference/types/trait-object.html /// [4]: https://doc.rust-lang.org/stable/std/primitive.unit.html -#[proc_macro_error] #[proc_macro_attribute] pub fn graphql_union(attr: TokenStream, body: TokenStream) -> TokenStream { - self::graphql_union::attr::expand(attr.into(), body.into()) - .unwrap_or_abort() - .into() + diagnostic::entry_point(|| { + self::graphql_union::attr::expand(attr.into(), body.into()) + .unwrap_or_abort() + .into() + }) } diff --git a/juniper_graphql_ws/Cargo.toml b/juniper_graphql_ws/Cargo.toml index 385e9512..ee5cabba 100644 --- a/juniper_graphql_ws/Cargo.toml +++ b/juniper_graphql_ws/Cargo.toml @@ -2,7 +2,7 @@ name = "juniper_graphql_ws" version = "0.4.0-dev" edition = "2021" -rust-version = "1.65" +rust-version = "1.73" description = "GraphQL over WebSocket Protocol implementations for `juniper` crate." license = "BSD-2-Clause" authors = [ diff --git a/juniper_graphql_ws/README.md b/juniper_graphql_ws/README.md index 5710b8cf..c4231b3c 100644 --- a/juniper_graphql_ws/README.md +++ b/juniper_graphql_ws/README.md @@ -4,7 +4,7 @@ [![Crates.io](https://img.shields.io/crates/v/juniper_graphql_ws.svg?maxAge=2592000)](https://crates.io/crates/juniper_graphql_ws) [![Documentation](https://docs.rs/juniper_graphql_ws/badge.svg)](https://docs.rs/juniper_graphql_ws) [![CI](https://github.com/graphql-rust/juniper/workflows/CI/badge.svg?branch=master "CI")](https://github.com/graphql-rust/juniper/actions?query=workflow%3ACI+branch%3Amaster) -[![Rust 1.65+](https://img.shields.io/badge/rustc-1.65+-lightgray.svg "Rust 1.65+")](https://blog.rust-lang.org/2022/11/03/Rust-1.65.0.html) +[![Rust 1.73+](https://img.shields.io/badge/rustc-1.73+-lightgray.svg "Rust 1.73+")](https://blog.rust-lang.org/2023/10/05/Rust-1.73.0.html) - [Changelog](https://github.com/graphql-rust/juniper/blob/master/juniper_graphql_ws/CHANGELOG.md) diff --git a/juniper_hyper/Cargo.toml b/juniper_hyper/Cargo.toml index 5a7dfc7a..60effdcf 100644 --- a/juniper_hyper/Cargo.toml +++ b/juniper_hyper/Cargo.toml @@ -2,7 +2,7 @@ name = "juniper_hyper" version = "0.9.0-dev" edition = "2021" -rust-version = "1.65" +rust-version = "1.73" description = "`juniper` GraphQL integration with `hyper`." license = "BSD-2-Clause" authors = ["Damir Vandic "] @@ -22,7 +22,7 @@ serde_json = "1.0.18" tokio = "1.0" url = "2.0" -# Fixes for MSRV check. +# Fixes for `minimal-versions` check. # TODO: Try remove on upgrade of `hyper` crate. http-body = "0.4.5" diff --git a/juniper_hyper/README.md b/juniper_hyper/README.md index 38e73a47..bbe8fcc8 100644 --- a/juniper_hyper/README.md +++ b/juniper_hyper/README.md @@ -4,7 +4,7 @@ [![Crates.io](https://img.shields.io/crates/v/juniper_hyper.svg?maxAge=2592000)](https://crates.io/crates/juniper_hyper) [![Documentation](https://docs.rs/juniper_hyper/badge.svg)](https://docs.rs/juniper_hyper) [![CI](https://github.com/graphql-rust/juniper/workflows/CI/badge.svg?branch=master "CI")](https://github.com/graphql-rust/juniper/actions?query=workflow%3ACI+branch%3Amaster) -[![Rust 1.65+](https://img.shields.io/badge/rustc-1.65+-lightgray.svg "Rust 1.65+")](https://blog.rust-lang.org/2022/11/03/Rust-1.65.0.html) +[![Rust 1.73+](https://img.shields.io/badge/rustc-1.73+-lightgray.svg "Rust 1.73+")](https://blog.rust-lang.org/2023/10/05/Rust-1.73.0.html) - [Changelog](https://github.com/graphql-rust/juniper/blob/master/juniper_hyper/CHANGELOG.md) diff --git a/juniper_iron/Cargo.toml b/juniper_iron/Cargo.toml index 1676d947..5e1877e1 100644 --- a/juniper_iron/Cargo.toml +++ b/juniper_iron/Cargo.toml @@ -2,7 +2,7 @@ name = "juniper_iron" version = "0.8.0-dev" edition = "2021" -rust-version = "1.65" +rust-version = "1.73" description = "`juniper` GraphQL integration with `iron`." license = "BSD-2-Clause" authors = [ diff --git a/juniper_iron/README.md b/juniper_iron/README.md index 51fa29b6..4d964ef0 100644 --- a/juniper_iron/README.md +++ b/juniper_iron/README.md @@ -4,7 +4,7 @@ [![Crates.io](https://img.shields.io/crates/v/juniper_iron.svg?maxAge=2592000)](https://crates.io/crates/juniper_iron) [![Documentation](https://docs.rs/juniper_iron/badge.svg)](https://docs.rs/juniper_iron) [![CI](https://github.com/graphql-rust/juniper/workflows/CI/badge.svg?branch=master "CI")](https://github.com/graphql-rust/juniper/actions?query=workflow%3ACI+branch%3Amaster) -[![Rust 1.65+](https://img.shields.io/badge/rustc-1.65+-lightgray.svg "Rust 1.65+")](https://blog.rust-lang.org/2022/11/03/Rust-1.65.0.html) +[![Rust 1.73+](https://img.shields.io/badge/rustc-1.73+-lightgray.svg "Rust 1.73+")](https://blog.rust-lang.org/2023/10/05/Rust-1.73.0.html) - [Changelog](https://github.com/graphql-rust/juniper/blob/master/juniper_iron/CHANGELOG.md) diff --git a/juniper_rocket/Cargo.toml b/juniper_rocket/Cargo.toml index f270be01..8ca4a31e 100644 --- a/juniper_rocket/Cargo.toml +++ b/juniper_rocket/Cargo.toml @@ -2,7 +2,7 @@ name = "juniper_rocket" version = "0.9.0-dev" edition = "2021" -rust-version = "1.65" +rust-version = "1.73" description = "`juniper` GraphQL integration with `rocket`." license = "BSD-2-Clause" authors = [ @@ -23,7 +23,7 @@ juniper = { version = "0.16.0-dev", path = "../juniper", default-features = fals rocket = { version = "=0.5.0-rc.3", default-features = false } serde_json = "1.0.18" -# Fixes for MSRV check. +# Fixes for `minimal-versions` check. # TODO: Try remove on upgrade of `rocket` crate. either = "1.8" inlinable_string = "0.1.15" diff --git a/juniper_rocket/README.md b/juniper_rocket/README.md index 929d9314..806baf24 100644 --- a/juniper_rocket/README.md +++ b/juniper_rocket/README.md @@ -4,7 +4,7 @@ [![Crates.io](https://img.shields.io/crates/v/juniper_rocket.svg?maxAge=2592000)](https://crates.io/crates/juniper_rocket) [![Documentation](https://docs.rs/juniper_rocket/badge.svg)](https://docs.rs/juniper_rocket) [![CI](https://github.com/graphql-rust/juniper/workflows/CI/badge.svg?branch=master "CI")](https://github.com/graphql-rust/juniper/actions?query=workflow%3ACI+branch%3Amaster) -[![Rust 1.65+](https://img.shields.io/badge/rustc-1.65+-lightgray.svg "Rust 1.65+")](https://blog.rust-lang.org/2022/11/03/Rust-1.65.0.html) +[![Rust 1.73+](https://img.shields.io/badge/rustc-1.73+-lightgray.svg "Rust 1.73+")](https://blog.rust-lang.org/2023/10/05/Rust-1.73.0.html) - [Changelog](https://github.com/graphql-rust/juniper/blob/master/juniper_rocket/CHANGELOG.md) diff --git a/juniper_subscriptions/Cargo.toml b/juniper_subscriptions/Cargo.toml index 02239979..c8a7d8cc 100644 --- a/juniper_subscriptions/Cargo.toml +++ b/juniper_subscriptions/Cargo.toml @@ -2,7 +2,7 @@ name = "juniper_subscriptions" version = "0.17.0-dev" edition = "2021" -rust-version = "1.65" +rust-version = "1.73" description = "Juniper `SubscriptionCoordinator` and `SubscriptionConnection` implementations." license = "BSD-2-Clause" authors = ["nWacky "] diff --git a/juniper_subscriptions/README.md b/juniper_subscriptions/README.md index 097ffc44..070d08f6 100644 --- a/juniper_subscriptions/README.md +++ b/juniper_subscriptions/README.md @@ -4,7 +4,7 @@ [![Crates.io](https://img.shields.io/crates/v/juniper_subscriptions.svg?maxAge=2592000)](https://crates.io/crates/juniper_subscriptions) [![Documentation](https://docs.rs/juniper_subscriptions/badge.svg)](https://docs.rs/juniper_subscriptions) [![CI](https://github.com/graphql-rust/juniper/workflows/CI/badge.svg?branch=master "CI")](https://github.com/graphql-rust/juniper/actions?query=workflow%3ACI+branch%3Amaster) -[![Rust 1.65+](https://img.shields.io/badge/rustc-1.65+-lightgray.svg "Rust 1.65+")](https://blog.rust-lang.org/2022/11/03/Rust-1.65.0.html) +[![Rust 1.73+](https://img.shields.io/badge/rustc-1.73+-lightgray.svg "Rust 1.73+")](https://blog.rust-lang.org/2023/10/05/Rust-1.73.0.html) - [Changelog](https://github.com/graphql-rust/juniper/blob/master/juniper_subscriptions/CHANGELOG.md) diff --git a/juniper_warp/Cargo.toml b/juniper_warp/Cargo.toml index 3c124b4a..a4615419 100644 --- a/juniper_warp/Cargo.toml +++ b/juniper_warp/Cargo.toml @@ -2,7 +2,7 @@ name = "juniper_warp" version = "0.8.0-dev" edition = "2021" -rust-version = "1.65" +rust-version = "1.73" description = "`juniper` GraphQL integration with `warp`." license = "BSD-2-Clause" authors = ["Tom Houlé "] @@ -37,7 +37,7 @@ thiserror = "1.0" tokio = { version = "1.0", features = ["rt-multi-thread"] } warp = { version = "0.3.2", default-features = false } -# Fixes for MSRV check. +# Fixes for `minimal-versions` check. # TODO: Try remove on upgrade of `warp` crate. headers = "0.3.8" diff --git a/juniper_warp/README.md b/juniper_warp/README.md index f98d4121..0fb0e617 100644 --- a/juniper_warp/README.md +++ b/juniper_warp/README.md @@ -4,7 +4,7 @@ [![Crates.io](https://img.shields.io/crates/v/juniper_warp.svg?maxAge=2592000)](https://crates.io/crates/juniper_warp) [![Documentation](https://docs.rs/juniper_warp/badge.svg)](https://docs.rs/juniper_warp) [![CI](https://github.com/graphql-rust/juniper/workflows/CI/badge.svg?branch=master "CI")](https://github.com/graphql-rust/juniper/actions?query=workflow%3ACI+branch%3Amaster) -[![Rust 1.65+](https://img.shields.io/badge/rustc-1.65+-lightgray.svg "Rust 1.65+")](https://blog.rust-lang.org/2022/11/03/Rust-1.65.0.html) +[![Rust 1.73+](https://img.shields.io/badge/rustc-1.73+-lightgray.svg "Rust 1.73+")](https://blog.rust-lang.org/2023/10/05/Rust-1.73.0.html) - [Changelog](https://github.com/graphql-rust/juniper/blob/master/juniper_warp/CHANGELOG.md) diff --git a/tests/codegen/fail/enum/derive_duplicated_value_names.stderr b/tests/codegen/fail/enum/derive_duplicated_value_names.stderr index 8b5ca830..f2f669c8 100644 --- a/tests/codegen/fail/enum/derive_duplicated_value_names.stderr +++ b/tests/codegen/fail/enum/derive_duplicated_value_names.stderr @@ -1,7 +1,5 @@ error: GraphQL enum expected all GraphQL enum values to have unique names --> fail/enum/derive_duplicated_value_names.rs:5:5 | -5 | / Test, -6 | | #[graphql(name = "TEST")] -7 | | Test1, - | |__________^ +5 | Test, + | ^^^^ diff --git a/tests/codegen/fail/enum/derive_name_double_underscored.stderr b/tests/codegen/fail/enum/derive_name_double_underscored.stderr index 36955ef3..474dce1f 100644 --- a/tests/codegen/fail/enum/derive_name_double_underscored.stderr +++ b/tests/codegen/fail/enum/derive_name_double_underscored.stderr @@ -1,7 +1,6 @@ error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. + · note: https://spec.graphql.org/October2021#sec-Schema --> fail/enum/derive_name_double_underscored.rs:4:6 | 4 | enum __Test { | ^^^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Schema diff --git a/tests/codegen/fail/enum/derive_variant_with_field.stderr b/tests/codegen/fail/enum/derive_variant_with_field.stderr index be3bc256..9343738d 100644 --- a/tests/codegen/fail/enum/derive_variant_with_field.stderr +++ b/tests/codegen/fail/enum/derive_variant_with_field.stderr @@ -1,7 +1,6 @@ error: GraphQL enum no fields allowed for non-ignored variants + · note: https://spec.graphql.org/October2021#sec-Enums --> fail/enum/derive_variant_with_field.rs:5:12 | 5 | Variant(i32), | ^^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Enums diff --git a/tests/codegen/fail/enum/derive_wrong_item.stderr b/tests/codegen/fail/enum/derive_wrong_item.stderr index 3670fc04..4b338edc 100644 --- a/tests/codegen/fail/enum/derive_wrong_item.stderr +++ b/tests/codegen/fail/enum/derive_wrong_item.stderr @@ -2,4 +2,4 @@ error: GraphQL enum can only be derived on enums --> fail/enum/derive_wrong_item.rs:4:1 | 4 | struct Test {} - | ^^^^^^^^^^^^^^ + | ^^^^^^ diff --git a/tests/codegen/fail/input-object/derive_incompatible_field_type.stderr b/tests/codegen/fail/input-object/derive_incompatible_field_type.stderr index 21bf4014..46abf94a 100644 --- a/tests/codegen/fail/input-object/derive_incompatible_field_type.stderr +++ b/tests/codegen/fail/input-object/derive_incompatible_field_type.stderr @@ -1,47 +1,46 @@ error[E0277]: the trait bound `ObjectA: IsInputType<__S>` is not satisfied - --> fail/input-object/derive_incompatible_field_type.rs:10:12 - | -10 | field: ObjectA, - | ^^^^^^^ the trait `IsInputType<__S>` is not implemented for `ObjectA` - | - = help: the following other types implement trait `IsInputType`: - > - > - > - > - as IsInputType> - > - > - > - and $N others + --> fail/input-object/derive_incompatible_field_type.rs:8:10 + | +8 | #[derive(GraphQLInputObject)] + | ^^^^^^^^^^^^^^^^^^ the trait `IsInputType<__S>` is not implemented for `ObjectA` + | + = help: the following other types implement trait `IsInputType`: + > + > + > + > + as IsInputType> + > + > + > + and $N others + = note: this error originates in the derive macro `GraphQLInputObject` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `ObjectA: FromInputValue<__S>` is not satisfied - --> fail/input-object/derive_incompatible_field_type.rs:10:12 - | -8 | #[derive(GraphQLInputObject)] - | ------------------ required by a bound introduced by this call -9 | struct Object { -10 | field: ObjectA, - | ^^^^^^^ the trait `FromInputValue<__S>` is not implemented for `ObjectA` - | - = help: the following other types implement trait `FromInputValue`: - > - > - > - > - as FromInputValue> - > - > - > - and $N others + --> fail/input-object/derive_incompatible_field_type.rs:8:10 + | +8 | #[derive(GraphQLInputObject)] + | ^^^^^^^^^^^^^^^^^^ the trait `FromInputValue<__S>` is not implemented for `ObjectA` + | + = help: the following other types implement trait `FromInputValue`: + > + > + > + > + as FromInputValue> + > + > + > + and $N others note: required by a bound in `Registry::<'r, S>::arg` - --> $WORKSPACE/juniper/src/executor/mod.rs - | - | pub fn arg(&mut self, name: &str, info: &T::TypeInfo) -> Argument<'r, S> - | --- required by a bound in this associated function - | where - | T: GraphQLType + FromInputValue, - | ^^^^^^^^^^^^^^^^^ required by this bound in `Registry::<'r, S>::arg` + --> $WORKSPACE/juniper/src/executor/mod.rs + | + | pub fn arg(&mut self, name: &str, info: &T::TypeInfo) -> Argument<'r, S> + | --- required by a bound in this associated function + | where + | T: GraphQLType + FromInputValue, + | ^^^^^^^^^^^^^^^^^ required by this bound in `Registry::<'r, S>::arg` + = note: this error originates in the derive macro `GraphQLInputObject` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `ObjectA: FromInputValue<__S>` is not satisfied --> fail/input-object/derive_incompatible_field_type.rs:8:10 diff --git a/tests/codegen/fail/input-object/derive_no_underscore.stderr b/tests/codegen/fail/input-object/derive_no_underscore.stderr index 98deeaa1..ebaa9322 100644 --- a/tests/codegen/fail/input-object/derive_no_underscore.stderr +++ b/tests/codegen/fail/input-object/derive_no_underscore.stderr @@ -1,8 +1,6 @@ error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. + · note: https://spec.graphql.org/October2021#sec-Schema --> fail/input-object/derive_no_underscore.rs:5:5 | -5 | / #[graphql(name = "__test")] -6 | | test: String, - | |________________^ - | - = note: https://spec.graphql.org/October2021#sec-Schema +5 | #[graphql(name = "__test")] + | ^ diff --git a/tests/codegen/fail/interface/attr_wrong_item.stderr b/tests/codegen/fail/interface/attr_wrong_item.stderr index 410f72bd..3f3e887e 100644 --- a/tests/codegen/fail/interface/attr_wrong_item.stderr +++ b/tests/codegen/fail/interface/attr_wrong_item.stderr @@ -2,4 +2,4 @@ error: GraphQL interface #[graphql_interface] attribute is applicable to trait a --> fail/interface/attr_wrong_item.rs:9:1 | 9 | enum Character {} - | ^^^^^^^^^^^^^^^^^ + | ^^^^ diff --git a/tests/codegen/fail/interface/derive_wrong_item.stderr b/tests/codegen/fail/interface/derive_wrong_item.stderr index 9b9be446..ba059bb5 100644 --- a/tests/codegen/fail/interface/derive_wrong_item.stderr +++ b/tests/codegen/fail/interface/derive_wrong_item.stderr @@ -1,6 +1,5 @@ error: GraphQL interface can only be derived on structs - --> fail/interface/derive_wrong_item.rs:9:1 - | -9 | / #[graphql(for = ObjA)] -10 | | enum Character {} - | |_________________^ + --> fail/interface/derive_wrong_item.rs:9:1 + | +9 | #[graphql(for = ObjA)] + | ^ diff --git a/tests/codegen/fail/interface/struct/attr_field_double_underscored.stderr b/tests/codegen/fail/interface/struct/attr_field_double_underscored.stderr index 85e57564..1400fbe7 100644 --- a/tests/codegen/fail/interface/struct/attr_field_double_underscored.stderr +++ b/tests/codegen/fail/interface/struct/attr_field_double_underscored.stderr @@ -1,7 +1,6 @@ error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. + · note: https://spec.graphql.org/October2021#sec-Schema --> fail/interface/struct/attr_field_double_underscored.rs:5:5 | 5 | __id: String, | ^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Schema diff --git a/tests/codegen/fail/interface/struct/attr_field_non_output_return_type.stderr b/tests/codegen/fail/interface/struct/attr_field_non_output_return_type.stderr index cd32c75c..f2d975b2 100644 --- a/tests/codegen/fail/interface/struct/attr_field_non_output_return_type.stderr +++ b/tests/codegen/fail/interface/struct/attr_field_non_output_return_type.stderr @@ -1,16 +1,16 @@ error[E0277]: the trait bound `ObjB: IsOutputType<__S>` is not satisfied - --> fail/interface/struct/attr_field_non_output_return_type.rs:8:1 - | -8 | #[graphql_interface] - | ^^^^^^^^^^^^^^^^^^^^ the trait `IsOutputType<__S>` is not implemented for `ObjB` - | - = help: the following other types implement trait `IsOutputType`: - > - > - > - > - as IsOutputType> - > - > - > - and $N others + --> fail/interface/struct/attr_field_non_output_return_type.rs:10:9 + | +10 | id: ObjB, + | ^^^^ the trait `IsOutputType<__S>` is not implemented for `ObjB` + | + = help: the following other types implement trait `IsOutputType`: + > + > + > + > + as IsOutputType> + > + > + > + and $N others diff --git a/tests/codegen/fail/interface/struct/attr_fields_duplicate.stderr b/tests/codegen/fail/interface/struct/attr_fields_duplicate.stderr index 109f2b7c..cad33766 100644 --- a/tests/codegen/fail/interface/struct/attr_fields_duplicate.stderr +++ b/tests/codegen/fail/interface/struct/attr_fields_duplicate.stderr @@ -1,12 +1,6 @@ error: GraphQL interface must have a different name for each field + · note: https://spec.graphql.org/October2021#sec-Interfaces --> fail/interface/struct/attr_fields_duplicate.rs:4:1 | -4 | / struct Character { -5 | | id: String, -6 | | -7 | | #[graphql(name = "id")] -8 | | id2: String, -9 | | } - | |_^ - | - = note: https://spec.graphql.org/October2021#sec-Interfaces +4 | struct Character { + | ^^^^^^ diff --git a/tests/codegen/fail/interface/struct/attr_missing_field.stderr b/tests/codegen/fail/interface/struct/attr_missing_field.stderr index 97b66fc7..b3b53574 100644 --- a/tests/codegen/fail/interface/struct/attr_missing_field.stderr +++ b/tests/codegen/fail/interface/struct/attr_missing_field.stderr @@ -13,27 +13,3 @@ error[E0080]: evaluation of constant value failed | ^^ the evaluated program panicked at 'Failed to implement interface `Character` on `ObjA`: Field `id` isn't implemented on `ObjA`.', $DIR/fail/interface/struct/attr_missing_field.rs:11:5 | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `::juniper::assert_field` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0080]: evaluation of constant value failed - --> fail/interface/struct/attr_missing_field.rs:11:5 - | -11 | id: String, - | ^^ the evaluated program panicked at 'Failed to implement interface `Character` on `ObjA`: Field `id` isn't implemented on `ObjA`.', $DIR/fail/interface/struct/attr_missing_field.rs:11:5 - | - = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `::juniper::assert_field` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0277]: the trait bound `ObjA: reflect::Field<__S, 11301463986558097276003903130001171064>` is not satisfied - --> fail/interface/struct/attr_missing_field.rs:11:5 - | -11 | id: String, - | ^^ the trait `reflect::Field<__S, 11301463986558097276003903130001171064>` is not implemented for `ObjA` - | - = help: the trait `reflect::Field<__S, 140650918148392961738240285796466530725>` is implemented for `ObjA` - -error[E0277]: the trait bound `ObjA: AsyncField<__S, 11301463986558097276003903130001171064>` is not satisfied - --> fail/interface/struct/attr_missing_field.rs:11:5 - | -11 | id: String, - | ^^ the trait `AsyncField<__S, 11301463986558097276003903130001171064>` is not implemented for `ObjA` - | - = help: the trait `AsyncField<__S, 140650918148392961738240285796466530725>` is implemented for `ObjA` diff --git a/tests/codegen/fail/interface/struct/attr_name_double_underscored.stderr b/tests/codegen/fail/interface/struct/attr_name_double_underscored.stderr index df34c85e..7deb8f0a 100644 --- a/tests/codegen/fail/interface/struct/attr_name_double_underscored.stderr +++ b/tests/codegen/fail/interface/struct/attr_name_double_underscored.stderr @@ -1,7 +1,6 @@ error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. + · note: https://spec.graphql.org/October2021#sec-Schema --> fail/interface/struct/attr_name_double_underscored.rs:4:8 | 4 | struct __Character { | ^^^^^^^^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Schema diff --git a/tests/codegen/fail/interface/struct/attr_no_fields.stderr b/tests/codegen/fail/interface/struct/attr_no_fields.stderr index f8fc279a..ed7cdeda 100644 --- a/tests/codegen/fail/interface/struct/attr_no_fields.stderr +++ b/tests/codegen/fail/interface/struct/attr_no_fields.stderr @@ -1,7 +1,6 @@ error: GraphQL interface must have at least one field + · note: https://spec.graphql.org/October2021#sec-Interfaces --> fail/interface/struct/attr_no_fields.rs:4:1 | 4 | struct Character {} - | ^^^^^^^^^^^^^^^^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Interfaces + | ^^^^^^ diff --git a/tests/codegen/fail/interface/struct/attr_unnamed_field.stderr b/tests/codegen/fail/interface/struct/attr_unnamed_field.stderr index 6ad84969..e75a958e 100644 --- a/tests/codegen/fail/interface/struct/attr_unnamed_field.stderr +++ b/tests/codegen/fail/interface/struct/attr_unnamed_field.stderr @@ -1,7 +1,6 @@ error: GraphQL interface expected named struct field + · note: https://spec.graphql.org/October2021#sec-Interfaces --> fail/interface/struct/attr_unnamed_field.rs:4:18 | 4 | struct Character(i32); | ^^^ - | - = note: https://spec.graphql.org/October2021#sec-Interfaces diff --git a/tests/codegen/fail/interface/struct/derive_field_double_underscored.stderr b/tests/codegen/fail/interface/struct/derive_field_double_underscored.stderr index f8330549..9d3cf023 100644 --- a/tests/codegen/fail/interface/struct/derive_field_double_underscored.stderr +++ b/tests/codegen/fail/interface/struct/derive_field_double_underscored.stderr @@ -1,7 +1,6 @@ error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. + · note: https://spec.graphql.org/October2021#sec-Schema --> fail/interface/struct/derive_field_double_underscored.rs:5:5 | 5 | __id: String, | ^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Schema diff --git a/tests/codegen/fail/interface/struct/derive_field_non_output_return_type.stderr b/tests/codegen/fail/interface/struct/derive_field_non_output_return_type.stderr index d8b5b733..8bc3aa0b 100644 --- a/tests/codegen/fail/interface/struct/derive_field_non_output_return_type.stderr +++ b/tests/codegen/fail/interface/struct/derive_field_non_output_return_type.stderr @@ -1,16 +1,16 @@ error[E0277]: the trait bound `ObjB: IsOutputType<__S>` is not satisfied - --> fail/interface/struct/derive_field_non_output_return_type.rs:8:10 - | -8 | #[derive(GraphQLInterface)] - | ^^^^^^^^^^^^^^^^ the trait `IsOutputType<__S>` is not implemented for `ObjB` - | - = help: the following other types implement trait `IsOutputType`: - > - > - > - > - as IsOutputType> - > - > - > - and $N others + --> fail/interface/struct/derive_field_non_output_return_type.rs:10:9 + | +10 | id: ObjB, + | ^^^^ the trait `IsOutputType<__S>` is not implemented for `ObjB` + | + = help: the following other types implement trait `IsOutputType`: + > + > + > + > + as IsOutputType> + > + > + > + and $N others diff --git a/tests/codegen/fail/interface/struct/derive_fields_duplicate.stderr b/tests/codegen/fail/interface/struct/derive_fields_duplicate.stderr index 63d03bc9..a671639f 100644 --- a/tests/codegen/fail/interface/struct/derive_fields_duplicate.stderr +++ b/tests/codegen/fail/interface/struct/derive_fields_duplicate.stderr @@ -1,12 +1,6 @@ error: GraphQL interface must have a different name for each field + · note: https://spec.graphql.org/October2021#sec-Interfaces --> fail/interface/struct/derive_fields_duplicate.rs:4:1 | -4 | / struct Character { -5 | | id: String, -6 | | -7 | | #[graphql(name = "id")] -8 | | id2: String, -9 | | } - | |_^ - | - = note: https://spec.graphql.org/October2021#sec-Interfaces +4 | struct Character { + | ^^^^^^ diff --git a/tests/codegen/fail/interface/struct/derive_missing_field.stderr b/tests/codegen/fail/interface/struct/derive_missing_field.stderr index ef6ef2d8..6f934431 100644 --- a/tests/codegen/fail/interface/struct/derive_missing_field.stderr +++ b/tests/codegen/fail/interface/struct/derive_missing_field.stderr @@ -13,27 +13,3 @@ error[E0080]: evaluation of constant value failed | ^^ the evaluated program panicked at 'Failed to implement interface `Character` on `ObjA`: Field `id` isn't implemented on `ObjA`.', $DIR/fail/interface/struct/derive_missing_field.rs:12:5 | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `::juniper::assert_field` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0080]: evaluation of constant value failed - --> fail/interface/struct/derive_missing_field.rs:12:5 - | -12 | id: String, - | ^^ the evaluated program panicked at 'Failed to implement interface `Character` on `ObjA`: Field `id` isn't implemented on `ObjA`.', $DIR/fail/interface/struct/derive_missing_field.rs:12:5 - | - = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `::juniper::assert_field` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0277]: the trait bound `ObjA: reflect::Field<__S, 11301463986558097276003903130001171064>` is not satisfied - --> fail/interface/struct/derive_missing_field.rs:12:5 - | -12 | id: String, - | ^^ the trait `reflect::Field<__S, 11301463986558097276003903130001171064>` is not implemented for `ObjA` - | - = help: the trait `reflect::Field<__S, 140650918148392961738240285796466530725>` is implemented for `ObjA` - -error[E0277]: the trait bound `ObjA: AsyncField<__S, 11301463986558097276003903130001171064>` is not satisfied - --> fail/interface/struct/derive_missing_field.rs:12:5 - | -12 | id: String, - | ^^ the trait `AsyncField<__S, 11301463986558097276003903130001171064>` is not implemented for `ObjA` - | - = help: the trait `AsyncField<__S, 140650918148392961738240285796466530725>` is implemented for `ObjA` diff --git a/tests/codegen/fail/interface/struct/derive_name_double_underscored.stderr b/tests/codegen/fail/interface/struct/derive_name_double_underscored.stderr index 9b41f141..5455787f 100644 --- a/tests/codegen/fail/interface/struct/derive_name_double_underscored.stderr +++ b/tests/codegen/fail/interface/struct/derive_name_double_underscored.stderr @@ -1,7 +1,6 @@ error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. + · note: https://spec.graphql.org/October2021#sec-Schema --> fail/interface/struct/derive_name_double_underscored.rs:4:8 | 4 | struct __Character { | ^^^^^^^^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Schema diff --git a/tests/codegen/fail/interface/struct/derive_no_fields.stderr b/tests/codegen/fail/interface/struct/derive_no_fields.stderr index 742c337a..649e843f 100644 --- a/tests/codegen/fail/interface/struct/derive_no_fields.stderr +++ b/tests/codegen/fail/interface/struct/derive_no_fields.stderr @@ -1,7 +1,6 @@ error: GraphQL interface must have at least one field + · note: https://spec.graphql.org/October2021#sec-Interfaces --> fail/interface/struct/derive_no_fields.rs:4:1 | 4 | struct Character {} - | ^^^^^^^^^^^^^^^^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Interfaces + | ^^^^^^ diff --git a/tests/codegen/fail/interface/struct/derive_unnamed_field.stderr b/tests/codegen/fail/interface/struct/derive_unnamed_field.stderr index 9783cb53..3b47a6e5 100644 --- a/tests/codegen/fail/interface/struct/derive_unnamed_field.stderr +++ b/tests/codegen/fail/interface/struct/derive_unnamed_field.stderr @@ -1,7 +1,6 @@ error: GraphQL interface expected named struct field + · note: https://spec.graphql.org/October2021#sec-Interfaces --> fail/interface/struct/derive_unnamed_field.rs:4:18 | 4 | struct Character(i32); | ^^^ - | - = note: https://spec.graphql.org/October2021#sec-Interfaces diff --git a/tests/codegen/fail/interface/trait/argument_double_underscored.stderr b/tests/codegen/fail/interface/trait/argument_double_underscored.stderr index 4cf82f0a..0c833650 100644 --- a/tests/codegen/fail/interface/trait/argument_double_underscored.stderr +++ b/tests/codegen/fail/interface/trait/argument_double_underscored.stderr @@ -1,7 +1,6 @@ error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. + · note: https://spec.graphql.org/October2021#sec-Schema --> fail/interface/trait/argument_double_underscored.rs:5:18 | 5 | fn id(&self, __num: i32) -> &str; | ^^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Schema diff --git a/tests/codegen/fail/interface/trait/argument_non_input_type.stderr b/tests/codegen/fail/interface/trait/argument_non_input_type.stderr index a6af9595..0a143836 100644 --- a/tests/codegen/fail/interface/trait/argument_non_input_type.stderr +++ b/tests/codegen/fail/interface/trait/argument_non_input_type.stderr @@ -16,29 +16,27 @@ error[E0277]: the trait bound `ObjA: IsInputType<__S>` is not satisfied and $N others error[E0277]: the trait bound `ObjA: FromInputValue<__S>` is not satisfied - --> fail/interface/trait/argument_non_input_type.rs:10:23 - | -8 | #[graphql_interface] - | -------------------- required by a bound introduced by this call -9 | trait Character { -10 | fn id(&self, obj: ObjA) -> &str; - | ^^^^ the trait `FromInputValue<__S>` is not implemented for `ObjA` - | - = help: the following other types implement trait `FromInputValue`: - > - > - > - as FromInputValue> - > - > - > - > - and $N others + --> fail/interface/trait/argument_non_input_type.rs:8:1 + | +8 | #[graphql_interface] + | ^^^^^^^^^^^^^^^^^^^^ the trait `FromInputValue<__S>` is not implemented for `ObjA` + | + = help: the following other types implement trait `FromInputValue`: + > + > + > + as FromInputValue> + > + > + > + > + and $N others note: required by a bound in `Registry::<'r, S>::arg` - --> $WORKSPACE/juniper/src/executor/mod.rs - | - | pub fn arg(&mut self, name: &str, info: &T::TypeInfo) -> Argument<'r, S> - | --- required by a bound in this associated function - | where - | T: GraphQLType + FromInputValue, - | ^^^^^^^^^^^^^^^^^ required by this bound in `Registry::<'r, S>::arg` + --> $WORKSPACE/juniper/src/executor/mod.rs + | + | pub fn arg(&mut self, name: &str, info: &T::TypeInfo) -> Argument<'r, S> + | --- required by a bound in this associated function + | where + | T: GraphQLType + FromInputValue, + | ^^^^^^^^^^^^^^^^^ required by this bound in `Registry::<'r, S>::arg` + = note: this error originates in the attribute macro `graphql_interface` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/codegen/fail/interface/trait/field_double_underscored.stderr b/tests/codegen/fail/interface/trait/field_double_underscored.stderr index 3069e574..1e2b00bf 100644 --- a/tests/codegen/fail/interface/trait/field_double_underscored.stderr +++ b/tests/codegen/fail/interface/trait/field_double_underscored.stderr @@ -1,7 +1,6 @@ error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. + · note: https://spec.graphql.org/October2021#sec-Schema --> fail/interface/trait/field_double_underscored.rs:5:8 | 5 | fn __id(&self) -> &str; | ^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Schema diff --git a/tests/codegen/fail/interface/trait/field_non_output_return_type.stderr b/tests/codegen/fail/interface/trait/field_non_output_return_type.stderr index ca0c5593..5f714086 100644 --- a/tests/codegen/fail/interface/trait/field_non_output_return_type.stderr +++ b/tests/codegen/fail/interface/trait/field_non_output_return_type.stderr @@ -1,16 +1,16 @@ error[E0277]: the trait bound `ObjB: IsOutputType<__S>` is not satisfied - --> fail/interface/trait/field_non_output_return_type.rs:8:1 - | -8 | #[graphql_interface] - | ^^^^^^^^^^^^^^^^^^^^ the trait `IsOutputType<__S>` is not implemented for `ObjB` - | - = help: the following other types implement trait `IsOutputType`: - > - > - > - > - as IsOutputType> - > - > - > - and $N others + --> fail/interface/trait/field_non_output_return_type.rs:10:21 + | +10 | fn id(&self) -> ObjB; + | ^^^^ the trait `IsOutputType<__S>` is not implemented for `ObjB` + | + = help: the following other types implement trait `IsOutputType`: + > + > + > + > + as IsOutputType> + > + > + > + and $N others diff --git a/tests/codegen/fail/interface/trait/fields_duplicate.stderr b/tests/codegen/fail/interface/trait/fields_duplicate.stderr index 4750e958..19bcfb51 100644 --- a/tests/codegen/fail/interface/trait/fields_duplicate.stderr +++ b/tests/codegen/fail/interface/trait/fields_duplicate.stderr @@ -1,12 +1,6 @@ error: GraphQL interface must have a different name for each field + · note: https://spec.graphql.org/October2021#sec-Interfaces --> fail/interface/trait/fields_duplicate.rs:4:1 | -4 | / trait Character { -5 | | fn id(&self) -> &str; -6 | | -7 | | #[graphql(name = "id")] -8 | | fn id2(&self) -> &str; -9 | | } - | |_^ - | - = note: https://spec.graphql.org/October2021#sec-Interfaces +4 | trait Character { + | ^^^^^ diff --git a/tests/codegen/fail/interface/trait/method_default_impl.stderr b/tests/codegen/fail/interface/trait/method_default_impl.stderr index 0e95cc3d..fed77316 100644 --- a/tests/codegen/fail/interface/trait/method_default_impl.stderr +++ b/tests/codegen/fail/interface/trait/method_default_impl.stderr @@ -1,4 +1,5 @@ error: GraphQL interface trait method can't have default implementation + · note: https://spec.graphql.org/October2021#sec-Interfaces --> fail/interface/trait/method_default_impl.rs:5:26 | 5 | fn id(&self) -> &str { @@ -6,5 +7,3 @@ error: GraphQL interface trait method can't have default implementation 6 | | "default" 7 | | } | |_____^ - | - = note: https://spec.graphql.org/October2021#sec-Interfaces diff --git a/tests/codegen/fail/interface/trait/missing_field.stderr b/tests/codegen/fail/interface/trait/missing_field.stderr index 11537b90..b3bcc8e5 100644 --- a/tests/codegen/fail/interface/trait/missing_field.stderr +++ b/tests/codegen/fail/interface/trait/missing_field.stderr @@ -13,27 +13,3 @@ error[E0080]: evaluation of constant value failed | ^^ the evaluated program panicked at 'Failed to implement interface `Character` on `ObjA`: Field `id` isn't implemented on `ObjA`.', $DIR/fail/interface/trait/missing_field.rs:11:8 | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `::juniper::assert_field` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0080]: evaluation of constant value failed - --> fail/interface/trait/missing_field.rs:11:8 - | -11 | fn id(&self) -> &str; - | ^^ the evaluated program panicked at 'Failed to implement interface `Character` on `ObjA`: Field `id` isn't implemented on `ObjA`.', $DIR/fail/interface/trait/missing_field.rs:11:8 - | - = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `::juniper::assert_field` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0277]: the trait bound `ObjA: reflect::Field<__S, 11301463986558097276003903130001171064>` is not satisfied - --> fail/interface/trait/missing_field.rs:11:8 - | -11 | fn id(&self) -> &str; - | ^^ the trait `reflect::Field<__S, 11301463986558097276003903130001171064>` is not implemented for `ObjA` - | - = help: the trait `reflect::Field<__S, 140650918148392961738240285796466530725>` is implemented for `ObjA` - -error[E0277]: the trait bound `ObjA: AsyncField<__S, 11301463986558097276003903130001171064>` is not satisfied - --> fail/interface/trait/missing_field.rs:11:8 - | -11 | fn id(&self) -> &str; - | ^^ the trait `AsyncField<__S, 11301463986558097276003903130001171064>` is not implemented for `ObjA` - | - = help: the trait `AsyncField<__S, 140650918148392961738240285796466530725>` is implemented for `ObjA` diff --git a/tests/codegen/fail/interface/trait/name_double_underscored.stderr b/tests/codegen/fail/interface/trait/name_double_underscored.stderr index 35640240..0dfd2226 100644 --- a/tests/codegen/fail/interface/trait/name_double_underscored.stderr +++ b/tests/codegen/fail/interface/trait/name_double_underscored.stderr @@ -1,7 +1,6 @@ error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. + · note: https://spec.graphql.org/October2021#sec-Schema --> fail/interface/trait/name_double_underscored.rs:4:7 | 4 | trait __Character { | ^^^^^^^^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Schema diff --git a/tests/codegen/fail/interface/trait/no_fields.stderr b/tests/codegen/fail/interface/trait/no_fields.stderr index 2638dc9d..c07f993b 100644 --- a/tests/codegen/fail/interface/trait/no_fields.stderr +++ b/tests/codegen/fail/interface/trait/no_fields.stderr @@ -1,7 +1,6 @@ error: GraphQL interface must have at least one field + · note: https://spec.graphql.org/October2021#sec-Interfaces --> fail/interface/trait/no_fields.rs:4:1 | 4 | trait Character {} - | ^^^^^^^^^^^^^^^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Interfaces + | ^^^^^ diff --git a/tests/codegen/fail/object/argument_double_underscored.stderr b/tests/codegen/fail/object/argument_double_underscored.stderr index ae33cf32..0eb5669a 100644 --- a/tests/codegen/fail/object/argument_double_underscored.stderr +++ b/tests/codegen/fail/object/argument_double_underscored.stderr @@ -1,7 +1,6 @@ error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. + · note: https://spec.graphql.org/October2021#sec-Schema --> fail/object/argument_double_underscored.rs:7:18 | 7 | fn id(&self, __num: i32) -> &str { | ^^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Schema diff --git a/tests/codegen/fail/object/argument_non_input_type.stderr b/tests/codegen/fail/object/argument_non_input_type.stderr index 323928ff..5310ce4a 100644 --- a/tests/codegen/fail/object/argument_non_input_type.stderr +++ b/tests/codegen/fail/object/argument_non_input_type.stderr @@ -16,13 +16,10 @@ error[E0277]: the trait bound `ObjA: IsInputType<__S>` is not satisfied and $N others error[E0277]: the trait bound `ObjA: FromInputValue<__S>` is not satisfied - --> fail/object/argument_non_input_type.rs:12:23 + --> fail/object/argument_non_input_type.rs:10:1 | 10 | #[graphql_object] - | ----------------- required by a bound introduced by this call -11 | impl ObjB { -12 | fn id(&self, obj: ObjA) -> &str { - | ^^^^ the trait `FromInputValue<__S>` is not implemented for `ObjA` + | ^^^^^^^^^^^^^^^^^ the trait `FromInputValue<__S>` is not implemented for `ObjA` | = help: the following other types implement trait `FromInputValue`: > @@ -42,6 +39,7 @@ note: required by a bound in `Registry::<'r, S>::arg` | where | T: GraphQLType + FromInputValue, | ^^^^^^^^^^^^^^^^^ required by this bound in `Registry::<'r, S>::arg` + = note: this error originates in the attribute macro `graphql_object` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `ObjA: FromInputValue<__S>` is not satisfied --> fail/object/argument_non_input_type.rs:10:1 @@ -60,20 +58,3 @@ error[E0277]: the trait bound `ObjA: FromInputValue<__S>` is not satisfied > and $N others = note: this error originates in the attribute macro `graphql_object` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0277]: the trait bound `ObjA: FromInputValue<__S>` is not satisfied - --> fail/object/argument_non_input_type.rs:12:23 - | -12 | fn id(&self, obj: ObjA) -> &str { - | ^^^^ the trait `FromInputValue<__S>` is not implemented for `ObjA` - | - = help: the following other types implement trait `FromInputValue`: - > - > - > - as FromInputValue> - > - > - > - > - and $N others diff --git a/tests/codegen/fail/object/attr_field_double_underscored.stderr b/tests/codegen/fail/object/attr_field_double_underscored.stderr index cd1849d8..48c6275a 100644 --- a/tests/codegen/fail/object/attr_field_double_underscored.stderr +++ b/tests/codegen/fail/object/attr_field_double_underscored.stderr @@ -1,5 +1,5 @@ error: #[graphql_object] attribute is applicable to non-trait `impl` blocks only - --> $DIR/attr_field_double_underscored.rs:5:1 + --> fail/object/attr_field_double_underscored.rs:5:1 | 5 | #[graphql_object] | ^^^^^^^^^^^^^^^^^ diff --git a/tests/codegen/fail/object/attr_field_non_output_return_type.stderr b/tests/codegen/fail/object/attr_field_non_output_return_type.stderr index 1c775851..d6fbf56d 100644 --- a/tests/codegen/fail/object/attr_field_non_output_return_type.stderr +++ b/tests/codegen/fail/object/attr_field_non_output_return_type.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `ObjB: IsOutputType<__S>` is not satisfied - --> fail/object/attr_field_non_output_return_type.rs:10:1 + --> fail/object/attr_field_non_output_return_type.rs:12:21 | -10 | #[graphql_object] - | ^^^^^^^^^^^^^^^^^ the trait `IsOutputType<__S>` is not implemented for `ObjB` +12 | fn id(&self) -> ObjB { + | ^^^^ the trait `IsOutputType<__S>` is not implemented for `ObjB` | = help: the following other types implement trait `IsOutputType`: > diff --git a/tests/codegen/fail/object/attr_fields_duplicate.stderr b/tests/codegen/fail/object/attr_fields_duplicate.stderr index 04304a3a..49716590 100644 --- a/tests/codegen/fail/object/attr_fields_duplicate.stderr +++ b/tests/codegen/fail/object/attr_fields_duplicate.stderr @@ -1,7 +1,6 @@ error: GraphQL object must have a different name for each field + · note: https://spec.graphql.org/October2021#sec-Objects --> fail/object/attr_fields_duplicate.rs:6:6 | 6 | impl ObjA { | ^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Objects diff --git a/tests/codegen/fail/object/attr_name_double_underscored.stderr b/tests/codegen/fail/object/attr_name_double_underscored.stderr index a46fbda4..c081460a 100644 --- a/tests/codegen/fail/object/attr_name_double_underscored.stderr +++ b/tests/codegen/fail/object/attr_name_double_underscored.stderr @@ -1,7 +1,6 @@ error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. + · note: https://spec.graphql.org/October2021#sec-Schema --> fail/object/attr_name_double_underscored.rs:6:6 | 6 | impl __Obj { | ^^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Schema diff --git a/tests/codegen/fail/object/attr_no_fields.stderr b/tests/codegen/fail/object/attr_no_fields.stderr index bd3a050b..704edf43 100644 --- a/tests/codegen/fail/object/attr_no_fields.stderr +++ b/tests/codegen/fail/object/attr_no_fields.stderr @@ -1,7 +1,6 @@ error: GraphQL object must have at least one field + · note: https://spec.graphql.org/October2021#sec-Objects --> fail/object/attr_no_fields.rs:6:6 | 6 | impl Obj {} | ^^^ - | - = note: https://spec.graphql.org/October2021#sec-Objects diff --git a/tests/codegen/fail/object/attr_wrong_item.stderr b/tests/codegen/fail/object/attr_wrong_item.stderr index cf914148..777572c3 100644 --- a/tests/codegen/fail/object/attr_wrong_item.stderr +++ b/tests/codegen/fail/object/attr_wrong_item.stderr @@ -1,5 +1,5 @@ error: #[graphql_object] attribute is applicable to non-trait `impl` blocks only - --> $DIR/attr_wrong_item.rs:3:1 + --> fail/object/attr_wrong_item.rs:3:1 | 3 | #[graphql_object] | ^^^^^^^^^^^^^^^^^ diff --git a/tests/codegen/fail/object/derive_field_double_underscored.stderr b/tests/codegen/fail/object/derive_field_double_underscored.stderr index 16b38b89..ff77c3fe 100644 --- a/tests/codegen/fail/object/derive_field_double_underscored.stderr +++ b/tests/codegen/fail/object/derive_field_double_underscored.stderr @@ -1,7 +1,6 @@ error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. + · note: https://spec.graphql.org/October2021#sec-Schema --> fail/object/derive_field_double_underscored.rs:5:5 | 5 | __test: String, | ^^^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Schema diff --git a/tests/codegen/fail/object/derive_field_non_output_return_type.stderr b/tests/codegen/fail/object/derive_field_non_output_return_type.stderr index ad431c53..75dff2be 100644 --- a/tests/codegen/fail/object/derive_field_non_output_return_type.stderr +++ b/tests/codegen/fail/object/derive_field_non_output_return_type.stderr @@ -1,16 +1,16 @@ error[E0277]: the trait bound `ObjB: IsOutputType<__S>` is not satisfied - --> fail/object/derive_field_non_output_return_type.rs:8:10 - | -8 | #[derive(GraphQLObject)] - | ^^^^^^^^^^^^^ the trait `IsOutputType<__S>` is not implemented for `ObjB` - | - = help: the following other types implement trait `IsOutputType`: - > - > - > - > - as IsOutputType> - > - > - > - and $N others + --> fail/object/derive_field_non_output_return_type.rs:10:9 + | +10 | id: ObjB, + | ^^^^ the trait `IsOutputType<__S>` is not implemented for `ObjB` + | + = help: the following other types implement trait `IsOutputType`: + > + > + > + > + as IsOutputType> + > + > + > + and $N others diff --git a/tests/codegen/fail/object/derive_fields_duplicate.stderr b/tests/codegen/fail/object/derive_fields_duplicate.stderr index e7e01291..bebeef56 100644 --- a/tests/codegen/fail/object/derive_fields_duplicate.stderr +++ b/tests/codegen/fail/object/derive_fields_duplicate.stderr @@ -1,11 +1,6 @@ error: GraphQL object must have a different name for each field + · note: https://spec.graphql.org/October2021#sec-Objects --> fail/object/derive_fields_duplicate.rs:4:1 | -4 | / struct ObjA { -5 | | id: String, -6 | | #[graphql(name = "id")] -7 | | id2: String, -8 | | } - | |_^ - | - = note: https://spec.graphql.org/October2021#sec-Objects +4 | struct ObjA { + | ^^^^^^ diff --git a/tests/codegen/fail/object/derive_name_double_underscored.stderr b/tests/codegen/fail/object/derive_name_double_underscored.stderr index 08793621..dc484a0e 100644 --- a/tests/codegen/fail/object/derive_name_double_underscored.stderr +++ b/tests/codegen/fail/object/derive_name_double_underscored.stderr @@ -1,7 +1,6 @@ error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. + · note: https://spec.graphql.org/October2021#sec-Schema --> fail/object/derive_name_double_underscored.rs:4:8 | 4 | struct __Obj { | ^^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Schema diff --git a/tests/codegen/fail/object/derive_no_fields.stderr b/tests/codegen/fail/object/derive_no_fields.stderr index 31f6812d..77c281e2 100644 --- a/tests/codegen/fail/object/derive_no_fields.stderr +++ b/tests/codegen/fail/object/derive_no_fields.stderr @@ -1,7 +1,6 @@ error: GraphQL object must have at least one field + · note: https://spec.graphql.org/October2021#sec-Objects --> fail/object/derive_no_fields.rs:4:1 | 4 | struct Obj {} - | ^^^^^^^^^^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Objects + | ^^^^^^ diff --git a/tests/codegen/fail/object/derive_wrong_item.stderr b/tests/codegen/fail/object/derive_wrong_item.stderr index 5fc072a0..71b8d0e5 100644 --- a/tests/codegen/fail/object/derive_wrong_item.stderr +++ b/tests/codegen/fail/object/derive_wrong_item.stderr @@ -2,4 +2,4 @@ error: GraphQL object can only be derived for structs --> fail/object/derive_wrong_item.rs:4:1 | 4 | enum Character {} - | ^^^^^^^^^^^^^^^^^ + | ^^^^ diff --git a/tests/codegen/fail/scalar/derive_input/attr_transparent_multiple_named_fields.stderr b/tests/codegen/fail/scalar/derive_input/attr_transparent_multiple_named_fields.stderr index a101fdb6..f082ef00 100644 --- a/tests/codegen/fail/scalar/derive_input/attr_transparent_multiple_named_fields.stderr +++ b/tests/codegen/fail/scalar/derive_input/attr_transparent_multiple_named_fields.stderr @@ -1,8 +1,5 @@ error: GraphQL scalar `transparent` attribute argument requires exactly 1 field --> fail/scalar/derive_input/attr_transparent_multiple_named_fields.rs:4:1 | -4 | / struct Scalar { -5 | | id: i32, -6 | | another: i32, -7 | | } - | |_^ +4 | struct Scalar { + | ^^^^^^ diff --git a/tests/codegen/fail/scalar/derive_input/attr_transparent_multiple_unnamed_fields.stderr b/tests/codegen/fail/scalar/derive_input/attr_transparent_multiple_unnamed_fields.stderr index 6ff2eb84..0c17a53c 100644 --- a/tests/codegen/fail/scalar/derive_input/attr_transparent_multiple_unnamed_fields.stderr +++ b/tests/codegen/fail/scalar/derive_input/attr_transparent_multiple_unnamed_fields.stderr @@ -2,4 +2,4 @@ error: GraphQL scalar `transparent` attribute argument requires exactly 1 field --> fail/scalar/derive_input/attr_transparent_multiple_unnamed_fields.rs:4:1 | 4 | struct Scalar(i32, i32); - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^ diff --git a/tests/codegen/fail/scalar/derive_input/attr_transparent_unit_struct.stderr b/tests/codegen/fail/scalar/derive_input/attr_transparent_unit_struct.stderr index 8882861f..e83780a8 100644 --- a/tests/codegen/fail/scalar/derive_input/attr_transparent_unit_struct.stderr +++ b/tests/codegen/fail/scalar/derive_input/attr_transparent_unit_struct.stderr @@ -2,4 +2,4 @@ error: GraphQL scalar `transparent` attribute argument requires exactly 1 field --> fail/scalar/derive_input/attr_transparent_unit_struct.rs:4:1 | 4 | struct ScalarSpecifiedByUrl; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^ diff --git a/tests/codegen/fail/scalar/derive_input/derive_transparent_multiple_named_fields.stderr b/tests/codegen/fail/scalar/derive_input/derive_transparent_multiple_named_fields.stderr index 1d42b4c1..a163872e 100644 --- a/tests/codegen/fail/scalar/derive_input/derive_transparent_multiple_named_fields.stderr +++ b/tests/codegen/fail/scalar/derive_input/derive_transparent_multiple_named_fields.stderr @@ -1,9 +1,5 @@ error: GraphQL scalar `transparent` attribute argument requires exactly 1 field --> fail/scalar/derive_input/derive_transparent_multiple_named_fields.rs:4:1 | -4 | / #[graphql(transparent)] -5 | | struct Scalar { -6 | | id: i32, -7 | | another: i32, -8 | | } - | |_^ +4 | #[graphql(transparent)] + | ^ diff --git a/tests/codegen/fail/scalar/derive_input/derive_transparent_multiple_unnamed_fields.stderr b/tests/codegen/fail/scalar/derive_input/derive_transparent_multiple_unnamed_fields.stderr index e7c5f5a8..9c5af34e 100644 --- a/tests/codegen/fail/scalar/derive_input/derive_transparent_multiple_unnamed_fields.stderr +++ b/tests/codegen/fail/scalar/derive_input/derive_transparent_multiple_unnamed_fields.stderr @@ -1,6 +1,5 @@ error: GraphQL scalar `transparent` attribute argument requires exactly 1 field --> fail/scalar/derive_input/derive_transparent_multiple_unnamed_fields.rs:4:1 | -4 | / #[graphql(transparent)] -5 | | struct Scalar(i32, i32); - | |________________________^ +4 | #[graphql(transparent)] + | ^ diff --git a/tests/codegen/fail/scalar/derive_input/derive_transparent_unit_struct.stderr b/tests/codegen/fail/scalar/derive_input/derive_transparent_unit_struct.stderr index 21156b67..dd62ca17 100644 --- a/tests/codegen/fail/scalar/derive_input/derive_transparent_unit_struct.stderr +++ b/tests/codegen/fail/scalar/derive_input/derive_transparent_unit_struct.stderr @@ -1,6 +1,5 @@ error: GraphQL scalar `transparent` attribute argument requires exactly 1 field --> fail/scalar/derive_input/derive_transparent_unit_struct.rs:4:1 | -4 | / #[graphql(transparent)] -5 | | struct ScalarSpecifiedByUrl; - | |____________________________^ +4 | #[graphql(transparent)] + | ^ diff --git a/tests/codegen/fail/scalar/type_alias/attr_with_not_all_resolvers.stderr b/tests/codegen/fail/scalar/type_alias/attr_with_not_all_resolvers.stderr index 879dfbd0..4ef029a4 100644 --- a/tests/codegen/fail/scalar/type_alias/attr_with_not_all_resolvers.stderr +++ b/tests/codegen/fail/scalar/type_alias/attr_with_not_all_resolvers.stderr @@ -2,4 +2,4 @@ error: GraphQL scalar all the resolvers have to be provided via `with` attribute --> fail/scalar/type_alias/attr_with_not_all_resolvers.rs:6:1 | 6 | type CustomScalar = Scalar; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^ diff --git a/tests/codegen/fail/scalar/type_alias/attr_without_resolvers.stderr b/tests/codegen/fail/scalar/type_alias/attr_without_resolvers.stderr index 6f77be79..707d2b0b 100644 --- a/tests/codegen/fail/scalar/type_alias/attr_without_resolvers.stderr +++ b/tests/codegen/fail/scalar/type_alias/attr_without_resolvers.stderr @@ -2,4 +2,4 @@ error: GraphQL scalar all the resolvers have to be provided via `with` attribute --> fail/scalar/type_alias/attr_without_resolvers.rs:6:1 | 6 | type CustomScalar = Scalar; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^ diff --git a/tests/codegen/fail/scalar_value/missing_attributes.stderr b/tests/codegen/fail/scalar_value/missing_attributes.stderr index 700a95fa..b269e5a0 100644 --- a/tests/codegen/fail/scalar_value/missing_attributes.stderr +++ b/tests/codegen/fail/scalar_value/missing_attributes.stderr @@ -1,11 +1,5 @@ error: GraphQL built-in scalars missing `#[value(as_int, as_float)]` attributes. In case you are sure that it's ok, use `#[value(allow_missing_attributes)]` to suppress this error. - --> fail/scalar_value/missing_attributes.rs:4:1 - | -4 | / pub enum DefaultScalarValue { -5 | | Int(i32), -6 | | Float(f64), -7 | | #[value(as_str, as_string, into_string)] -... | -10 | | Boolean(bool), -11 | | } - | |_^ + --> fail/scalar_value/missing_attributes.rs:4:1 + | +4 | pub enum DefaultScalarValue { + | ^^^ diff --git a/tests/codegen/fail/scalar_value/not_enum.stderr b/tests/codegen/fail/scalar_value/not_enum.stderr index f8783c99..a40a5d39 100644 --- a/tests/codegen/fail/scalar_value/not_enum.stderr +++ b/tests/codegen/fail/scalar_value/not_enum.stderr @@ -2,4 +2,4 @@ error: GraphQL built-in scalars can only be derived for enums --> fail/scalar_value/not_enum.rs:2:1 | 2 | struct ScalarValue; - | ^^^^^^^^^^^^^^^^^^^ + | ^^^^^^ diff --git a/tests/codegen/fail/subscription/argument_double_underscored.stderr b/tests/codegen/fail/subscription/argument_double_underscored.stderr index dd83ba63..a79c53eb 100644 --- a/tests/codegen/fail/subscription/argument_double_underscored.stderr +++ b/tests/codegen/fail/subscription/argument_double_underscored.stderr @@ -1,7 +1,6 @@ error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. + · note: https://spec.graphql.org/October2021#sec-Schema --> fail/subscription/argument_double_underscored.rs:11:24 | 11 | async fn id(&self, __num: i32) -> Stream<'static, &'static str> { | ^^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Schema diff --git a/tests/codegen/fail/subscription/argument_non_input_type.stderr b/tests/codegen/fail/subscription/argument_non_input_type.stderr index baded3fd..3e2b9aaa 100644 --- a/tests/codegen/fail/subscription/argument_non_input_type.stderr +++ b/tests/codegen/fail/subscription/argument_non_input_type.stderr @@ -24,13 +24,10 @@ error[E0277]: the trait bound `ObjA: IsInputType<__S>` is not satisfied and $N others error[E0277]: the trait bound `ObjA: FromInputValue<__S>` is not satisfied - --> fail/subscription/argument_non_input_type.rs:17:29 + --> fail/subscription/argument_non_input_type.rs:15:1 | 15 | #[graphql_subscription] - | ----------------------- required by a bound introduced by this call -16 | impl ObjB { -17 | async fn id(&self, obj: ObjA) -> Stream<'static, &'static str> { - | ^^^^ the trait `FromInputValue<__S>` is not implemented for `ObjA` + | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromInputValue<__S>` is not implemented for `ObjA` | = help: the following other types implement trait `FromInputValue`: > @@ -50,6 +47,7 @@ note: required by a bound in `Registry::<'r, S>::arg` | where | T: GraphQLType + FromInputValue, | ^^^^^^^^^^^^^^^^^ required by this bound in `Registry::<'r, S>::arg` + = note: this error originates in the attribute macro `graphql_subscription` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `ObjA: FromInputValue<__S>` is not satisfied --> fail/subscription/argument_non_input_type.rs:15:1 @@ -68,20 +66,3 @@ error[E0277]: the trait bound `ObjA: FromInputValue<__S>` is not satisfied > and $N others = note: this error originates in the attribute macro `graphql_subscription` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0277]: the trait bound `ObjA: FromInputValue<__S>` is not satisfied - --> fail/subscription/argument_non_input_type.rs:17:29 - | -17 | async fn id(&self, obj: ObjA) -> Stream<'static, &'static str> { - | ^^^^ the trait `FromInputValue<__S>` is not implemented for `ObjA` - | - = help: the following other types implement trait `FromInputValue`: - > - > - > - as FromInputValue> - > - > - > - > - and $N others diff --git a/tests/codegen/fail/subscription/field_double_underscored.stderr b/tests/codegen/fail/subscription/field_double_underscored.stderr index 1f5e519a..c22772ab 100644 --- a/tests/codegen/fail/subscription/field_double_underscored.stderr +++ b/tests/codegen/fail/subscription/field_double_underscored.stderr @@ -1,5 +1,5 @@ error: #[graphql_subscription] attribute is applicable to non-trait `impl` blocks only - --> $DIR/field_double_underscored.rs:9:1 + --> fail/subscription/field_double_underscored.rs:9:1 | 9 | #[graphql_subscription] | ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/codegen/fail/subscription/field_non_output_return_type.stderr b/tests/codegen/fail/subscription/field_non_output_return_type.stderr index 5a47e2c7..e1a42551 100644 --- a/tests/codegen/fail/subscription/field_non_output_return_type.stderr +++ b/tests/codegen/fail/subscription/field_non_output_return_type.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `ObjB: IsOutputType<__S>` is not satisfied - --> fail/subscription/field_non_output_return_type.rs:15:1 + --> fail/subscription/field_non_output_return_type.rs:17:27 | -15 | #[graphql_subscription] - | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `IsOutputType<__S>` is not implemented for `ObjB` +17 | async fn id(&self) -> Stream<'static, ObjB> { + | ^^^^^^ the trait `IsOutputType<__S>` is not implemented for `ObjB` | = help: the following other types implement trait `IsOutputType`: > diff --git a/tests/codegen/fail/subscription/field_not_async.stderr b/tests/codegen/fail/subscription/field_not_async.stderr index 93fa942b..d1c63681 100644 --- a/tests/codegen/fail/subscription/field_not_async.stderr +++ b/tests/codegen/fail/subscription/field_not_async.stderr @@ -1,8 +1,7 @@ error: GraphQL object synchronous resolvers are not supported + · note: https://spec.graphql.org/October2021#sec-Objects + · note: Specify that this function is async: `async fn foo()` --> fail/subscription/field_not_async.rs:11:5 | 11 | fn id(&self) -> Stream<'static, bool> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Objects - = note: Specify that this function is async: `async fn foo()` + | ^^ diff --git a/tests/codegen/fail/subscription/fields_duplicate.stderr b/tests/codegen/fail/subscription/fields_duplicate.stderr index 28281e51..c3c43abd 100644 --- a/tests/codegen/fail/subscription/fields_duplicate.stderr +++ b/tests/codegen/fail/subscription/fields_duplicate.stderr @@ -1,7 +1,6 @@ error: GraphQL object must have a different name for each field + · note: https://spec.graphql.org/October2021#sec-Objects --> fail/subscription/fields_duplicate.rs:10:6 | 10 | impl ObjA { | ^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Objects diff --git a/tests/codegen/fail/subscription/name_double_underscored.stderr b/tests/codegen/fail/subscription/name_double_underscored.stderr index d9fffd1b..607414ec 100644 --- a/tests/codegen/fail/subscription/name_double_underscored.stderr +++ b/tests/codegen/fail/subscription/name_double_underscored.stderr @@ -1,7 +1,6 @@ error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. + · note: https://spec.graphql.org/October2021#sec-Schema --> fail/subscription/name_double_underscored.rs:10:6 | 10 | impl __Obj { | ^^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Schema diff --git a/tests/codegen/fail/subscription/no_fields.stderr b/tests/codegen/fail/subscription/no_fields.stderr index 6faaed2f..90c66ae6 100644 --- a/tests/codegen/fail/subscription/no_fields.stderr +++ b/tests/codegen/fail/subscription/no_fields.stderr @@ -1,7 +1,6 @@ error: GraphQL object must have at least one field + · note: https://spec.graphql.org/October2021#sec-Objects --> fail/subscription/no_fields.rs:6:6 | 6 | impl Obj {} | ^^^ - | - = note: https://spec.graphql.org/October2021#sec-Objects diff --git a/tests/codegen/fail/subscription/wrong_item.stderr b/tests/codegen/fail/subscription/wrong_item.stderr index d149b56b..8f238ca1 100644 --- a/tests/codegen/fail/subscription/wrong_item.stderr +++ b/tests/codegen/fail/subscription/wrong_item.stderr @@ -1,5 +1,5 @@ error: #[graphql_subscription] attribute is applicable to non-trait `impl` blocks only - --> $DIR/wrong_item.rs:3:1 + --> fail/subscription/wrong_item.rs:3:1 | 3 | #[graphql_subscription] | ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/codegen/fail/union/attr_wrong_item.stderr b/tests/codegen/fail/union/attr_wrong_item.stderr index 2a6d3ae0..7e49ac41 100644 --- a/tests/codegen/fail/union/attr_wrong_item.stderr +++ b/tests/codegen/fail/union/attr_wrong_item.stderr @@ -1,5 +1,5 @@ error: #[graphql_union] attribute is applicable to trait definitions only - --> $DIR/attr_wrong_item.rs:3:1 + --> fail/union/attr_wrong_item.rs:3:1 | 3 | #[graphql_union] | ^^^^^^^^^^^^^^^^ diff --git a/tests/codegen/fail/union/derive_wrong_item.stderr b/tests/codegen/fail/union/derive_wrong_item.stderr index 379a5d69..85b57e2c 100644 --- a/tests/codegen/fail/union/derive_wrong_item.stderr +++ b/tests/codegen/fail/union/derive_wrong_item.stderr @@ -2,4 +2,4 @@ error: GraphQL union can only be derived for enums and structs --> fail/union/derive_wrong_item.rs:4:1 | 4 | union Character { id: i32 } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^ diff --git a/tests/codegen/fail/union/enum_external_resolver_fn_conflicts_with_variant_external_resolver_fn.stderr b/tests/codegen/fail/union/enum_external_resolver_fn_conflicts_with_variant_external_resolver_fn.stderr index 17b5ec8d..72ecac3a 100644 --- a/tests/codegen/fail/union/enum_external_resolver_fn_conflicts_with_variant_external_resolver_fn.stderr +++ b/tests/codegen/fail/union/enum_external_resolver_fn_conflicts_with_variant_external_resolver_fn.stderr @@ -1,7 +1,6 @@ error: GraphQL union variant `Human` already has external resolver function `resolve_fn1` declared on the enum + · note: https://spec.graphql.org/October2021#sec-Unions --> fail/union/enum_external_resolver_fn_conflicts_with_variant_external_resolver_fn.rs:6:15 | 6 | #[graphql(with = resolve_fn2)] | ^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Unions diff --git a/tests/codegen/fail/union/enum_name_double_underscored.stderr b/tests/codegen/fail/union/enum_name_double_underscored.stderr index 623186d8..2000b3f7 100644 --- a/tests/codegen/fail/union/enum_name_double_underscored.stderr +++ b/tests/codegen/fail/union/enum_name_double_underscored.stderr @@ -1,7 +1,6 @@ error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. + · note: https://spec.graphql.org/October2021#sec-Schema --> fail/union/enum_name_double_underscored.rs:4:6 | 4 | enum __Character { | ^^^^^^^^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Schema diff --git a/tests/codegen/fail/union/enum_no_fields.stderr b/tests/codegen/fail/union/enum_no_fields.stderr index 7e036c6a..7d868e33 100644 --- a/tests/codegen/fail/union/enum_no_fields.stderr +++ b/tests/codegen/fail/union/enum_no_fields.stderr @@ -1,7 +1,6 @@ error: GraphQL union expects at least one union variant + · note: https://spec.graphql.org/October2021#sec-Unions --> fail/union/enum_no_fields.rs:4:1 | 4 | enum Character {} - | ^^^^^^^^^^^^^^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Unions + | ^^^^ diff --git a/tests/codegen/fail/union/enum_non_object_variant.stderr b/tests/codegen/fail/union/enum_non_object_variant.stderr index c0356aa3..3e75bb5a 100644 --- a/tests/codegen/fail/union/enum_non_object_variant.stderr +++ b/tests/codegen/fail/union/enum_non_object_variant.stderr @@ -1,16 +1,17 @@ error[E0277]: the trait bound `Test: GraphQLObject<__S>` is not satisfied - --> fail/union/enum_non_object_variant.rs:11:10 - | -11 | Test(Test), - | ^^^^ the trait `GraphQLObject<__S>` is not implemented for `Test` - | - = help: the following other types implement trait `GraphQLObject`: - as GraphQLObject> - as GraphQLObject> - as GraphQLObject> - > - as GraphQLObject> - as GraphQLObject> - as GraphQLObject> - as GraphQLObject> - <&T as GraphQLObject> + --> fail/union/enum_non_object_variant.rs:9:10 + | +9 | #[derive(GraphQLUnion)] + | ^^^^^^^^^^^^ the trait `GraphQLObject<__S>` is not implemented for `Test` + | + = help: the following other types implement trait `GraphQLObject`: + as GraphQLObject> + as GraphQLObject> + as GraphQLObject> + > + as GraphQLObject> + as GraphQLObject> + as GraphQLObject> + as GraphQLObject> + <&T as GraphQLObject> + = note: this error originates in the derive macro `GraphQLUnion` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/codegen/fail/union/enum_same_type_pretty.stderr b/tests/codegen/fail/union/enum_same_type_pretty.stderr index 7b03ac3a..0e1eb7b2 100644 --- a/tests/codegen/fail/union/enum_same_type_pretty.stderr +++ b/tests/codegen/fail/union/enum_same_type_pretty.stderr @@ -1,10 +1,6 @@ error: GraphQL union must have a different type for each union variant + · note: https://spec.graphql.org/October2021#sec-Unions --> fail/union/enum_same_type_pretty.rs:4:1 | -4 | / enum Character { -5 | | A(u8), -6 | | B(u8), -7 | | } - | |_^ - | - = note: https://spec.graphql.org/October2021#sec-Unions +4 | enum Character { + | ^^^^ diff --git a/tests/codegen/fail/union/enum_wrong_variant_field.stderr b/tests/codegen/fail/union/enum_wrong_variant_field.stderr index 6ad79275..bd24c2d7 100644 --- a/tests/codegen/fail/union/enum_wrong_variant_field.stderr +++ b/tests/codegen/fail/union/enum_wrong_variant_field.stderr @@ -1,15 +1,13 @@ error: GraphQL union enum allows only unnamed variants with a single field, e.g. `Some(T)` + · note: https://spec.graphql.org/October2021#sec-Unions --> fail/union/enum_wrong_variant_field.rs:5:5 | 5 | A { human: Human }, | ^ - | - = note: https://spec.graphql.org/October2021#sec-Unions error: GraphQL union enum allows only unnamed variants with a single field, e.g. `Some(T)` + · note: https://spec.graphql.org/October2021#sec-Unions --> fail/union/enum_wrong_variant_field.rs:10:6 | 10 | A(Human, u8), | ^^^^^^^^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Unions diff --git a/tests/codegen/fail/union/struct_name_double_underscored.stderr b/tests/codegen/fail/union/struct_name_double_underscored.stderr index 84b3e3a9..e706d74f 100644 --- a/tests/codegen/fail/union/struct_name_double_underscored.stderr +++ b/tests/codegen/fail/union/struct_name_double_underscored.stderr @@ -1,7 +1,6 @@ error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. + · note: https://spec.graphql.org/October2021#sec-Schema --> fail/union/struct_name_double_underscored.rs:5:8 | 5 | struct __Character; | ^^^^^^^^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Schema diff --git a/tests/codegen/fail/union/struct_no_fields.stderr b/tests/codegen/fail/union/struct_no_fields.stderr index e5e79101..ef7c685b 100644 --- a/tests/codegen/fail/union/struct_no_fields.stderr +++ b/tests/codegen/fail/union/struct_no_fields.stderr @@ -1,7 +1,6 @@ error: GraphQL union expects at least one union variant + · note: https://spec.graphql.org/October2021#sec-Unions --> fail/union/struct_no_fields.rs:4:1 | 4 | struct Character; - | ^^^^^^^^^^^^^^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Unions + | ^^^^^^ diff --git a/tests/codegen/fail/union/struct_non_object_variant.stderr b/tests/codegen/fail/union/struct_non_object_variant.stderr index 934344c6..ebbb6a18 100644 --- a/tests/codegen/fail/union/struct_non_object_variant.stderr +++ b/tests/codegen/fail/union/struct_non_object_variant.stderr @@ -1,16 +1,17 @@ error[E0277]: the trait bound `Test: GraphQLObject<__S>` is not satisfied - --> fail/union/struct_non_object_variant.rs:10:14 - | -10 | #[graphql(on Test = Character::a)] - | ^^^^ the trait `GraphQLObject<__S>` is not implemented for `Test` - | - = help: the following other types implement trait `GraphQLObject`: - as GraphQLObject> - as GraphQLObject> - as GraphQLObject> - > - as GraphQLObject> - as GraphQLObject> - as GraphQLObject> - as GraphQLObject> - <&T as GraphQLObject> + --> fail/union/struct_non_object_variant.rs:9:10 + | +9 | #[derive(GraphQLUnion)] + | ^^^^^^^^^^^^ the trait `GraphQLObject<__S>` is not implemented for `Test` + | + = help: the following other types implement trait `GraphQLObject`: + as GraphQLObject> + as GraphQLObject> + as GraphQLObject> + > + as GraphQLObject> + as GraphQLObject> + as GraphQLObject> + as GraphQLObject> + <&T as GraphQLObject> + = note: this error originates in the derive macro `GraphQLUnion` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/codegen/fail/union/struct_same_type_pretty.stderr b/tests/codegen/fail/union/struct_same_type_pretty.stderr index 9e3152bd..770fe720 100644 --- a/tests/codegen/fail/union/struct_same_type_pretty.stderr +++ b/tests/codegen/fail/union/struct_same_type_pretty.stderr @@ -1,5 +1,5 @@ error: duplicated attribute argument found - --> $DIR/struct_same_type_pretty.rs:5:14 + --> fail/union/struct_same_type_pretty.rs:5:14 | 5 | #[graphql(on i32 = Character::b)] | ^^^ diff --git a/tests/codegen/fail/union/trait_method_conflicts_with_external_resolver_fn.stderr b/tests/codegen/fail/union/trait_method_conflicts_with_external_resolver_fn.stderr index c098337e..09edeb9f 100644 --- a/tests/codegen/fail/union/trait_method_conflicts_with_external_resolver_fn.stderr +++ b/tests/codegen/fail/union/trait_method_conflicts_with_external_resolver_fn.stderr @@ -1,8 +1,7 @@ error: GraphQL union trait method `a` conflicts with the external resolver function `some_fn` declared on the trait to resolve the variant type `Human` + · note: https://spec.graphql.org/October2021#sec-Unions + · note: use `#[graphql(ignore)]` attribute to ignore this trait method for union variants resolution --> fail/union/trait_method_conflicts_with_external_resolver_fn.rs:5:5 | 5 | fn a(&self) -> Option<&Human>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Unions - = note: use `#[graphql(ignore)]` attribute to ignore this trait method for union variants resolution + | ^^ diff --git a/tests/codegen/fail/union/trait_name_double_underscored.stderr b/tests/codegen/fail/union/trait_name_double_underscored.stderr index afb1f11e..04c8e03c 100644 --- a/tests/codegen/fail/union/trait_name_double_underscored.stderr +++ b/tests/codegen/fail/union/trait_name_double_underscored.stderr @@ -1,7 +1,6 @@ error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. + · note: https://spec.graphql.org/October2021#sec-Schema --> fail/union/trait_name_double_underscored.rs:4:7 | 4 | trait __Character { | ^^^^^^^^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Schema diff --git a/tests/codegen/fail/union/trait_no_fields.stderr b/tests/codegen/fail/union/trait_no_fields.stderr index c2f032da..6823de5f 100644 --- a/tests/codegen/fail/union/trait_no_fields.stderr +++ b/tests/codegen/fail/union/trait_no_fields.stderr @@ -1,7 +1,6 @@ error: GraphQL union expects at least one union variant + · note: https://spec.graphql.org/October2021#sec-Unions --> fail/union/trait_no_fields.rs:4:1 | 4 | trait Character {} - | ^^^^^^^^^^^^^^^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Unions + | ^^^^^ diff --git a/tests/codegen/fail/union/trait_non_object_variant.stderr b/tests/codegen/fail/union/trait_non_object_variant.stderr index 60214759..6ff1aeb9 100644 --- a/tests/codegen/fail/union/trait_non_object_variant.stderr +++ b/tests/codegen/fail/union/trait_non_object_variant.stderr @@ -1,16 +1,17 @@ error[E0277]: the trait bound `Test: GraphQLObject<__S>` is not satisfied - --> fail/union/trait_non_object_variant.rs:11:28 - | -11 | fn a(&self) -> Option<&Test>; - | ^^^^ the trait `GraphQLObject<__S>` is not implemented for `Test` - | - = help: the following other types implement trait `GraphQLObject`: - as GraphQLObject> - as GraphQLObject> - as GraphQLObject> - > - as GraphQLObject> - as GraphQLObject> - as GraphQLObject> - as GraphQLObject> - <&T as GraphQLObject> + --> fail/union/trait_non_object_variant.rs:9:1 + | +9 | #[graphql_union] + | ^^^^^^^^^^^^^^^^ the trait `GraphQLObject<__S>` is not implemented for `Test` + | + = help: the following other types implement trait `GraphQLObject`: + as GraphQLObject> + as GraphQLObject> + as GraphQLObject> + > + as GraphQLObject> + as GraphQLObject> + as GraphQLObject> + as GraphQLObject> + <&T as GraphQLObject> + = note: this error originates in the attribute macro `graphql_union` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/codegen/fail/union/trait_same_type_pretty.stderr b/tests/codegen/fail/union/trait_same_type_pretty.stderr index 116a7113..a659bcf7 100644 --- a/tests/codegen/fail/union/trait_same_type_pretty.stderr +++ b/tests/codegen/fail/union/trait_same_type_pretty.stderr @@ -1,10 +1,6 @@ error: GraphQL union must have a different type for each union variant + · note: https://spec.graphql.org/October2021#sec-Unions --> fail/union/trait_same_type_pretty.rs:4:1 | -4 | / trait Character { -5 | | fn a(&self) -> Option<&u8>; -6 | | fn b(&self) -> Option<&u8>; -7 | | } - | |_^ - | - = note: https://spec.graphql.org/October2021#sec-Unions +4 | trait Character { + | ^^^^^ diff --git a/tests/codegen/fail/union/trait_with_attr_on_method.stderr b/tests/codegen/fail/union/trait_with_attr_on_method.stderr index 6e406214..9341e9bb 100644 --- a/tests/codegen/fail/union/trait_with_attr_on_method.stderr +++ b/tests/codegen/fail/union/trait_with_attr_on_method.stderr @@ -1,8 +1,7 @@ error: GraphQL union cannot use #[graphql(with = ...)] attribute on a trait method + · note: https://spec.graphql.org/October2021#sec-Unions + · note: instead use #[graphql(ignore)] on the method with #[graphql_union(on ... = ...)] on the trait itself --> fail/union/trait_with_attr_on_method.rs:5:15 | 5 | #[graphql(with = something)] | ^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Unions - = note: instead use #[graphql(ignore)] on the method with #[graphql_union(on ... = ...)] on the trait itself diff --git a/tests/codegen/fail/union/trait_wrong_method_input_args.stderr b/tests/codegen/fail/union/trait_wrong_method_input_args.stderr index 74c68596..24e7c528 100644 --- a/tests/codegen/fail/union/trait_wrong_method_input_args.stderr +++ b/tests/codegen/fail/union/trait_wrong_method_input_args.stderr @@ -1,7 +1,6 @@ error: GraphQL union expects trait method to accept `&self` only and, optionally, `&Context` + · note: https://spec.graphql.org/October2021#sec-Unions --> fail/union/trait_wrong_method_input_args.rs:5:10 | 5 | fn a(&self, ctx: &(), rand: u8) -> Option<&Human>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Unions + | ^ diff --git a/tests/codegen/fail/union/trait_wrong_method_return_type.stderr b/tests/codegen/fail/union/trait_wrong_method_return_type.stderr index 1594d53a..42545c43 100644 --- a/tests/codegen/fail/union/trait_wrong_method_return_type.stderr +++ b/tests/codegen/fail/union/trait_wrong_method_return_type.stderr @@ -1,7 +1,6 @@ error: GraphQL union expects trait method return type to be `Option<&VariantType>` only + · note: https://spec.graphql.org/October2021#sec-Unions --> fail/union/trait_wrong_method_return_type.rs:5:20 | 5 | fn a(&self) -> &Human; - | ^^^^^^ - | - = note: https://spec.graphql.org/October2021#sec-Unions + | ^ diff --git a/tests/codegen/src/lib.rs b/tests/codegen/src/lib.rs index abdcf203..d8869c30 100644 --- a/tests/codegen/src/lib.rs +++ b/tests/codegen/src/lib.rs @@ -1,7 +1,7 @@ // TODO: [Object] Type Validation: §4 (interfaces) for objects // TODO: [Non-Null] §1 A Non‐Null type must not wrap another Non‐Null type. -#[rustversion::nightly] +#[rustversion::stable] #[test] fn test_failing_compilation() { let t = trybuild::TestCases::new();