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.
This commit is contained in:
Sergio Benitez 2024-05-02 15:40:42 -07:00
parent 7b17de6699
commit fd2094c5f3
8 changed files with 263 additions and 125 deletions

View File

@ -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),

View File

@ -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<syn::WherePredicate, syn::Token![,]>;
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<F>(fields: Fields<'_>, map_f: F) -> Result<TokenStream>
where F: Fn(&syn::Type, &syn::Expr) -> TokenStream
@ -32,8 +41,8 @@ fn fields_map<F>(fields: Fields<'_>, map_f: F) -> Result<TokenStream>
}
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() =>

View File

@ -991,3 +991,50 @@ struct Q<T>(T);
// This is here to ensure we don't warn, which we can't test with trybuild.
#[derive(FromForm)]
pub struct JsonTokenBad<T>(Q<T>);
#[test]
fn range() {
use std::ops::{Range, RangeFrom, RangeTo, RangeToInclusive};
let range: Range<usize> = strict("start=1&end=2").unwrap();
assert_eq!(range, Range { start: 1, end: 2 });
let range: Range<isize> = strict_encoded("start=-1&end=2").unwrap();
assert_eq!(range, Range { start: -1, end: 2 });
let range: Range<isize> = strict("start=-1&end=-95").unwrap();
assert_eq!(range, Range { start: -1, end: -95 });
let range: Range<isize> = strict_encoded("start=-1&end=-95").unwrap();
assert_eq!(range, Range { start: -1, end: -95 });
let range: RangeFrom<char> = strict("start=a").unwrap();
assert_eq!(range, RangeFrom { start: 'a' });
let range: RangeTo<char> = strict("end=z").unwrap();
assert_eq!(range, RangeTo { end: 'z' });
let range: RangeToInclusive<u8> = 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<Range<usize>> = 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<TodoTask> = 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, },
});
}

View File

@ -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<T>`:
<bool as From<format_description::parse::format_item::HourBase>>
@ -533,3 +552,4 @@ error[E0277]: the trait bound `bool: From<&str>` is not satisfied
<bool as From<format_description::parse::format_item::WeekdayOneIndexed>>
<bool as From<format_description::parse::format_item::YearBase>>
= note: required for `&str` to implement `Into<bool>`
= note: this error originates in the derive macro `FromForm` (in Nightly builds, run with -Z macro-backtrace for more info)

View File

@ -20,7 +20,12 @@ 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`
| ^-------
| |
| __________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`
@ -67,7 +74,12 @@ error[E0277]: the trait bound `Foo<usize>: 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<usize>`, which is required by `_::FromFormGeneratedContext<'r>: std::marker::Send`
| ^-------
| |
| __________in this derive macro expansion
| |
13 | | struct Other {
| |____________^ the trait `FromFormField<'_>` is not implemented for `Foo<usize>`, 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<usize>: 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>>
<Arc<T> as FromForm<'v>>
<BTreeMap<K, V> as FromForm<'v>>
<BadType3 as FromForm<'r>>
<Contextual<'v, T> as FromForm<'v>>
<HashMap<K, V> as FromForm<'v>>
<Lenient<T> as FromForm<'v>>
<Other 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-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<Cow<'v, str>>
Capped<TempFile<'v>>
Capped<std::string::String>
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<usize>: 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<usize>: FromFormField<'_>` is not satisfied
= note: required for `Foo<usize>` 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<usize>: FromFormField<'_>` is not satisfied
--> tests/ui-fail-nightly/from_form_type_errors.rs:14:5
error[E0277]: the trait bound `Foo<usize>: FromForm<'r>` is not satisfied
--> tests/ui-fail-nightly/from_form_type_errors.rs:14:12
|
14 | field: Foo<usize>,
| ^^^^^^^^^^^^^^^^^ the trait `FromFormField<'_>` is not implemented for `Foo<usize>`, which is required by `Foo<usize>: FromForm<'r>`
| ^^^^^^^^^^ the trait `FromFormField<'_>` is not implemented for `Foo<usize>`, which is required by `Foo<usize>: FromForm<'r>`
|
= help: the following other types implement trait `FromForm<'r>`:
<(A, B) as FromForm<'v>>
<Arc<T> as FromForm<'v>>
<BTreeMap<K, V> as FromForm<'v>>
<BadType3 as FromForm<'r>>
<Contextual<'v, T> as FromForm<'v>>
<HashMap<K, V> as FromForm<'v>>
<Lenient<T> as FromForm<'v>>
<Other as FromForm<'r>>
and $N others
= note: required for `Foo<usize>` to implement `FromForm<'r>`
error[E0277]: the trait bound `Foo<usize>: 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<usize>,
| ^^^^^^^^^^ the trait `FromFormField<'_>` is not implemented for `Foo<usize>`, which is required by `Foo<usize>: FromForm<'r>`
|
= help: the following other types implement trait `FromFormField<'v>`:
&'v [u8]
@ -187,25 +222,4 @@ error[E0277]: the trait bound `Foo<usize>: FromFormField<'_>` is not satisfied
Cow<'v, str>
and $N others
= note: required for `Foo<usize>` to implement `FromForm<'r>`
error[E0277]: the trait bound `Foo<usize>: FromFormField<'r>` is not satisfied
--> tests/ui-fail-nightly/from_form_type_errors.rs:14:12
|
14 | field: Foo<usize>,
| ^^^^^^^^^^ the trait `FromFormField<'r>` is not implemented for `Foo<usize>`
|
= help: the following other types implement trait `FromFormField<'v>`:
&'v [u8]
&'v str
Capped<&'v [u8]>
Capped<&'v str>
Capped<Cow<'v, str>>
Capped<TempFile<'v>>
Capped<std::string::String>
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)

