rust-clippy/tests/ui/fallible_impl_from.stderr
2018-12-28 12:41:12 +01:00

93 lines
3.2 KiB
Text

error: consider implementing `TryFrom` instead
--> $DIR/fallible_impl_from.rs:14:1
|
LL | / impl From<String> for Foo {
LL | | fn from(s: String) -> Self {
LL | | Foo(s.parse().unwrap())
LL | | }
LL | | }
| |_^
|
note: lint level defined here
--> $DIR/fallible_impl_from.rs:10:9
|
LL | #![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
|
LL | Foo(s.parse().unwrap())
| ^^^^^^^^^^^^^^^^^^
error: consider implementing `TryFrom` instead
--> $DIR/fallible_impl_from.rs:35:1
|
LL | / impl From<usize> for Invalid {
LL | | fn from(i: usize) -> Invalid {
LL | | if i != 42 {
LL | | panic!();
... |
LL | | }
LL | | }
| |_^
|
= 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
|
LL | 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
|
LL | / impl From<Option<String>> for Invalid {
LL | | fn from(s: Option<String>) -> Invalid {
LL | | let s = s.unwrap();
LL | | if !s.is_empty() {
... |
LL | | }
LL | | }
| |_^
|
= 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
|
LL | let s = s.unwrap();
| ^^^^^^^^^^
LL | if !s.is_empty() {
LL | panic!(42);
| ^^^^^^^^^^^
LL | } else if s.parse::<u32>().unwrap() != 42 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^
LL | 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
|
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);
... |
LL | | }
LL | | }
| |_^
|
= 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
|
LL | if s.parse::<u32>().ok().unwrap() != 42 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | 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