File tree Expand file tree Collapse file tree 2 files changed +49205
-0
lines changed
rust/ql/test/library-tests/type-inference Expand file tree Collapse file tree 2 files changed +49205
-0
lines changed Original file line number Diff line number Diff line change @@ -32,3 +32,41 @@ mod regression1 {
3232 opt_e. unwrap ( ) // $ target=unwrap
3333 }
3434}
35+
36+ mod regression2 {
37+ trait SomeTrait { }
38+
39+ trait MyFrom < T > {
40+ fn my_from ( value : T ) -> Self ;
41+ }
42+
43+ impl < T > MyFrom < T > for T {
44+ fn my_from ( s : T ) -> Self {
45+ s
46+ }
47+ }
48+
49+ impl < T > MyFrom < T > for Option < T > {
50+ fn my_from ( val : T ) -> Option < T > {
51+ Some ( val)
52+ }
53+ }
54+
55+ pub struct S < T > ( T ) ;
56+
57+ impl < T > MyFrom < S < T > > for Option < T > {
58+ fn my_from ( s : S < T > ) -> Self {
59+ Some ( s. 0 ) // $ fieldof=S
60+ }
61+ }
62+
63+ pub fn f < T1 , T2 > ( x : T2 ) -> T2
64+ where
65+ T2 : SomeTrait + MyFrom < Option < T1 > > ,
66+ Option < T1 > : MyFrom < T2 > ,
67+ {
68+ let y = MyFrom :: my_from ( x) ; // $ target=my_from
69+ let z = MyFrom :: my_from ( y) ; // $ target=my_from
70+ z
71+ }
72+ }
You can’t perform that action at this time.
0 commit comments