summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/fallible_impl_from.stderr
blob: d637dbce5d79294a603e0d69abe2510e3f47b1cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
error: consider implementing `TryFrom` instead
  --> $DIR/fallible_impl_from.rs:5:1
   |
LL | / impl From<String> for Foo {
LL | |     fn from(s: String) -> Self {
LL | |         Foo(s.parse().unwrap())
LL | |     }
LL | | }
   | |_^
   |
note: the lint level is defined here
  --> $DIR/fallible_impl_from.rs:1: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:7:13
   |
LL |         Foo(s.parse().unwrap())
   |             ^^^^^^^^^^^^^^^^^^

error: consider implementing `TryFrom` instead
  --> $DIR/fallible_impl_from.rs:26: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:29:13
   |
LL |             panic!();
   |             ^^^^^^^^
   = 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)

error: consider implementing `TryFrom` instead
  --> $DIR/fallible_impl_from.rs:35: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:37: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 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)

error: consider implementing `TryFrom` instead
  --> $DIR/fallible_impl_from.rs:53: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:55:12
   |
LL |         if s.parse::<u32>().ok().unwrap() != 42 {
   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL |             panic!("{:?}", s);
   |             ^^^^^^^^^^^^^^^^^
   = 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)

error: aborting due to 4 previous errors