rust/tests/ui/fallible_impl_from.stderr

94 lines
3.2 KiB
Plaintext
Raw Normal View History

2017-10-17 11:09:10 -05:00
error: consider implementing `TryFrom` instead
2018-10-06 11:18:06 -05:00
--> $DIR/fallible_impl_from.rs:17:1
|
2018-10-06 11:18:06 -05:00
17 | / impl From<String> for Foo {
18 | | fn from(s: String) -> Self {
19 | | Foo(s.parse().unwrap())
20 | | }
21 | | }
| |_^
|
2017-10-17 11:09:10 -05:00
note: lint level defined here
2018-10-06 11:18:06 -05:00
--> $DIR/fallible_impl_from.rs:13:9
|
2018-10-06 11:18:06 -05:00
13 | #![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 11:09:10 -05:00
note: potential failure(s)
2018-10-06 11:18:06 -05:00
--> $DIR/fallible_impl_from.rs:19:13
|
2018-10-06 11:18:06 -05:00
19 | Foo(s.parse().unwrap())
| ^^^^^^^^^^^^^^^^^^
2017-10-17 11:09:10 -05:00
error: consider implementing `TryFrom` instead
2018-10-06 11:18:06 -05:00
--> $DIR/fallible_impl_from.rs:40:1
2017-10-17 11:09:10 -05:00
|
2018-10-06 11:18:06 -05:00
40 | / impl From<usize> for Invalid {
41 | | fn from(i: usize) -> Invalid {
42 | | if i != 42 {
43 | | panic!();
2017-10-17 11:09:10 -05:00
... |
2018-10-06 11:18:06 -05:00
46 | | }
47 | | }
2017-10-17 11:09:10 -05: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-10-06 11:18:06 -05:00
--> $DIR/fallible_impl_from.rs:43:13
2017-10-17 11:09:10 -05:00
|
2018-10-06 11:18:06 -05:00
43 | panic!();
2017-10-17 11:09:10 -05:00
| ^^^^^^^^^
2017-11-29 08:45:12 -06: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 11:09:10 -05:00
error: consider implementing `TryFrom` instead
2018-10-06 11:18:06 -05:00
--> $DIR/fallible_impl_from.rs:49:1
2017-10-17 11:09:10 -05:00
|
2018-10-06 11:18:06 -05:00
49 | / impl From<Option<String>> for Invalid {
50 | | fn from(s: Option<String>) -> Invalid {
51 | | let s = s.unwrap();
52 | | if !s.is_empty() {
2017-10-17 11:09:10 -05:00
... |
2018-10-06 11:18:06 -05:00
58 | | }
59 | | }
2017-10-17 11:09:10 -05: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-10-06 11:18:06 -05:00
--> $DIR/fallible_impl_from.rs:51:17
2017-10-17 11:09:10 -05:00
|
2018-10-06 11:18:06 -05:00
51 | let s = s.unwrap();
2017-10-17 11:09:10 -05:00
| ^^^^^^^^^^
2018-10-06 11:18:06 -05:00
52 | if !s.is_empty() {
53 | panic!(42);
2017-10-17 11:09:10 -05:00
| ^^^^^^^^^^^
2018-10-06 11:18:06 -05:00
54 | } else if s.parse::<u32>().unwrap() != 42 {
2017-10-17 11:09:10 -05:00
| ^^^^^^^^^^^^^^^^^^^^^^^^^
2018-10-06 11:18:06 -05:00
55 | panic!("{:?}", s);
2017-10-17 11:09:10 -05:00
| ^^^^^^^^^^^^^^^^^^
2017-11-29 08:45:12 -06: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 11:09:10 -05:00
error: consider implementing `TryFrom` instead
2018-10-06 11:18:06 -05:00
--> $DIR/fallible_impl_from.rs:67:1
2017-10-17 11:09:10 -05:00
|
2018-10-06 11:18:06 -05:00
67 | / impl<'a> From<&'a mut <Box<u32> as ProjStrTrait>::ProjString> for Invalid {
68 | | fn from(s: &'a mut <Box<u32> as ProjStrTrait>::ProjString) -> Invalid {
69 | | if s.parse::<u32>().ok().unwrap() != 42 {
70 | | panic!("{:?}", s);
2017-10-17 11:09:10 -05:00
... |
2018-10-06 11:18:06 -05:00
73 | | }
74 | | }
2017-10-17 11:09:10 -05: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-10-06 11:18:06 -05:00
--> $DIR/fallible_impl_from.rs:69:12
2017-10-17 11:09:10 -05:00
|
2018-10-06 11:18:06 -05:00
69 | if s.parse::<u32>().ok().unwrap() != 42 {
2017-10-17 11:09:10 -05:00
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2018-10-06 11:18:06 -05:00
70 | panic!("{:?}", s);
2017-10-17 11:09:10 -05:00
| ^^^^^^^^^^^^^^^^^^
2017-11-29 08:45:12 -06: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 11:09:10 -05:00
2018-01-16 10:06:27 -06:00
error: aborting due to 4 previous errors