View File

@ -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<T>`:
<bool as From<format_description::parse::format_item::HourBase>>
@ -571,3 +596,4 @@ error[E0277]: the trait bound `bool: From<&str>` is not satisfied
<bool as From<format_description::parse::format_item::WeekdayOneIndexed>>
<bool as From<format_description::parse::format_item::YearBase>>
= note: required for `&str` to implement `Into<bool>`
= note: this error originates in the derive macro `FromForm` (in Nightly builds, run with -Z macro-backtrace for more info)

View File

@ -6,13 +6,13 @@ 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>`
@ -20,22 +20,29 @@ 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`
| ^-------
| |
| __________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,13 +60,13 @@ error[E0277]: the trait bound `Foo<usize>: 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<usize>` to implement `FromForm<'r>`
@ -67,22 +74,29 @@ error[E0277]: the trait bound `Foo<usize>: 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<usize>`, which is required by `_::FromFormGeneratedContext<'r>: std::marker::Send`
| ^-------
| |
| __________in this derive macro expansion
| |
13 | | struct Other {
| |____________^ the trait `FromFormField<'_>` is not implemented for `Foo<usize>`, 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<usize>` 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>`:
<BadType3 as FromForm<'r>>
<Other as FromForm<'r>>
<HashMap<K, V> as FromForm<'v>>
<BTreeMap<K, V> as FromForm<'v>>
<Arc<T> as FromForm<'v>>
<form::from_form::_::proxy::Range<T> as FromForm<'r>>
<form::from_form::_::proxy::RangeFrom<T> as FromForm<'r>>
<form::from_form::_::proxy::RangeTo<T> 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<usize>: 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<usize>: 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<usize>` 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<usize>: FromFormField<'_>` is not satisfied
--> tests/ui-fail-stable/from_form_type_errors.rs:14:5
|
14 | field: Foo<usize>,
| ^^^^^^^^^^^^^^^^^ the trait `FromFormField<'_>` is not implemented for `Foo<usize>`, which is required by `Foo<usize>: 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<usize>` to implement `FromForm<'r>`
error[E0277]: the trait bound `Foo<usize>: FromFormField<'r>` is not satisfied
error[E0277]: the trait bound `Foo<usize>: FromForm<'r>` is not satisfied
--> tests/ui-fail-stable/from_form_type_errors.rs:14:12
|
14 | field: Foo<usize>,
| ^^^^^^^^^^ the trait `FromFormField<'r>` is not implemented for `Foo<usize>`
| ^^^^^^^^^^ the trait `FromFormField<'_>` is not implemented for `Foo<usize>`, which is required by `Foo<usize>: FromForm<'r>`
|
= help: the following other types implement trait `FromForm<'r>`:
<BadType3 as FromForm<'r>>
<Other as FromForm<'r>>
<HashMap<K, V> as FromForm<'v>>
<BTreeMap<K, V> as FromForm<'v>>
<Arc<T> as FromForm<'v>>
<form::from_form::_::proxy::Range<T> as FromForm<'r>>
<form::from_form::_::proxy::RangeFrom<T> as FromForm<'r>>
<form::from_form::_::proxy::RangeTo<T> as FromForm<'r>>
and $N others
= note: required for `Foo<usize>` to implement `FromForm<'r>`
error[E0277]: the trait bound `Foo<usize>: 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<usize>,
| ^^^^^^^^^^ the trait `FromFormField<'_>` is not implemented for `Foo<usize>`, which is required by `Foo<usize>: 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<usize>` to implement `FromForm<'r>`
= note: this error originates in the derive macro `FromForm` (in Nightly builds, run with -Z macro-backtrace for more info)

View File

@ -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<'_>`