Avoid more platform dependent errors in UI tests.

This commit is contained in:
Sergio Benitez 2022-05-03 14:33:11 -07:00
parent 55ea5dfb35
commit 4c6c0b497c
3 changed files with 48 additions and 26 deletions

View File

@ -477,23 +477,21 @@ note: function defined here
| pub fn ext<'v>(file: &TempFile<'_>, r#type: ContentType) -> Result<'v, ()> { | pub fn ext<'v>(file: &TempFile<'_>, r#type: ContentType) -> Result<'v, ()> {
| ^^^ | ^^^
error[E0277]: the trait bound `usize: From<&str>` is not satisfied error[E0308]: mismatched types
--> tests/ui-fail-nightly/from_form.rs:171:23 --> tests/ui-fail-nightly/from_form.rs:171:23
| |
171 | #[field(default = "no conversion")] 171 | #[field(default = 123)]
| ^^^^^^^^^^^^^^^ the trait `From<&str>` is not implemented for `usize` | ^^^
| |
| expected struct `std::string::String`, found integer
| arguments to this enum variant are incorrect
| |
= help: the following other types implement trait `From<T>`: help: try using a conversion method
<f32 as From<i16>> |
<f32 as From<i8>> 171 | #[field(default = 123.to_string())]
<f32 as From<u16>> | ++++++++++++
<f32 as From<u8>> 171 | #[field(default = 123.to_string())]
<f64 as From<f32>> | ++++++++++++
<f64 as From<i16>>
<f64 as From<i32>>
<f64 as From<i8>>
and 85 others
= note: required because of the requirements on the impl of `Into<usize>` for `&str`
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
@ -509,3 +507,12 @@ help: try using a conversion method
| ++++++++++++ | ++++++++++++
203 | #[field(default_with = Some("hi".to_string()))] 203 | #[field(default_with = Some("hi".to_string()))]
| ++++++++++++ | ++++++++++++
error[E0277]: the trait bound `bool: From<&str>` is not satisfied
--> tests/ui-fail-nightly/from_form.rs:209:23
|
209 | #[field(default = "no conversion")]
| ^^^^^^^^^^^^^^^ the trait `From<&str>` is not implemented for `bool`
|
= help: the trait `From<subtle::Choice>` is implemented for `bool`
= note: required because of the requirements on the impl of `Into<bool>` for `&str`

View File

@ -501,19 +501,18 @@ error[E0308]: mismatched types
165 | #[field(validate = ext("hello"))] 165 | #[field(validate = ext("hello"))]
| ^^^^^^^ expected struct `ContentType`, found `&str` | ^^^^^^^ expected struct `ContentType`, found `&str`
error[E0277]: the trait bound `usize: From<&str>` is not satisfied error[E0308]: mismatched types
--> tests/ui-fail-stable/from_form.rs:171:23 --> tests/ui-fail-stable/from_form.rs:171:23
| |
171 | #[field(default = "no conversion")] 171 | #[field(default = 123)]
| ^^^^^^^^^^^^^^^ the trait `From<&str>` is not implemented for `usize` | ^^^ expected struct `std::string::String`, found integer
| |
= help: the following implementations were found: help: try using a conversion method
<usize as From<NonZeroUsize>> |
<usize as From<bool>> 171 | #[field(default = 123.to_string())]
<usize as From<mio::token::Token>> | ++++++++++++
<usize as From<runtime::thread_pool::idle::State>> 171 | #[field(default = 123.to_string())]
and 89 others | ++++++++++++
= note: required because of the requirements on the impl of `Into<usize>` for `&str`
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
@ -527,3 +526,13 @@ help: try using a conversion method
| ++++++++++++ | ++++++++++++
203 | #[field(default_with = Some("hi".to_string()))] 203 | #[field(default_with = Some("hi".to_string()))]
| ++++++++++++ | ++++++++++++
error[E0277]: the trait bound `bool: From<&str>` is not satisfied
--> tests/ui-fail-stable/from_form.rs:209:23
|
209 | #[field(default = "no conversion")]
| ^^^^^^^^^^^^^^^ the trait `From<&str>` is not implemented for `bool`
|
= help: the following implementations were found:
<bool as From<subtle::Choice>>
= note: required because of the requirements on the impl of `Into<bool>` for `&str`

View File

@ -168,8 +168,8 @@ struct Validate3 {
#[derive(FromForm)] #[derive(FromForm)]
struct Default0 { struct Default0 {
#[field(default = "no conversion")] #[field(default = 123)]
first: usize, first: String,
} }
#[derive(FromForm)] #[derive(FromForm)]
@ -204,6 +204,12 @@ struct Default5 {
no_conversion_from_with: String, no_conversion_from_with: String,
} }
#[derive(FromForm)]
struct Default6 {
#[field(default = "no conversion")]
first: bool,
}
#[derive(FromForm)] // NO ERROR #[derive(FromForm)] // NO ERROR
struct Another<T> { struct Another<T> {
_foo: T, _foo: T,