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