mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-18 09:03:18 +00:00
93 lines
3.2 KiB
Text
93 lines
3.2 KiB
Text
error: consider implementing `TryFrom` instead
|
|
--> $DIR/fallible_impl_from.rs:14:1
|
|
|
|
|
14 | / impl From<String> for Foo {
|
|
15 | | fn from(s: String) -> Self {
|
|
16 | | Foo(s.parse().unwrap())
|
|
17 | | }
|
|
18 | | }
|
|
| |_^
|
|
|
|
|
note: lint level defined here
|
|
--> $DIR/fallible_impl_from.rs:10:9
|
|
|
|
|
10 | #![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.
|
|
note: potential failure(s)
|
|
--> $DIR/fallible_impl_from.rs:16:13
|
|
|
|
|
16 | Foo(s.parse().unwrap())
|
|
| ^^^^^^^^^^^^^^^^^^
|
|
|
|
error: consider implementing `TryFrom` instead
|
|
--> $DIR/fallible_impl_from.rs:35:1
|
|
|
|
|
35 | / impl From<usize> for Invalid {
|
|
36 | | fn from(i: usize) -> Invalid {
|
|
37 | | if i != 42 {
|
|
38 | | panic!();
|
|
... |
|
|
41 | | }
|
|
42 | | }
|
|
| |_^
|
|
|
|
|
= help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail.
|
|
note: potential failure(s)
|
|
--> $DIR/fallible_impl_from.rs:38:13
|
|
|
|
|
38 | panic!();
|
|
| ^^^^^^^^^
|
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
|
|
|
error: consider implementing `TryFrom` instead
|
|
--> $DIR/fallible_impl_from.rs:44:1
|
|
|
|
|
44 | / impl From<Option<String>> for Invalid {
|
|
45 | | fn from(s: Option<String>) -> Invalid {
|
|
46 | | let s = s.unwrap();
|
|
47 | | if !s.is_empty() {
|
|
... |
|
|
53 | | }
|
|
54 | | }
|
|
| |_^
|
|
|
|
|
= help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail.
|
|
note: potential failure(s)
|
|
--> $DIR/fallible_impl_from.rs:46:17
|
|
|
|
|
46 | let s = s.unwrap();
|
|
| ^^^^^^^^^^
|
|
47 | if !s.is_empty() {
|
|
48 | panic!(42);
|
|
| ^^^^^^^^^^^
|
|
49 | } else if s.parse::<u32>().unwrap() != 42 {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
50 | panic!("{:?}", s);
|
|
| ^^^^^^^^^^^^^^^^^^
|
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
|
|
|
error: consider implementing `TryFrom` instead
|
|
--> $DIR/fallible_impl_from.rs:62:1
|
|
|
|
|
62 | / impl<'a> From<&'a mut <Box<u32> as ProjStrTrait>::ProjString> for Invalid {
|
|
63 | | fn from(s: &'a mut <Box<u32> as ProjStrTrait>::ProjString) -> Invalid {
|
|
64 | | if s.parse::<u32>().ok().unwrap() != 42 {
|
|
65 | | panic!("{:?}", s);
|
|
... |
|
|
68 | | }
|
|
69 | | }
|
|
| |_^
|
|
|
|
|
= help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail.
|
|
note: potential failure(s)
|
|
--> $DIR/fallible_impl_from.rs:64:12
|
|
|
|
|
64 | if s.parse::<u32>().ok().unwrap() != 42 {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
65 | panic!("{:?}", s);
|
|
| ^^^^^^^^^^^^^^^^^^
|
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
|
|
|
error: aborting due to 4 previous errors
|
|
|