From fd2094c5f36e1828694fefc4c506746639dff2df Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Thu, 2 May 2024 15:40:42 -0700 Subject: [PATCH] Use call site hygiene in FromForm derive. This commit changes the `FromForm` derive codegen so that it consistently emits tokens with call site hygiene. This allows `FromForm` derives to be emitted my macros more reliably. --- core/codegen/src/derive/form_field.rs | 8 + core/codegen/src/derive/from_form.rs | 19 ++- core/codegen/tests/from_form.rs | 47 ++++++ .../tests/ui-fail-nightly/from_form.stderr | 22 ++- .../from_form_type_errors.stderr | 122 +++++++++------- .../tests/ui-fail-stable/from_form.stderr | 28 +++- .../from_form_type_errors.stderr | 138 ++++++++++-------- .../ui-fail-stable/route-type-errors.stderr | 4 +- 8 files changed, 263 insertions(+), 125 deletions(-) diff --git a/core/codegen/src/derive/form_field.rs b/core/codegen/src/derive/form_field.rs index 60688e5e..ac3119d6 100644 --- a/core/codegen/src/derive/form_field.rs +++ b/core/codegen/src/derive/form_field.rs @@ -9,6 +9,14 @@ use quote::{ToTokens, TokenStreamExt}; use crate::syn_ext::IdentExt; use crate::name::Name; +macro_rules! quote_spanned { + ($span:expr => $($token:tt)*) => ( + quote::quote_spanned!( + proc_macro2::Span::call_site().located_at($span) => $($token)* + ) + ) +} + #[derive(Debug)] pub enum FieldName { Cased(Name), diff --git a/core/codegen/src/derive/from_form.rs b/core/codegen/src/derive/from_form.rs index f1ef4f50..8303b8fd 100644 --- a/core/codegen/src/derive/from_form.rs +++ b/core/codegen/src/derive/from_form.rs @@ -4,11 +4,20 @@ use syn::parse::Parser; use devise::*; use crate::exports::*; -use crate::derive::form_field::{*, FieldName::*}; +use crate::derive::form_field::FieldName::*; +use crate::derive::form_field::{FieldExt, default, first_duplicate, validators}; use crate::syn_ext::{GenericsExt as _, TypeExt as _}; type WherePredicates = syn::punctuated::Punctuated; +macro_rules! quote_spanned { + ($span:expr => $($token:tt)*) => ( + quote::quote_spanned!( + proc_macro2::Span::call_site().located_at($span) => $($token)* + ) + ) +} + // F: fn(field_ty: Ty, field_context: Expr) fn fields_map(fields: Fields<'_>, map_f: F) -> Result where F: Fn(&syn::Type, &syn::Expr) -> TokenStream @@ -32,8 +41,8 @@ fn fields_map(fields: Fields<'_>, map_f: F) -> Result } matchers.extend(field.field_names()?.into_iter().map(|f| match f { - Cased(name) => quote!(#name => { #push }), - Uncased(name) => quote!(__n if __n.as_uncased() == #name => { #push }), + Cased(f) => quote_spanned!(ty.span() => #f => { #push }), + Uncased(f) => quote_spanned!(ty.span() => __n if __n.as_uncased() == #f => { #push }), })); } @@ -192,7 +201,7 @@ pub fn derive_from_form(input: proc_macro::TokenStream) -> TokenStream { let (ctxt_ty, gen) = context_type(input)?; let (_, ty_gen, _) = gen.split_for_impl(); let output = mapper::input_default(mapper, input)?; - Ok(quote! { + Ok(quote_spanned! { ctxt_ty.span() => async fn push_data( __c: &mut #ctxt_ty #ty_gen, __f: #_form::DataField<'r, '_> @@ -234,7 +243,7 @@ pub fn derive_from_form(input: proc_macro::TokenStream) -> TokenStream { let ident = fields.iter().map(|f| f.context_ident()); let builder = fields.builder(|f| { let ident = f.context_ident(); - quote!(#ident.unwrap()) + quote_spanned!(ident.span() => #ident.unwrap()) }); Ok(quote_spanned!(fields.span() => diff --git a/core/codegen/tests/from_form.rs b/core/codegen/tests/from_form.rs index 568840d1..bed73596 100644 --- a/core/codegen/tests/from_form.rs +++ b/core/codegen/tests/from_form.rs @@ -991,3 +991,50 @@ struct Q(T); // This is here to ensure we don't warn, which we can't test with trybuild. #[derive(FromForm)] pub struct JsonTokenBad(Q); + +#[test] +fn range() { + use std::ops::{Range, RangeFrom, RangeTo, RangeToInclusive}; + + let range: Range = strict("start=1&end=2").unwrap(); + assert_eq!(range, Range { start: 1, end: 2 }); + + let range: Range = strict_encoded("start=-1&end=2").unwrap(); + assert_eq!(range, Range { start: -1, end: 2 }); + + let range: Range = strict("start=-1&end=-95").unwrap(); + assert_eq!(range, Range { start: -1, end: -95 }); + + let range: Range = strict_encoded("start=-1&end=-95").unwrap(); + assert_eq!(range, Range { start: -1, end: -95 }); + + let range: RangeFrom = strict("start=a").unwrap(); + assert_eq!(range, RangeFrom { start: 'a' }); + + let range: RangeTo = strict("end=z").unwrap(); + assert_eq!(range, RangeTo { end: 'z' }); + + let range: RangeToInclusive = strict("end=255").unwrap(); + assert_eq!(range, RangeToInclusive { end: 255 }); + + // now with compound, non-Step values + let form_string = &["start.start=0", "start.end=1", "end.start=1", "end.end=2"].join("&"); + let range: Range> = strict(&form_string).unwrap(); + assert_eq!(range, Range { + start: Range { start: 0, end : 1}, + end: Range { start: 1, end : 2 } + }); + + let form_string = &[ + "start.description=some%20task", + "start.completed=false", + "end.description=yet%20more%20work", + "end.completed=true", + ].join("&"); + + let range: Range = strict_encoded(form_string).unwrap(); + assert_eq!(range, Range { + start: TodoTask { description: "some task".into(), completed: false, }, + end: TodoTask { description: "yet more work".into(), completed: true, }, + }); +} diff --git a/core/codegen/tests/ui-fail-nightly/from_form.stderr b/core/codegen/tests/ui-fail-nightly/from_form.stderr index 0a40c37d..0432aedc 100644 --- a/core/codegen/tests/ui-fail-nightly/from_form.stderr +++ b/core/codegen/tests/ui-fail-nightly/from_form.stderr @@ -379,6 +379,9 @@ note: error occurred while deriving `FromForm` error: duplicate default field expression --> tests/ui-fail-nightly/from_form.rs:184:23 | +181 | #[derive(FromForm)] + | -------- in this derive macro expansion +... 184 | #[field(default = 2)] | ^ | @@ -393,6 +396,9 @@ note: error occurred while deriving `FromForm` error: duplicate default expressions --> tests/ui-fail-nightly/from_form.rs:190:23 | +188 | #[derive(FromForm)] + | -------- in this derive macro expansion +189 | struct Default3 { 190 | #[field(default = 1, default_with = None)] | ^ | @@ -412,6 +418,9 @@ note: error occurred while deriving `FromForm` error: duplicate default expressions --> tests/ui-fail-nightly/from_form.rs:197:23 | +194 | #[derive(FromForm)] + | -------- in this derive macro expansion +... 197 | #[field(default = 1)] | ^ | @@ -487,6 +496,9 @@ error[E0308]: mismatched types help: the type constructed contains `{integer}` due to the type of the argument passed --> tests/ui-fail-nightly/from_form.rs:171:23 | +169 | #[derive(FromForm)] + | -------- in this derive macro expansion +170 | struct Default0 { 171 | #[field(default = 123)] | ^^^ this argument influences the type of `Some` note: tuple variant defined here @@ -494,6 +506,7 @@ note: tuple variant defined here | | Some(#[stable(feature = "rust1", since = "1.0.0")] T), | ^^^^ + = note: this error originates in the derive macro `FromForm` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0308]: mismatched types --> tests/ui-fail-nightly/from_form.rs:203:33 @@ -520,8 +533,14 @@ note: tuple variant defined here error[E0277]: the trait bound `bool: From<&str>` is not satisfied --> tests/ui-fail-nightly/from_form.rs:209:23 | +207 | #[derive(FromForm)] + | -------- in this derive macro expansion +208 | struct Default6 { 209 | #[field(default = "no conversion")] - | ^^^^^^^^^^^^^^^ the trait `From<&str>` is not implemented for `bool`, which is required by `&str: Into<_>` + | ^^^^^^^^^^^^^^^ + | | + | the trait `From<&str>` is not implemented for `bool`, which is required by `&str: Into<_>` + | this tail expression is of type `&str` | = help: the following other types implement trait `From`: > @@ -533,3 +552,4 @@ error[E0277]: the trait bound `bool: From<&str>` is not satisfied > > = note: required for `&str` to implement `Into` + = note: this error originates in the derive macro `FromForm` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/core/codegen/tests/ui-fail-nightly/from_form_type_errors.stderr b/core/codegen/tests/ui-fail-nightly/from_form_type_errors.stderr index b360fe56..4775da11 100644 --- a/core/codegen/tests/ui-fail-nightly/from_form_type_errors.stderr +++ b/core/codegen/tests/ui-fail-nightly/from_form_type_errors.stderr @@ -19,8 +19,13 @@ error[E0277]: the trait bound `Unknown: FromFormField<'_>` is not satisfied error[E0277]: the trait bound `Unknown: FromFormField<'_>` is not satisfied --> tests/ui-fail-nightly/from_form_type_errors.rs:5:10 | -5 | #[derive(FromForm)] - | ^^^^^^^^ the trait `FromFormField<'_>` is not implemented for `Unknown`, which is required by `_::FromFormGeneratedContext<'r>: std::marker::Send` +5 | #[derive(FromForm)] + | ^------- + | | + | __________in this derive macro expansion + | | +6 | | struct BadType3 { + | |_______________^ the trait `FromFormField<'_>` is not implemented for `Unknown`, which is required by `_::FromFormGeneratedContext<'r>: std::marker::Send` | = help: the following other types implement trait `FromFormField<'v>`: &'v [u8] @@ -36,6 +41,8 @@ error[E0277]: the trait bound `Unknown: FromFormField<'_>` is not satisfied note: required because it appears within the type `_::FromFormGeneratedContext<'r>` --> tests/ui-fail-nightly/from_form_type_errors.rs:6:8 | +5 | #[derive(FromForm)] + | -------- in this derive macro expansion 6 | struct BadType3 { | ^^^^^^^^ note: required by a bound in `rocket::form::FromForm::Context` @@ -66,8 +73,13 @@ error[E0277]: the trait bound `Foo: FromFormField<'_>` is not satisfied error[E0277]: the trait bound `Foo: FromFormField<'_>` is not satisfied --> tests/ui-fail-nightly/from_form_type_errors.rs:12:10 | -12 | #[derive(FromForm)] - | ^^^^^^^^ the trait `FromFormField<'_>` is not implemented for `Foo`, which is required by `_::FromFormGeneratedContext<'r>: std::marker::Send` +12 | #[derive(FromForm)] + | ^------- + | | + | __________in this derive macro expansion + | | +13 | | struct Other { + | |____________^ the trait `FromFormField<'_>` is not implemented for `Foo`, which is required by `_::FromFormGeneratedContext<'r>: std::marker::Send` | = help: the following other types implement trait `FromFormField<'v>`: &'v [u8] @@ -83,6 +95,8 @@ error[E0277]: the trait bound `Foo: FromFormField<'_>` is not satisfied note: required because it appears within the type `_::FromFormGeneratedContext<'r>` --> tests/ui-fail-nightly/from_form_type_errors.rs:13:8 | +12 | #[derive(FromForm)] + | -------- in this derive macro expansion 13 | struct Other { | ^^^^^ note: required by a bound in `rocket::form::FromForm::Context` @@ -111,11 +125,32 @@ error[E0277]: the trait bound `Unknown: FromFormField<'_>` is not satisfied = note: required for `Unknown` to implement `FromForm<'r>` = note: this error originates in the derive macro `FromForm` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `Unknown: FromFormField<'_>` is not satisfied - --> tests/ui-fail-nightly/from_form_type_errors.rs:7:5 +error[E0277]: the trait bound `Unknown: FromForm<'r>` is not satisfied + --> tests/ui-fail-nightly/from_form_type_errors.rs:7:12 | 7 | field: Unknown, - | ^^^^^^^^^^^^^^ the trait `FromFormField<'_>` is not implemented for `Unknown`, which is required by `Unknown: FromForm<'r>` + | ^^^^^^^ the trait `FromFormField<'_>` is not implemented for `Unknown`, which is required by `Unknown: FromForm<'r>` + | + = help: the following other types implement trait `FromForm<'r>`: + <(A, B) as FromForm<'v>> + as FromForm<'v>> + as FromForm<'v>> + > + as FromForm<'v>> + as FromForm<'v>> + as FromForm<'v>> + > + and $N others + = note: required for `Unknown` to implement `FromForm<'r>` + +error[E0277]: the trait bound `Unknown: FromFormField<'_>` is not satisfied + --> tests/ui-fail-nightly/from_form_type_errors.rs:7:12 + | +5 | #[derive(FromForm)] + | -------- in this derive macro expansion +6 | struct BadType3 { +7 | field: Unknown, + | ^^^^^^^ the trait `FromFormField<'_>` is not implemented for `Unknown`, which is required by `Unknown: FromForm<'r>` | = help: the following other types implement trait `FromFormField<'v>`: &'v [u8] @@ -128,28 +163,7 @@ error[E0277]: the trait bound `Unknown: FromFormField<'_>` is not satisfied Cow<'v, str> and $N others = note: required for `Unknown` to implement `FromForm<'r>` - -error[E0277]: the trait bound `Unknown: FromFormField<'r>` is not satisfied - --> tests/ui-fail-nightly/from_form_type_errors.rs:7:12 - | -7 | field: Unknown, - | ^^^^^^^ the trait `FromFormField<'r>` is not implemented for `Unknown` - | - = help: the following other types implement trait `FromFormField<'v>`: - &'v [u8] - &'v str - Capped<&'v [u8]> - Capped<&'v str> - Capped> - Capped> - Capped - Cow<'v, str> - and $N others -note: required by a bound in `FromFieldContext` - --> $WORKSPACE/core/lib/src/form/from_form_field.rs - | - | pub struct FromFieldContext<'v, T: FromFormField<'v>> { - | ^^^^^^^^^^^^^^^^^ required by this bound in `FromFieldContext` + = note: this error originates in the derive macro `FromForm` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Foo: FromFormField<'_>` is not satisfied --> tests/ui-fail-nightly/from_form_type_errors.rs:12:10 @@ -170,11 +184,32 @@ error[E0277]: the trait bound `Foo: FromFormField<'_>` is not satisfied = note: required for `Foo` to implement `FromForm<'r>` = note: this error originates in the derive macro `FromForm` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `Foo: FromFormField<'_>` is not satisfied - --> tests/ui-fail-nightly/from_form_type_errors.rs:14:5 +error[E0277]: the trait bound `Foo: FromForm<'r>` is not satisfied + --> tests/ui-fail-nightly/from_form_type_errors.rs:14:12 | 14 | field: Foo, - | ^^^^^^^^^^^^^^^^^ the trait `FromFormField<'_>` is not implemented for `Foo`, which is required by `Foo: FromForm<'r>` + | ^^^^^^^^^^ the trait `FromFormField<'_>` is not implemented for `Foo`, which is required by `Foo: FromForm<'r>` + | + = help: the following other types implement trait `FromForm<'r>`: + <(A, B) as FromForm<'v>> + as FromForm<'v>> + as FromForm<'v>> + > + as FromForm<'v>> + as FromForm<'v>> + as FromForm<'v>> + > + and $N others + = note: required for `Foo` to implement `FromForm<'r>` + +error[E0277]: the trait bound `Foo: FromFormField<'_>` is not satisfied + --> tests/ui-fail-nightly/from_form_type_errors.rs:14:12 + | +12 | #[derive(FromForm)] + | -------- in this derive macro expansion +13 | struct Other { +14 | field: Foo, + | ^^^^^^^^^^ the trait `FromFormField<'_>` is not implemented for `Foo`, which is required by `Foo: FromForm<'r>` | = help: the following other types implement trait `FromFormField<'v>`: &'v [u8] @@ -187,25 +222,4 @@ error[E0277]: the trait bound `Foo: FromFormField<'_>` is not satisfied Cow<'v, str> and $N others = note: required for `Foo` to implement `FromForm<'r>` - -error[E0277]: the trait bound `Foo: FromFormField<'r>` is not satisfied - --> tests/ui-fail-nightly/from_form_type_errors.rs:14:12 - | -14 | field: Foo, - | ^^^^^^^^^^ the trait `FromFormField<'r>` is not implemented for `Foo` - | - = help: the following other types implement trait `FromFormField<'v>`: - &'v [u8] - &'v str - Capped<&'v [u8]> - Capped<&'v str> - Capped> - Capped> - Capped - Cow<'v, str> - and $N others -note: required by a bound in `FromFieldContext` - --> $WORKSPACE/core/lib/src/form/from_form_field.rs - | - | pub struct FromFieldContext<'v, T: FromFormField<'v>> { - | ^^^^^^^^^^^^^^^^^ required by this bound in `FromFieldContext` + = note: this error originates in the derive macro `FromForm` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/core/codegen/tests/ui-fail-stable/from_form.stderr b/core/codegen/tests/ui-fail-stable/from_form.stderr index b0d0addf..81a57843 100644 --- a/core/codegen/tests/ui-fail-stable/from_form.stderr +++ b/core/codegen/tests/ui-fail-stable/from_form.stderr @@ -413,8 +413,13 @@ error: duplicate default field expression = help: at most one `default` or `default_with` is allowed --> tests/ui-fail-stable/from_form.rs:184:23 | +181 | #[derive(FromForm)] + | -------- in this derive macro expansion +... 184 | #[field(default = 2)] | ^ + | + = note: this error originates in the derive macro `FromForm` (in Nightly builds, run with -Z macro-backtrace for more info) error: [note] error occurred while deriving `FromForm` --> tests/ui-fail-stable/from_form.rs:181:10 @@ -428,8 +433,13 @@ error: duplicate default expressions = help: only one of `default` or `default_with` must be used --> tests/ui-fail-stable/from_form.rs:190:23 | +188 | #[derive(FromForm)] + | -------- in this derive macro expansion +189 | struct Default3 { 190 | #[field(default = 1, default_with = None)] | ^ + | + = note: this error originates in the derive macro `FromForm` (in Nightly builds, run with -Z macro-backtrace for more info) error: [note] other default expression is here --> tests/ui-fail-stable/from_form.rs:190:41 @@ -449,8 +459,13 @@ error: duplicate default expressions = help: only one of `default` or `default_with` must be used --> tests/ui-fail-stable/from_form.rs:197:23 | +194 | #[derive(FromForm)] + | -------- in this derive macro expansion +... 197 | #[field(default = 1)] | ^ + | + = note: this error originates in the derive macro `FromForm` (in Nightly builds, run with -Z macro-backtrace for more info) error: [note] other default expression is here --> tests/ui-fail-stable/from_form.rs:196:28 @@ -525,6 +540,9 @@ error[E0308]: mismatched types help: the type constructed contains `{integer}` due to the type of the argument passed --> tests/ui-fail-stable/from_form.rs:171:23 | +169 | #[derive(FromForm)] + | -------- in this derive macro expansion +170 | struct Default0 { 171 | #[field(default = 123)] | ^^^ this argument influences the type of `Some` note: tuple variant defined here @@ -532,6 +550,7 @@ note: tuple variant defined here | | Some(#[stable(feature = "rust1", since = "1.0.0")] T), | ^^^^ + = note: this error originates in the derive macro `FromForm` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0308]: mismatched types --> tests/ui-fail-stable/from_form.rs:203:33 @@ -558,8 +577,14 @@ note: tuple variant defined here error[E0277]: the trait bound `bool: From<&str>` is not satisfied --> tests/ui-fail-stable/from_form.rs:209:23 | +207 | #[derive(FromForm)] + | -------- in this derive macro expansion +208 | struct Default6 { 209 | #[field(default = "no conversion")] - | ^^^^^^^^^^^^^^^ the trait `From<&str>` is not implemented for `bool`, which is required by `&str: Into<_>` + | ^^^^^^^^^^^^^^^ + | | + | the trait `From<&str>` is not implemented for `bool`, which is required by `&str: Into<_>` + | this tail expression is of type `&str` | = help: the following other types implement trait `From`: > @@ -571,3 +596,4 @@ error[E0277]: the trait bound `bool: From<&str>` is not satisfied > > = note: required for `&str` to implement `Into` + = note: this error originates in the derive macro `FromForm` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/core/codegen/tests/ui-fail-stable/from_form_type_errors.stderr b/core/codegen/tests/ui-fail-stable/from_form_type_errors.stderr index ad6ebb37..e41f7ecc 100644 --- a/core/codegen/tests/ui-fail-stable/from_form_type_errors.stderr +++ b/core/codegen/tests/ui-fail-stable/from_form_type_errors.stderr @@ -6,36 +6,43 @@ error[E0277]: the trait bound `Unknown: FromFormField<'_>` is not satisfied | = help: the following other types implement trait `FromFormField<'v>`: bool + char isize i8 i16 i32 i64 i128 - usize and $N others = note: required for `Unknown` to implement `FromForm<'r>` error[E0277]: the trait bound `Unknown: FromFormField<'_>` is not satisfied --> tests/ui-fail-stable/from_form_type_errors.rs:5:10 | -5 | #[derive(FromForm)] - | ^^^^^^^^ the trait `FromFormField<'_>` is not implemented for `Unknown`, which is required by `_::FromFormGeneratedContext<'r>: std::marker::Send` +5 | #[derive(FromForm)] + | ^------- + | | + | __________in this derive macro expansion + | | +6 | | struct BadType3 { + | |_______________^ the trait `FromFormField<'_>` is not implemented for `Unknown`, which is required by `_::FromFormGeneratedContext<'r>: std::marker::Send` | = help: the following other types implement trait `FromFormField<'v>`: bool + char isize i8 i16 i32 i64 i128 - usize and $N others = note: required for `Unknown` to implement `FromForm<'r>` note: required because it appears within the type `_::FromFormGeneratedContext<'r>` --> tests/ui-fail-stable/from_form_type_errors.rs:6:8 | +5 | #[derive(FromForm)] + | -------- in this derive macro expansion 6 | struct BadType3 { | ^^^^^^^^ note: required by a bound in `rocket::form::FromForm::Context` @@ -53,36 +60,43 @@ error[E0277]: the trait bound `Foo: FromFormField<'_>` is not satisfied | = help: the following other types implement trait `FromFormField<'v>`: bool + char isize i8 i16 i32 i64 i128 - usize and $N others = note: required for `Foo` to implement `FromForm<'r>` error[E0277]: the trait bound `Foo: FromFormField<'_>` is not satisfied --> tests/ui-fail-stable/from_form_type_errors.rs:12:10 | -12 | #[derive(FromForm)] - | ^^^^^^^^ the trait `FromFormField<'_>` is not implemented for `Foo`, which is required by `_::FromFormGeneratedContext<'r>: std::marker::Send` +12 | #[derive(FromForm)] + | ^------- + | | + | __________in this derive macro expansion + | | +13 | | struct Other { + | |____________^ the trait `FromFormField<'_>` is not implemented for `Foo`, which is required by `_::FromFormGeneratedContext<'r>: std::marker::Send` | = help: the following other types implement trait `FromFormField<'v>`: bool + char isize i8 i16 i32 i64 i128 - usize and $N others = note: required for `Foo` to implement `FromForm<'r>` note: required because it appears within the type `_::FromFormGeneratedContext<'r>` --> tests/ui-fail-stable/from_form_type_errors.rs:13:8 | +12 | #[derive(FromForm)] + | -------- in this derive macro expansion 13 | struct Other { | ^^^^^ note: required by a bound in `rocket::form::FromForm::Context` @@ -100,56 +114,56 @@ error[E0277]: the trait bound `Unknown: FromFormField<'_>` is not satisfied | = help: the following other types implement trait `FromFormField<'v>`: bool + char isize i8 i16 i32 i64 i128 - usize and $N others = note: required for `Unknown` to implement `FromForm<'r>` = note: this error originates in the derive macro `FromForm` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `Unknown: FromFormField<'_>` is not satisfied - --> tests/ui-fail-stable/from_form_type_errors.rs:7:5 - | -7 | field: Unknown, - | ^^^^^^^^^^^^^^ the trait `FromFormField<'_>` is not implemented for `Unknown`, which is required by `Unknown: FromForm<'r>` - | - = help: the following other types implement trait `FromFormField<'v>`: - bool - isize - i8 - i16 - i32 - i64 - i128 - usize - and $N others - = note: required for `Unknown` to implement `FromForm<'r>` - -error[E0277]: the trait bound `Unknown: FromFormField<'r>` is not satisfied +error[E0277]: the trait bound `Unknown: FromForm<'r>` is not satisfied --> tests/ui-fail-stable/from_form_type_errors.rs:7:12 | 7 | field: Unknown, - | ^^^^^^^ the trait `FromFormField<'r>` is not implemented for `Unknown` + | ^^^^^^^ the trait `FromFormField<'_>` is not implemented for `Unknown`, which is required by `Unknown: FromForm<'r>` + | + = help: the following other types implement trait `FromForm<'r>`: + > + > + as FromForm<'v>> + as FromForm<'v>> + as FromForm<'v>> + as FromForm<'r>> + as FromForm<'r>> + as FromForm<'r>> + and $N others + = note: required for `Unknown` to implement `FromForm<'r>` + +error[E0277]: the trait bound `Unknown: FromFormField<'_>` is not satisfied + --> tests/ui-fail-stable/from_form_type_errors.rs:7:12 + | +5 | #[derive(FromForm)] + | -------- in this derive macro expansion +6 | struct BadType3 { +7 | field: Unknown, + | ^^^^^^^ the trait `FromFormField<'_>` is not implemented for `Unknown`, which is required by `Unknown: FromForm<'r>` | = help: the following other types implement trait `FromFormField<'v>`: bool + char isize i8 i16 i32 i64 i128 - usize and $N others -note: required by a bound in `FromFieldContext` - --> $WORKSPACE/core/lib/src/form/from_form_field.rs - | - | pub struct FromFieldContext<'v, T: FromFormField<'v>> { - | ^^^^^^^^^^^^^^^^^ required by this bound in `FromFieldContext` + = note: required for `Unknown` to implement `FromForm<'r>` + = note: this error originates in the derive macro `FromForm` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Foo: FromFormField<'_>` is not satisfied --> tests/ui-fail-stable/from_form_type_errors.rs:12:10 @@ -159,53 +173,53 @@ error[E0277]: the trait bound `Foo: FromFormField<'_>` is not satisfied | = help: the following other types implement trait `FromFormField<'v>`: bool + char isize i8 i16 i32 i64 i128 - usize and $N others = note: required for `Foo` to implement `FromForm<'r>` = note: this error originates in the derive macro `FromForm` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `Foo: FromFormField<'_>` is not satisfied - --> tests/ui-fail-stable/from_form_type_errors.rs:14:5 - | -14 | field: Foo, - | ^^^^^^^^^^^^^^^^^ the trait `FromFormField<'_>` is not implemented for `Foo`, which is required by `Foo: FromForm<'r>` - | - = help: the following other types implement trait `FromFormField<'v>`: - bool - isize - i8 - i16 - i32 - i64 - i128 - usize - and $N others - = note: required for `Foo` to implement `FromForm<'r>` - -error[E0277]: the trait bound `Foo: FromFormField<'r>` is not satisfied +error[E0277]: the trait bound `Foo: FromForm<'r>` is not satisfied --> tests/ui-fail-stable/from_form_type_errors.rs:14:12 | 14 | field: Foo, - | ^^^^^^^^^^ the trait `FromFormField<'r>` is not implemented for `Foo` + | ^^^^^^^^^^ the trait `FromFormField<'_>` is not implemented for `Foo`, which is required by `Foo: FromForm<'r>` + | + = help: the following other types implement trait `FromForm<'r>`: + > + > + as FromForm<'v>> + as FromForm<'v>> + as FromForm<'v>> + as FromForm<'r>> + as FromForm<'r>> + as FromForm<'r>> + and $N others + = note: required for `Foo` to implement `FromForm<'r>` + +error[E0277]: the trait bound `Foo: FromFormField<'_>` is not satisfied + --> tests/ui-fail-stable/from_form_type_errors.rs:14:12 + | +12 | #[derive(FromForm)] + | -------- in this derive macro expansion +13 | struct Other { +14 | field: Foo, + | ^^^^^^^^^^ the trait `FromFormField<'_>` is not implemented for `Foo`, which is required by `Foo: FromForm<'r>` | = help: the following other types implement trait `FromFormField<'v>`: bool + char isize i8 i16 i32 i64 i128 - usize and $N others -note: required by a bound in `FromFieldContext` - --> $WORKSPACE/core/lib/src/form/from_form_field.rs - | - | pub struct FromFieldContext<'v, T: FromFormField<'v>> { - | ^^^^^^^^^^^^^^^^^ required by this bound in `FromFieldContext` + = note: required for `Foo` to implement `FromForm<'r>` + = note: this error originates in the derive macro `FromForm` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/core/codegen/tests/ui-fail-stable/route-type-errors.stderr b/core/codegen/tests/ui-fail-stable/route-type-errors.stderr index bebdea7c..e7fcb308 100644 --- a/core/codegen/tests/ui-fail-stable/route-type-errors.stderr +++ b/core/codegen/tests/ui-fail-stable/route-type-errors.stderr @@ -35,13 +35,13 @@ error[E0277]: the trait bound `Q: FromFormField<'_>` is not satisfied | = help: the following other types implement trait `FromFormField<'v>`: bool + char isize i8 i16 i32 i64 i128 - usize and $N others = note: required for `Q` to implement `FromForm<'_>` @@ -53,13 +53,13 @@ error[E0277]: the trait bound `Q: FromFormField<'_>` is not satisfied | = help: the following other types implement trait `FromFormField<'v>`: bool + char isize i8 i16 i32 i64 i128 - usize and $N others = note: required for `Q` to implement `FromForm<'_>`