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 e942011974
commit dfc118f279
8 changed files with 452 additions and 14 deletions

View File

@ -9,6 +9,14 @@ use quote::{ToTokens, TokenStreamExt};
use crate::syn_ext::IdentExt; use crate::syn_ext::IdentExt;
use crate::name::Name; 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)] #[derive(Debug)]
pub enum FieldName { pub enum FieldName {
Cased(Name), Cased(Name),

View File

@ -4,11 +4,20 @@ use syn::parse::Parser;
use devise::*; use devise::*;
use crate::exports::*; 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 _}; use crate::syn_ext::{GenericsExt as _, TypeExt as _};
type WherePredicates = syn::punctuated::Punctuated<syn::WherePredicate, syn::Token![,]>; 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) // F: fn(field_ty: Ty, field_context: Expr)
fn fields_map<F>(fields: Fields<'_>, map_f: F) -> Result<TokenStream> fn fields_map<F>(fields: Fields<'_>, map_f: F) -> Result<TokenStream>
where F: Fn(&syn::Type, &syn::Expr) -> 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 { matchers.extend(field.field_names()?.into_iter().map(|f| match f {
Cased(name) => quote!(#name => { #push }), Cased(f) => quote_spanned!(ty.span() => #f => { #push }),
Uncased(name) => quote!(__n if __n.as_uncased() == #name => { #push }), Uncased(f) => quote_spanned!(ty.span() => __n if __n.as_uncased() == #f => { #push }),
})); }));
} }
@ -195,7 +204,7 @@ pub fn derive_from_form(input: proc_macro::TokenStream) -> TokenStream {
let (ctxt_ty, gen) = context_type(input)?; let (ctxt_ty, gen) = context_type(input)?;
let (_, ty_gen, _) = gen.split_for_impl(); let (_, ty_gen, _) = gen.split_for_impl();
let output = mapper::input_default(mapper, input)?; let output = mapper::input_default(mapper, input)?;
Ok(quote! { Ok(quote_spanned! { ctxt_ty.span() =>
async fn push_data( async fn push_data(
__c: &mut #ctxt_ty #ty_gen, __c: &mut #ctxt_ty #ty_gen,
__f: #_form::DataField<'r, '_> __f: #_form::DataField<'r, '_>
@ -237,7 +246,7 @@ pub fn derive_from_form(input: proc_macro::TokenStream) -> TokenStream {
let ident = fields.iter().map(|f| f.context_ident()); let ident = fields.iter().map(|f| f.context_ident());
let builder = fields.builder(|f| { let builder = fields.builder(|f| {
let ident = f.context_ident(); let ident = f.context_ident();
quote!(#ident.unwrap()) quote_spanned!(ident.span() => #ident.unwrap())
}); });
Ok(quote_spanned!(fields.span() => 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. // This is here to ensure we don't warn, which we can't test with trybuild.
#[derive(FromForm)] #[derive(FromForm)]
pub struct JsonTokenBad<T>(Q<T>); 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 error: duplicate default field expression
--> tests/ui-fail-nightly/from_form.rs:184:23 --> tests/ui-fail-nightly/from_form.rs:184:23
| |
181 | #[derive(FromForm)]
| -------- in this derive macro expansion
...
184 | #[field(default = 2)] 184 | #[field(default = 2)]
| ^ | ^
| |
@ -393,6 +396,9 @@ note: error occurred while deriving `FromForm`
error: duplicate default expressions error: duplicate default expressions
--> tests/ui-fail-nightly/from_form.rs:190:23 --> 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)] 190 | #[field(default = 1, default_with = None)]
| ^ | ^
| |
@ -412,6 +418,9 @@ note: error occurred while deriving `FromForm`
error: duplicate default expressions error: duplicate default expressions
--> tests/ui-fail-nightly/from_form.rs:197:23 --> tests/ui-fail-nightly/from_form.rs:197:23
| |
194 | #[derive(FromForm)]
| -------- in this derive macro expansion
...
197 | #[field(default = 1)] 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 help: the type constructed contains `{integer}` due to the type of the argument passed
--> tests/ui-fail-nightly/from_form.rs:171:23 --> tests/ui-fail-nightly/from_form.rs:171:23
| |
169 | #[derive(FromForm)]
| -------- in this derive macro expansion
170 | struct Default0 {
171 | #[field(default = 123)] 171 | #[field(default = 123)]
| ^^^ this argument influences the type of `Some` | ^^^ this argument influences the type of `Some`
note: tuple variant defined here note: tuple variant defined here
@ -494,6 +506,7 @@ note: tuple variant defined here
| |
| Some(#[stable(feature = "rust1", since = "1.0.0")] T), | 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 error[E0308]: mismatched types
--> tests/ui-fail-nightly/from_form.rs:203:33 --> 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 error[E0277]: the trait bound `bool: From<&str>` is not satisfied
--> tests/ui-fail-nightly/from_form.rs:209:23 --> 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")] 209 | #[field(default = "no conversion")]
| ^^^^^^^^^^^^^^^ the trait `From<&str>` is not implemented for `bool` | ^^^^^^^^^^^^^^^
| |
| 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>`: = help: the following other types implement trait `From<T>`:
<bool as From<format_description::parse::format_item::HourBase>> <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::WeekdayOneIndexed>>
<bool as From<format_description::parse::format_item::YearBase>> <bool as From<format_description::parse::format_item::YearBase>>
= note: required for `&str` to implement `Into<bool>` = 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

@ -37,8 +37,13 @@ error[E0277]: the trait bound `Foo<usize>: FromFormField<'_>` is not satisfied
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 --> tests/ui-fail-nightly/from_form_type_errors.rs:5:10
| |
5 | #[derive(FromForm)] 5 | #[derive(FromForm)]
| ^^^^^^^^ the trait `FromFormField<'_>` is not implemented for `Unknown` | ^-------
| |
| __________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>`: = help: the following other types implement trait `FromFormField<'v>`:
bool bool
@ -54,6 +59,8 @@ error[E0277]: the trait bound `Unknown: FromFormField<'_>` is not satisfied
note: required because it appears within the type `FromFormGeneratedContext<'r>` note: required because it appears within the type `FromFormGeneratedContext<'r>`
--> tests/ui-fail-nightly/from_form_type_errors.rs:6:8 --> tests/ui-fail-nightly/from_form_type_errors.rs:6:8
| |
5 | #[derive(FromForm)]
| -------- in this derive macro expansion
6 | struct BadType3 { 6 | struct BadType3 {
| ^^^^^^^^ | ^^^^^^^^
note: required by a bound in `rocket::form::FromForm::Context` note: required by a bound in `rocket::form::FromForm::Context`
@ -66,8 +73,13 @@ note: required by a bound in `rocket::form::FromForm::Context`
error[E0277]: the trait bound `Foo<usize>: FromFormField<'_>` is not satisfied error[E0277]: the trait bound `Foo<usize>: FromFormField<'_>` is not satisfied
--> tests/ui-fail-nightly/from_form_type_errors.rs:12:10 --> tests/ui-fail-nightly/from_form_type_errors.rs:12:10
| |
12 | #[derive(FromForm)] 12 | #[derive(FromForm)]
| ^^^^^^^^ the trait `FromFormField<'_>` is not implemented for `Foo<usize>` | ^-------
| |
| __________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>`: = help: the following other types implement trait `FromFormField<'v>`:
bool bool
@ -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>` note: required because it appears within the type `FromFormGeneratedContext<'r>`
--> tests/ui-fail-nightly/from_form_type_errors.rs:13:8 --> tests/ui-fail-nightly/from_form_type_errors.rs:13:8
| |
12 | #[derive(FromForm)]
| -------- in this derive macro expansion
13 | struct Other { 13 | struct Other {
| ^^^^^ | ^^^^^
note: required by a bound in `rocket::form::FromForm::Context` note: required by a bound in `rocket::form::FromForm::Context`
@ -91,3 +105,121 @@ note: required by a bound in `rocket::form::FromForm::Context`
| type Context: Send; | type Context: Send;
| ^^^^ required by this bound in `FromForm::Context` | ^^^^ required by this bound in `FromForm::Context`
= note: this error originates in the derive macro `FromForm` (in Nightly builds, run with -Z macro-backtrace for more info) = 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:5:10
|
5 | #[derive(FromForm)]
| ^^^^^^^^ 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]
&'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 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: 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>`
|
= 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]
&'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 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-nightly/from_form_type_errors.rs:12:10
|
12 | #[derive(FromForm)]
| ^^^^^^^^ 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]
&'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 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>: 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>`
|
= 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]
&'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 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

@ -407,8 +407,13 @@ error: duplicate default field expression
= help: at most one `default` or `default_with` is allowed = help: at most one `default` or `default_with` is allowed
--> tests/ui-fail-stable/from_form.rs:184:23 --> tests/ui-fail-stable/from_form.rs:184:23
| |
181 | #[derive(FromForm)]
| -------- in this derive macro expansion
...
184 | #[field(default = 2)] 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` error: [note] error occurred while deriving `FromForm`
--> tests/ui-fail-stable/from_form.rs:181:10 --> tests/ui-fail-stable/from_form.rs:181:10
@ -422,8 +427,13 @@ error: duplicate default expressions
= help: only one of `default` or `default_with` must be used = help: only one of `default` or `default_with` must be used
--> tests/ui-fail-stable/from_form.rs:190:23 --> 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)] 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 error: [note] other default expression is here
--> tests/ui-fail-stable/from_form.rs:190:41 --> tests/ui-fail-stable/from_form.rs:190:41
@ -443,8 +453,13 @@ error: duplicate default expressions
= help: only one of `default` or `default_with` must be used = help: only one of `default` or `default_with` must be used
--> tests/ui-fail-stable/from_form.rs:197:23 --> tests/ui-fail-stable/from_form.rs:197:23
| |
194 | #[derive(FromForm)]
| -------- in this derive macro expansion
...
197 | #[field(default = 1)] 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 error: [note] other default expression is here
--> tests/ui-fail-stable/from_form.rs:196:28 --> tests/ui-fail-stable/from_form.rs:196:28
@ -519,6 +534,9 @@ error[E0308]: mismatched types
help: the type constructed contains `{integer}` due to the type of the argument passed help: the type constructed contains `{integer}` due to the type of the argument passed
--> tests/ui-fail-stable/from_form.rs:171:23 --> tests/ui-fail-stable/from_form.rs:171:23
| |
169 | #[derive(FromForm)]
| -------- in this derive macro expansion
170 | struct Default0 {
171 | #[field(default = 123)] 171 | #[field(default = 123)]
| ^^^ this argument influences the type of `Some` | ^^^ this argument influences the type of `Some`
note: tuple variant defined here note: tuple variant defined here
@ -526,6 +544,7 @@ note: tuple variant defined here
| |
| Some(#[stable(feature = "rust1", since = "1.0.0")] T), | 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 error[E0308]: mismatched types
--> tests/ui-fail-stable/from_form.rs:203:33 --> tests/ui-fail-stable/from_form.rs:203:33
@ -552,8 +571,20 @@ note: tuple variant defined here
error[E0277]: the trait bound `bool: From<&str>` is not satisfied error[E0277]: the trait bound `bool: From<&str>` is not satisfied
--> tests/ui-fail-stable/from_form.rs:209:23 --> 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")] 209 | #[field(default = "no conversion")]
<<<<<<< HEAD
| ^^^^^^^^^^^^^^^ the trait `From<&str>` is not implemented for `bool` | ^^^^^^^^^^^^^^^ the trait `From<&str>` is not implemented for `bool`
||||||| parent of fd2094c5f (Use call site hygiene in FromForm derive.)
| ^^^^^^^^^^^^^^^ 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`
>>>>>>> fd2094c5f (Use call site hygiene in FromForm derive.)
| |
= help: the following other types implement trait `From<T>`: = help: the following other types implement trait `From<T>`:
<bool as From<format_description::parse::format_item::HourBase>> <bool as From<format_description::parse::format_item::HourBase>>
@ -565,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::WeekdayOneIndexed>>
<bool as From<format_description::parse::format_item::YearBase>> <bool as From<format_description::parse::format_item::YearBase>>
= note: required for `&str` to implement `Into<bool>` = 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,16 +6,52 @@ error[E0277]: the trait bound `Unknown: FromFormField<'_>` is not satisfied
| |
= help: the following other types implement trait `FromFormField<'v>`: = help: the following other types implement trait `FromFormField<'v>`:
bool bool
char
isize isize
i8 i8
i16 i16
i32 i32
i64 i64
i128 i128
usize
and $N others and $N others
= note: required for `Unknown` to implement `FromForm<'r>` = 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)]
| ^-------
| |
| __________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
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`
--> $WORKSPACE/core/lib/src/form/from_form.rs
|
| type Context: Send;
| ^^^^ required by this bound in `FromForm::Context`
= 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 error[E0277]: the trait bound `Foo<usize>: FromFormField<'_>` is not satisfied
--> tests/ui-fail-stable/from_form_type_errors.rs:14:12 --> tests/ui-fail-stable/from_form_type_errors.rs:14:12
| |
@ -24,12 +60,166 @@ error[E0277]: the trait bound `Foo<usize>: FromFormField<'_>` is not satisfied
| |
= help: the following other types implement trait `FromFormField<'v>`: = help: the following other types implement trait `FromFormField<'v>`:
bool bool
char
isize isize
i8 i8
i16 i16
i32 i32
i64 i64
i128 i128
usize
and $N others and $N others
= note: required for `Foo<usize>` to implement `FromForm<'r>` = 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:12:10
|
12 | #[derive(FromForm)]
| ^-------
| |
| __________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
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`
--> $WORKSPACE/core/lib/src/form/from_form.rs
|
| type Context: Send;
| ^^^^ required by this bound in `FromForm::Context`
= 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:5:10
|
5 | #[derive(FromForm)]
| ^^^^^^^^ 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
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: FromForm<'r>` is not satisfied
--> tests/ui-fail-stable/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>`
|
= 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
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 `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 `Foo<usize>: FromForm<'r>`
|
= help: the following other types implement trait `FromFormField<'v>`:
bool
char
isize
i8
i16
i32
i64
i128
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>: FromForm<'r>` is not satisfied
--> tests/ui-fail-stable/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>`
|
= 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
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)

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>`: = help: the following other types implement trait `FromFormField<'v>`:
bool bool
char
isize isize
i8 i8
i16 i16
i32 i32
i64 i64
i128 i128
usize
and $N others and $N others
= note: required for `Q` to implement `FromForm<'_>` = 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>`: = help: the following other types implement trait `FromFormField<'v>`:
bool bool
char
isize isize
i8 i8
i16 i16
i32 i32
i64 i64
i128 i128
usize
and $N others and $N others
= note: required for `Q` to implement `FromForm<'_>` = note: required for `Q` to implement `FromForm<'_>`