2017-10-17 11:09:10 -05:00
|
|
|
error: consider implementing `TryFrom` instead
|
2019-01-07 15:33:18 -06:00
|
|
|
--> $DIR/fallible_impl_from.rs:5:1
|
2018-08-01 09:30:44 -05:00
|
|
|
|
|
2018-12-27 09:57:55 -06:00
|
|
|
LL | / impl From<String> for Foo {
|
|
|
|
LL | | fn from(s: String) -> Self {
|
|
|
|
LL | | Foo(s.parse().unwrap())
|
|
|
|
LL | | }
|
|
|
|
LL | | }
|
2018-08-01 09:30:44 -05:00
|
|
|
| |_^
|
|
|
|
|
|
2020-01-31 13:21:10 -06:00
|
|
|
note: the lint level is defined here
|
2019-01-07 15:33:18 -06:00
|
|
|
--> $DIR/fallible_impl_from.rs:1:9
|
2018-08-01 09:30:44 -05:00
|
|
|
|
|
2018-12-27 09:57:55 -06:00
|
|
|
LL | #![deny(clippy::fallible_impl_from)]
|
2018-08-01 09:30:44 -05:00
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2021-02-24 07:02:51 -06:00
|
|
|
= help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail
|
2017-10-17 11:09:10 -05:00
|
|
|
note: potential failure(s)
|
2019-01-07 15:33:18 -06:00
|
|
|
--> $DIR/fallible_impl_from.rs:7:13
|
2018-08-01 09:30:44 -05:00
|
|
|
|
|
2018-12-27 09:57:55 -06:00
|
|
|
LL | Foo(s.parse().unwrap())
|
2018-08-01 09:30:44 -05:00
|
|
|
| ^^^^^^^^^^^^^^^^^^
|
2017-10-17 11:09:10 -05:00
|
|
|
|
|
|
|
error: consider implementing `TryFrom` instead
|
2019-01-07 15:33:18 -06:00
|
|
|
--> $DIR/fallible_impl_from.rs:26:1
|
2017-10-17 11:09:10 -05:00
|
|
|
|
|
2018-12-27 09:57:55 -06:00
|
|
|
LL | / impl From<usize> for Invalid {
|
|
|
|
LL | | fn from(i: usize) -> Invalid {
|
|
|
|
LL | | if i != 42 {
|
|
|
|
LL | | panic!();
|
2017-10-17 11:09:10 -05:00
|
|
|
... |
|
2018-12-27 09:57:55 -06:00
|
|
|
LL | | }
|
|
|
|
LL | | }
|
2017-10-17 11:09:10 -05:00
|
|
|
| |_^
|
|
|
|
|
|
2021-02-24 07:02:51 -06:00
|
|
|
= help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail
|
2017-10-17 11:09:10 -05:00
|
|
|
note: potential failure(s)
|
2019-01-07 15:33:18 -06:00
|
|
|
--> $DIR/fallible_impl_from.rs:29:13
|
2017-10-17 11:09:10 -05:00
|
|
|
|
|
2018-12-27 09:57:55 -06:00
|
|
|
LL | panic!();
|
2017-10-17 11:09:10 -05:00
|
|
|
| ^^^^^^^^^
|
2020-02-06 21:34:06 -06:00
|
|
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
2017-10-17 11:09:10 -05:00
|
|
|
|
|
|
|
error: consider implementing `TryFrom` instead
|
2019-01-07 15:33:18 -06:00
|
|
|
--> $DIR/fallible_impl_from.rs:35:1
|
2017-10-17 11:09:10 -05:00
|
|
|
|
|
2018-12-27 09:57:55 -06:00
|
|
|
LL | / impl From<Option<String>> for Invalid {
|
|
|
|
LL | | fn from(s: Option<String>) -> Invalid {
|
|
|
|
LL | | let s = s.unwrap();
|
|
|
|
LL | | if !s.is_empty() {
|
2017-10-17 11:09:10 -05:00
|
|
|
... |
|
2018-12-27 09:57:55 -06:00
|
|
|
LL | | }
|
|
|
|
LL | | }
|
2017-10-17 11:09:10 -05:00
|
|
|
| |_^
|
|
|
|
|
|
2021-02-24 07:02:51 -06:00
|
|
|
= help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail
|
2017-10-17 11:09:10 -05:00
|
|
|
note: potential failure(s)
|
2019-01-07 15:33:18 -06:00
|
|
|
--> $DIR/fallible_impl_from.rs:37:17
|
2017-10-17 11:09:10 -05:00
|
|
|
|
|
2018-12-27 09:57:55 -06:00
|
|
|
LL | let s = s.unwrap();
|
2017-10-17 11:09:10 -05:00
|
|
|
| ^^^^^^^^^^
|
2018-12-27 09:57:55 -06:00
|
|
|
LL | if !s.is_empty() {
|
2021-02-02 13:24:42 -06:00
|
|
|
LL | panic!("42");
|
|
|
|
| ^^^^^^^^^^^^^
|
2018-12-27 09:57:55 -06:00
|
|
|
LL | } else if s.parse::<u32>().unwrap() != 42 {
|
2017-10-17 11:09:10 -05:00
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
2018-12-27 09:57:55 -06:00
|
|
|
LL | panic!("{:?}", s);
|
2017-10-17 11:09:10 -05:00
|
|
|
| ^^^^^^^^^^^^^^^^^^
|
2020-02-06 21:34:06 -06:00
|
|
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
2017-10-17 11:09:10 -05:00
|
|
|
|
|
|
|
error: consider implementing `TryFrom` instead
|
2019-01-07 15:33:18 -06:00
|
|
|
--> $DIR/fallible_impl_from.rs:53:1
|
2017-10-17 11:09:10 -05:00
|
|
|
|
|
2018-12-27 09:57:55 -06:00
|
|
|
LL | / impl<'a> From<&'a mut <Box<u32> as ProjStrTrait>::ProjString> for Invalid {
|
|
|
|
LL | | fn from(s: &'a mut <Box<u32> as ProjStrTrait>::ProjString) -> Invalid {
|
|
|
|
LL | | if s.parse::<u32>().ok().unwrap() != 42 {
|
|
|
|
LL | | panic!("{:?}", s);
|
2017-10-17 11:09:10 -05:00
|
|
|
... |
|
2018-12-27 09:57:55 -06:00
|
|
|
LL | | }
|
|
|
|
LL | | }
|
2017-10-17 11:09:10 -05:00
|
|
|
| |_^
|
|
|
|
|
|
2021-02-24 07:02:51 -06:00
|
|
|
= help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail
|
2017-10-17 11:09:10 -05:00
|
|
|
note: potential failure(s)
|
2019-01-07 15:33:18 -06:00
|
|
|
--> $DIR/fallible_impl_from.rs:55:12
|
2017-10-17 11:09:10 -05:00
|
|
|
|
|
2018-12-27 09:57:55 -06:00
|
|
|
LL | if s.parse::<u32>().ok().unwrap() != 42 {
|
2017-10-17 11:09:10 -05:00
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2018-12-27 09:57:55 -06:00
|
|
|
LL | panic!("{:?}", s);
|
2017-10-17 11:09:10 -05:00
|
|
|
| ^^^^^^^^^^^^^^^^^^
|
2020-02-06 21:34:06 -06:00
|
|
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
2017-10-17 11:09:10 -05:00
|
|
|
|
2018-01-16 10:06:27 -06:00
|
|
|
error: aborting due to 4 previous errors
|
|
|
|
|