File tree Expand file tree Collapse file tree 2 files changed +634
-574
lines changed
rust/ql/test/library-tests/type-inference Expand file tree Collapse file tree 2 files changed +634
-574
lines changed Original file line number Diff line number Diff line change @@ -368,6 +368,18 @@ mod trait_associated_type {
368
368
}
369
369
}
370
370
371
+ // A generic trait with multiple associated types.
372
+ trait TraitMultipleAssoc < TrG > {
373
+ type Assoc1 ;
374
+ type Assoc2 ;
375
+
376
+ fn get_zero ( & self ) -> TrG ;
377
+
378
+ fn get_one ( & self ) -> Self :: Assoc1 ;
379
+
380
+ fn get_two ( & self ) -> Self :: Assoc2 ;
381
+ }
382
+
371
383
#[ derive( Debug , Default ) ]
372
384
struct S ;
373
385
@@ -417,6 +429,23 @@ mod trait_associated_type {
417
429
thing. m1 ( ) // $ method=MyTrait::m1
418
430
}
419
431
432
+ impl TraitMultipleAssoc < AT > for AT {
433
+ type Assoc1 = S ;
434
+ type Assoc2 = S2 ;
435
+
436
+ fn get_zero ( & self ) -> AT {
437
+ AT
438
+ }
439
+
440
+ fn get_one ( & self ) -> Self :: Assoc1 {
441
+ S
442
+ }
443
+
444
+ fn get_two ( & self ) -> Self :: Assoc2 {
445
+ S2
446
+ }
447
+ }
448
+
420
449
pub fn f ( ) {
421
450
let x1 = S ;
422
451
// Call to method in `impl` block
@@ -441,6 +470,10 @@ mod trait_associated_type {
441
470
println ! ( "{:?}" , x5. m1( ) ) ; // $ method=m1 MISSING: type=x5.m1():A.S2
442
471
let x6 = S2 ;
443
472
println ! ( "{:?}" , x6. m2( ) ) ; // $ method=m2 type=x6.m2():A.S2
473
+
474
+ let assoc_zero = AT . get_zero ( ) ; // $ method=get_zero type=assoc_zero:AT
475
+ let assoc_one = AT . get_one ( ) ; // $ method=get_one type=assoc_one:S
476
+ let assoc_two = AT . get_two ( ) ; // $ method=get_two type=assoc_two:S2
444
477
}
445
478
}
446
479
You can’t perform that action at this time.
0 commit comments