File tree Expand file tree Collapse file tree 2 files changed +4265
-4198
lines changed
rust/ql/test/library-tests/type-inference Expand file tree Collapse file tree 2 files changed +4265
-4198
lines changed Original file line number Diff line number Diff line change @@ -121,6 +121,51 @@ mod trait_impl {
121121 }
122122}
123123
124+ mod trait_visibility {
125+ // In this test the correct method target depends on which trait is visible.
126+
127+ mod m {
128+ pub trait Foo {
129+ // Foo::a_method
130+ fn a_method ( & self ) {
131+ println ! ( "foo!" ) ;
132+ }
133+ }
134+
135+ pub trait Bar {
136+ // Bar::a_method
137+ fn a_method ( & self ) {
138+ println ! ( "quux!" ) ;
139+ }
140+ }
141+
142+ pub struct X ;
143+ impl Foo for X { }
144+ impl Bar for X { }
145+ }
146+
147+ use m:: X ;
148+
149+ fn main ( ) {
150+ let x = X ;
151+ {
152+ use m:: Foo ;
153+ x. a_method ( ) ; // $ target=Foo::a_method SPURIOUS: target=Bar::a_method
154+ }
155+ {
156+ use m:: Bar ;
157+ x. a_method ( ) ; // $ target=Bar::a_method SPURIOUS: target=Foo::a_method
158+ }
159+ {
160+ use m:: Bar ;
161+ use m:: Foo ;
162+ // x.a_method(); // This would be ambiguous
163+ Foo :: a_method ( & x) ; // $ target=Foo::a_method
164+ Bar :: a_method ( & x) ; // $ target=Bar::a_method
165+ }
166+ }
167+ }
168+
124169mod method_non_parametric_impl {
125170 #[ derive( Debug ) ]
126171 struct MyThing < A > {
You can’t perform that action at this time.
0 commit comments