File tree Expand file tree Collapse file tree 2 files changed +74
-0
lines changed Expand file tree Collapse file tree 2 files changed +74
-0
lines changed Original file line number Diff line number Diff line change 1+ use  serde:: de:: Deserialize ; 
2+ use  serde:: ser:: Serialize ; 
3+ 
4+ fn  to_string < T > ( _:  & T )  -> String 
5+ where 
6+  T :  Serialize , 
7+ { 
8+  unimplemented ! ( ) 
9+ } 
10+ 
11+ fn  from_str < ' de ,  T > ( _:  & ' de  str )  -> T 
12+ where 
13+  T :  Deserialize < ' de > , 
14+ { 
15+  unimplemented ! ( ) 
16+ } 
17+ 
18+ struct  MyStruct ; 
19+ 
20+ fn  main ( )  { 
21+  to_string ( & MyStruct ) ; 
22+  let  _:  MyStruct  = from_str ( "" ) ; 
23+ } 
Original file line number Diff line number Diff line change 1+ error[E0277]: the trait bound `MyStruct: Serialize` is not satisfied
2+  --> tests/ui/on_unimplemented.rs:21:15
3+  |
4+ 21 | to_string(&MyStruct);
5+  | --------- ^^^^^^^^^ the trait `Serialize` is not implemented for `MyStruct`
6+  | |
7+  | required by a bound introduced by this call
8+  |
9+  = help: the following other types implement trait `Serialize`:
10+  &'a T
11+  &'a mut T
12+  ()
13+  (T,)
14+  (T0, T1)
15+  (T0, T1, T2)
16+  (T0, T1, T2, T3)
17+  (T0, T1, T2, T3, T4)
18+  and $N others
19+ note: required by a bound in `to_string`
20+  --> tests/ui/on_unimplemented.rs:6:8
21+  |
22+ 4 | fn to_string<T>(_: &T) -> String
23+  | --------- required by a bound in this function
24+ 5 | where
25+ 6 | T: Serialize,
26+  | ^^^^^^^^^ required by this bound in `to_string`
27+ 
28+ error[E0277]: the trait bound `MyStruct: Deserialize<'_>` is not satisfied
29+  --> tests/ui/on_unimplemented.rs:22:23
30+  |
31+ 22 | let _: MyStruct = from_str("");
32+  | ^^^^^^^^^^^^ the trait `Deserialize<'_>` is not implemented for `MyStruct`
33+  |
34+  = help: the following other types implement trait `Deserialize<'de>`:
35+  &'a Path
36+  &'a [u8]
37+  &'a str
38+  ()
39+  (T,)
40+  (T0, T1)
41+  (T0, T1, T2)
42+  (T0, T1, T2, T3)
43+  and $N others
44+ note: required by a bound in `from_str`
45+  --> tests/ui/on_unimplemented.rs:13:8
46+  |
47+ 11 | fn from_str<'de, T>(_: &'de str) -> T
48+  | -------- required by a bound in this function
49+ 12 | where
50+ 13 | T: Deserialize<'de>,
51+  | ^^^^^^^^^^^^^^^^ required by this bound in `from_str`
                                 You can’t perform that action at this time. 
               
                  
0 commit comments