2017-10-17 18:09:10 +02:00
|
|
|
error: consider implementing `TryFrom` instead
|
2018-08-01 16:30:44 +02:00
|
|
|
--> $DIR/fallible_impl_from.rs:7:1
|
|
|
|
|
|
|
|
|
7 | / impl From<String> for Foo {
|
|
|
|
8 | | fn from(s: String) -> Self {
|
|
|
|
9 | | Foo(s.parse().unwrap())
|
|
|
|
10 | | }
|
|
|
|
11 | | }
|
|
|
|
| |_^
|
|
|
|
|
|
2017-10-17 18:09:10 +02:00
|
|
|
note: lint level defined here
|
2018-08-01 16:30:44 +02:00
|
|
|
--> $DIR/fallible_impl_from.rs:3:9
|
|
|
|
|
|
|
|
|
3 | #![deny(clippy::fallible_impl_from)]
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
= help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail.
|
2017-10-17 18:09:10 +02:00
|
|
|
note: potential failure(s)
|
2018-08-01 16:30:44 +02:00
|
|
|
--> $DIR/fallible_impl_from.rs:9:13
|
|
|
|
|
|
|
|
|
9 | Foo(s.parse().unwrap())
|
|
|
|
| ^^^^^^^^^^^^^^^^^^
|
2017-10-17 18:09:10 +02:00
|
|
|
|
|
|
|
error: consider implementing `TryFrom` instead
|
2018-08-01 16:30:44 +02:00
|
|
|
--> $DIR/fallible_impl_from.rs:30:1
|
2017-10-17 18:09:10 +02:00
|
|
|
|
|
2018-08-01 16:30:44 +02:00
|
|
|
30 | / impl From<usize> for Invalid {
|
|
|
|
31 | | fn from(i: usize) -> Invalid {
|
|
|
|
32 | | if i != 42 {
|
|
|
|
33 | | panic!();
|
2017-10-17 18:09:10 +02:00
|
|
|
... |
|
2018-08-01 16:30:44 +02:00
|
|
|
36 | | }
|
|
|
|
37 | | }
|
2017-10-17 18:09:10 +02:00
|
|
|
| |_^
|
|
|
|
|
|
|
|
|
= help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail.
|
|
|
|
note: potential failure(s)
|
2018-08-01 16:30:44 +02:00
|
|
|
--> $DIR/fallible_impl_from.rs:33:13
|
2017-10-17 18:09:10 +02:00
|
|
|
|
|
2018-08-01 16:30:44 +02:00
|
|
|
33 | panic!();
|
2017-10-17 18:09:10 +02:00
|
|
|
| ^^^^^^^^^
|
2017-11-29 15:45:12 +01:00
|
|
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
2017-10-17 18:09:10 +02:00
|
|
|
|
|
|
|
error: consider implementing `TryFrom` instead
|
2018-08-01 16:30:44 +02:00
|
|
|
--> $DIR/fallible_impl_from.rs:39:1
|
2017-10-17 18:09:10 +02:00
|
|
|
|
|
2018-08-01 16:30:44 +02:00
|
|
|
39 | / impl From<Option<String>> for Invalid {
|
|
|
|
40 | | fn from(s: Option<String>) -> Invalid {
|
|
|
|
41 | | let s = s.unwrap();
|
|
|
|
42 | | if !s.is_empty() {
|
2017-10-17 18:09:10 +02:00
|
|
|
... |
|
2018-08-01 16:30:44 +02:00
|
|
|
48 | | }
|
|
|
|
49 | | }
|
2017-10-17 18:09:10 +02:00
|
|
|
| |_^
|
|
|
|
|
|
|
|
|
= help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail.
|
|
|
|
note: potential failure(s)
|
2018-08-01 16:30:44 +02:00
|
|
|
--> $DIR/fallible_impl_from.rs:41:17
|
2017-10-17 18:09:10 +02:00
|
|
|
|
|
2018-08-01 16:30:44 +02:00
|
|
|
41 | let s = s.unwrap();
|
2017-10-17 18:09:10 +02:00
|
|
|
| ^^^^^^^^^^
|
2018-08-01 16:30:44 +02:00
|
|
|
42 | if !s.is_empty() {
|
|
|
|
43 | panic!(42);
|
2017-10-17 18:09:10 +02:00
|
|
|
| ^^^^^^^^^^^
|
2018-08-01 16:30:44 +02:00
|
|
|
44 | } else if s.parse::<u32>().unwrap() != 42 {
|
2017-10-17 18:09:10 +02:00
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
2018-08-01 16:30:44 +02:00
|
|
|
45 | panic!("{:?}", s);
|
2017-10-17 18:09:10 +02:00
|
|
|
| ^^^^^^^^^^^^^^^^^^
|
2017-11-29 15:45:12 +01:00
|
|
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
2017-10-17 18:09:10 +02:00
|
|
|
|
|
|
|
error: consider implementing `TryFrom` instead
|
2018-08-01 16:30:44 +02:00
|
|
|
--> $DIR/fallible_impl_from.rs:57:1
|
2017-10-17 18:09:10 +02:00
|
|
|
|
|
2018-08-01 16:30:44 +02:00
|
|
|
57 | / impl<'a> From<&'a mut <Box<u32> as ProjStrTrait>::ProjString> for Invalid {
|
|
|
|
58 | | fn from(s: &'a mut <Box<u32> as ProjStrTrait>::ProjString) -> Invalid {
|
|
|
|
59 | | if s.parse::<u32>().ok().unwrap() != 42 {
|
|
|
|
60 | | panic!("{:?}", s);
|
2017-10-17 18:09:10 +02:00
|
|
|
... |
|
2018-08-01 16:30:44 +02:00
|
|
|
63 | | }
|
|
|
|
64 | | }
|
2017-10-17 18:09:10 +02:00
|
|
|
| |_^
|
|
|
|
|
|
|
|
|
= help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail.
|
|
|
|
note: potential failure(s)
|
2018-08-01 16:30:44 +02:00
|
|
|
--> $DIR/fallible_impl_from.rs:59:12
|
2017-10-17 18:09:10 +02:00
|
|
|
|
|
2018-08-01 16:30:44 +02:00
|
|
|
59 | if s.parse::<u32>().ok().unwrap() != 42 {
|
2017-10-17 18:09:10 +02:00
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2018-08-01 16:30:44 +02:00
|
|
|
60 | panic!("{:?}", s);
|
2017-10-17 18:09:10 +02:00
|
|
|
| ^^^^^^^^^^^^^^^^^^
|
2017-11-29 15:45:12 +01:00
|
|
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
2017-10-17 18:09:10 +02:00
|
|
|
|
2018-01-16 17:06:27 +01:00
|
|
|
error: aborting due to 4 previous errors
|
|
|
|
|