2017-10-17 16:09:10 +00:00
error: consider implementing `TryFrom` instead
2024-02-17 12:16:29 +00:00
--> tests/ui/fallible_impl_from.rs:6:1
2018-08-01 14:30:44 +00:00
|
2018-12-27 15:57:55 +00:00
LL | / impl From<String> for Foo {
2023-07-28 19:35:48 +00:00
LL | |
2018-12-27 15:57:55 +00:00
LL | | fn from(s: String) -> Self {
LL | | Foo(s.parse().unwrap())
LL | | }
LL | | }
2018-08-01 14:30:44 +00:00
| |_^
|
2021-03-12 14:30:50 +00:00
= help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail
2017-10-17 16:09:10 +00:00
note: potential failure(s)
2024-02-17 12:16:29 +00:00
--> tests/ui/fallible_impl_from.rs:9:13
2018-08-01 14:30:44 +00:00
|
2018-12-27 15:57:55 +00:00
LL | Foo(s.parse().unwrap())
2018-08-01 14:30:44 +00:00
| ^^^^^^^^^^^^^^^^^^
2022-09-22 16:04:22 +00:00
note: the lint level is defined here
2024-02-17 12:16:29 +00:00
--> tests/ui/fallible_impl_from.rs:1:9
2022-09-22 16:04:22 +00:00
|
LL | #![deny(clippy::fallible_impl_from)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
2017-10-17 16:09:10 +00:00
error: consider implementing `TryFrom` instead
2024-02-17 12:16:29 +00:00
--> tests/ui/fallible_impl_from.rs:28:1
2017-10-17 16:09:10 +00:00
|
2018-12-27 15:57:55 +00:00
LL | / impl From<usize> for Invalid {
2023-07-28 19:35:48 +00:00
LL | |
2018-12-27 15:57:55 +00:00
LL | | fn from(i: usize) -> Invalid {
LL | | if i != 42 {
2017-10-17 16:09:10 +00:00
... |
2018-12-27 15:57:55 +00:00
LL | | }
LL | | }
2017-10-17 16:09:10 +00:00
| |_^
|
2021-03-12 14:30:50 +00:00
= help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail
2017-10-17 16:09:10 +00:00
note: potential failure(s)
2024-02-17 12:16:29 +00:00
--> tests/ui/fallible_impl_from.rs:32:13
2017-10-17 16:09:10 +00:00
|
2018-12-27 15:57:55 +00:00
LL | panic!();
2021-10-14 18:28:30 +00:00
| ^^^^^^^^
2022-06-21 02:25:52 +00:00
= note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
2017-10-17 16:09:10 +00:00
error: consider implementing `TryFrom` instead
2024-02-17 12:16:29 +00:00
--> tests/ui/fallible_impl_from.rs:38:1
2017-10-17 16:09:10 +00:00
|
2018-12-27 15:57:55 +00:00
LL | / impl From<Option<String>> for Invalid {
2023-07-28 19:35:48 +00:00
LL | |
2018-12-27 15:57:55 +00:00
LL | | fn from(s: Option<String>) -> Invalid {
LL | | let s = s.unwrap();
2017-10-17 16:09:10 +00:00
... |
2018-12-27 15:57:55 +00:00
LL | | }
LL | | }
2017-10-17 16:09:10 +00:00
| |_^
|
2021-03-12 14:30:50 +00:00
= help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail
2017-10-17 16:09:10 +00:00
note: potential failure(s)
2024-02-17 12:16:29 +00:00
--> tests/ui/fallible_impl_from.rs:41:17
2017-10-17 16:09:10 +00:00
|
2018-12-27 15:57:55 +00:00
LL | let s = s.unwrap();
2017-10-17 16:09:10 +00:00
| ^^^^^^^^^^
2018-12-27 15:57:55 +00:00
LL | if !s.is_empty() {
2021-02-02 19:24:42 +00:00
LL | panic!("42");
2021-10-14 18:28:30 +00:00
| ^^^^^^^^^^^^
2018-12-27 15:57:55 +00:00
LL | } else if s.parse::<u32>().unwrap() != 42 {
2017-10-17 16:09:10 +00:00
| ^^^^^^^^^^^^^^^^^^^^^^^^^
2018-12-27 15:57:55 +00:00
LL | panic!("{:?}", s);
2021-10-14 18:28:30 +00:00
| ^^^^^^^^^^^^^^^^^
2022-06-21 02:25:52 +00:00
= note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
2017-10-17 16:09:10 +00:00
error: consider implementing `TryFrom` instead
2024-02-17 12:16:29 +00:00
--> tests/ui/fallible_impl_from.rs:57:1
2017-10-17 16:09:10 +00:00
|
2018-12-27 15:57:55 +00:00
LL | / impl<'a> From<&'a mut <Box<u32> as ProjStrTrait>::ProjString> for Invalid {
2023-07-28 19:35:48 +00:00
LL | |
2018-12-27 15:57:55 +00:00
LL | | fn from(s: &'a mut <Box<u32> as ProjStrTrait>::ProjString) -> Invalid {
LL | | if s.parse::<u32>().ok().unwrap() != 42 {
2017-10-17 16:09:10 +00:00
... |
2018-12-27 15:57:55 +00:00
LL | | }
LL | | }
2017-10-17 16:09:10 +00:00
| |_^
|
2021-03-12 14:30:50 +00:00
= help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail
2017-10-17 16:09:10 +00:00
note: potential failure(s)
2024-02-17 12:16:29 +00:00
--> tests/ui/fallible_impl_from.rs:60:12
2017-10-17 16:09:10 +00:00
|
2018-12-27 15:57:55 +00:00
LL | if s.parse::<u32>().ok().unwrap() != 42 {
2017-10-17 16:09:10 +00:00
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2018-12-27 15:57:55 +00:00
LL | panic!("{:?}", s);
2021-10-14 18:28:30 +00:00
| ^^^^^^^^^^^^^^^^^
2022-06-21 02:25:52 +00:00
= note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
2017-10-17 16:09:10 +00:00
2018-01-16 16:06:27 +00:00
error: aborting due to 4 previous errors