]> git.lizzy.rs Git - rust.git/blob - tests/ui/fallible_impl_from.stderr
Auto merge of #9684 - kraktus:ref_option_ref, r=xFrednet
[rust.git] / tests / ui / fallible_impl_from.stderr
1 error: consider implementing `TryFrom` instead
2   --> $DIR/fallible_impl_from.rs:6:1
3    |
4 LL | / impl From<String> for Foo {
5 LL | |     fn from(s: String) -> Self {
6 LL | |         Foo(s.parse().unwrap())
7 LL | |     }
8 LL | | }
9    | |_^
10    |
11    = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail
12 note: potential failure(s)
13   --> $DIR/fallible_impl_from.rs:8:13
14    |
15 LL |         Foo(s.parse().unwrap())
16    |             ^^^^^^^^^^^^^^^^^^
17 note: the lint level is defined here
18   --> $DIR/fallible_impl_from.rs:1:9
19    |
20 LL | #![deny(clippy::fallible_impl_from)]
21    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^
22
23 error: consider implementing `TryFrom` instead
24   --> $DIR/fallible_impl_from.rs:27:1
25    |
26 LL | / impl From<usize> for Invalid {
27 LL | |     fn from(i: usize) -> Invalid {
28 LL | |         if i != 42 {
29 LL | |             panic!();
30 ...  |
31 LL | |     }
32 LL | | }
33    | |_^
34    |
35    = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail
36 note: potential failure(s)
37   --> $DIR/fallible_impl_from.rs:30:13
38    |
39 LL |             panic!();
40    |             ^^^^^^^^
41    = 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)
42
43 error: consider implementing `TryFrom` instead
44   --> $DIR/fallible_impl_from.rs:36:1
45    |
46 LL | / impl From<Option<String>> for Invalid {
47 LL | |     fn from(s: Option<String>) -> Invalid {
48 LL | |         let s = s.unwrap();
49 LL | |         if !s.is_empty() {
50 ...  |
51 LL | |     }
52 LL | | }
53    | |_^
54    |
55    = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail
56 note: potential failure(s)
57   --> $DIR/fallible_impl_from.rs:38:17
58    |
59 LL |         let s = s.unwrap();
60    |                 ^^^^^^^^^^
61 LL |         if !s.is_empty() {
62 LL |             panic!("42");
63    |             ^^^^^^^^^^^^
64 LL |         } else if s.parse::<u32>().unwrap() != 42 {
65    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^
66 LL |             panic!("{:?}", s);
67    |             ^^^^^^^^^^^^^^^^^
68    = 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)
69
70 error: consider implementing `TryFrom` instead
71   --> $DIR/fallible_impl_from.rs:54:1
72    |
73 LL | / impl<'a> From<&'a mut <Box<u32> as ProjStrTrait>::ProjString> for Invalid {
74 LL | |     fn from(s: &'a mut <Box<u32> as ProjStrTrait>::ProjString) -> Invalid {
75 LL | |         if s.parse::<u32>().ok().unwrap() != 42 {
76 LL | |             panic!("{:?}", s);
77 ...  |
78 LL | |     }
79 LL | | }
80    | |_^
81    |
82    = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail
83 note: potential failure(s)
84   --> $DIR/fallible_impl_from.rs:56:12
85    |
86 LL |         if s.parse::<u32>().ok().unwrap() != 42 {
87    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
88 LL |             panic!("{:?}", s);
89    |             ^^^^^^^^^^^^^^^^^
90    = 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)
91
92 error: aborting due to 4 previous errors
93