@@ -262,7 +262,10 @@ impl<K: UnifyKey> UnificationTable<K> {
262
262
}
263
263
264
264
/// Returns an iterator over all keys unioned with `key`.
265
- pub fn unioned_keys ( & mut self , key : K ) -> UnionedKeys < K > {
265
+ pub fn unioned_keys < K1 > ( & mut self , key : K1 ) -> UnionedKeys < K >
266
+ where K1 : Into < K >
267
+ {
268
+ let key = key. into ( ) ;
266
269
let root_key = self . get_root_key ( key) ;
267
270
UnionedKeys {
268
271
table : self ,
@@ -455,35 +458,45 @@ impl<'tcx, K, V> UnificationTable<K>
455
458
/// Unions two keys without the possibility of failure; only
456
459
/// applicable when unify values use `NoError` as their error
457
460
/// type.
458
- pub fn union ( & mut self , a_id : K , b_id : K )
459
- where V : UnifyValue < Error = NoError >
461
+ pub fn union < K1 , K2 > ( & mut self , a_id : K1 , b_id : K2 )
462
+ where K1 : Into < K > , K2 : Into < K > , V : UnifyValue < Error = NoError > ,
460
463
{
461
464
self . unify_var_var ( a_id, b_id) . unwrap ( ) ;
462
465
}
463
466
464
467
/// Unions a key and a value without the possibility of failure;
465
468
/// only applicable when unify values use `NoError` as their error
466
469
/// type.
467
- pub fn union_value ( & mut self , id : K , value : V )
468
- where V : UnifyValue < Error = NoError >
470
+ pub fn union_value < K1 > ( & mut self , id : K1 , value : V )
471
+ where K1 : Into < K > , V : UnifyValue < Error = NoError > ,
469
472
{
470
473
self . unify_var_value ( id, value) . unwrap ( ) ;
471
474
}
472
475
473
476
/// Given two keys, indicates whether they have been unioned together.
474
- pub fn unioned ( & mut self , a_id : K , b_id : K ) -> bool {
477
+ pub fn unioned < K1 , K2 > ( & mut self , a_id : K1 , b_id : K2 ) -> bool
478
+ where K1 : Into < K > , K2 : Into < K > ,
479
+ {
475
480
self . find ( a_id) == self . find ( b_id)
476
481
}
477
482
478
483
/// Given a key, returns the (current) root key.
479
- pub fn find ( & mut self , id : K ) -> K {
484
+ pub fn find < K1 > ( & mut self , id : K1 ) -> K
485
+ where K1 : Into < K >
486
+ {
487
+ let id = id. into ( ) ;
480
488
self . get_root_key ( id)
481
489
}
482
490
483
491
/// Unions together two variables, merging their values. If
484
492
/// merging the values fails, the error is propagated and this
485
493
/// method has no effect.
486
- pub fn unify_var_var ( & mut self , a_id : K , b_id : K ) -> Result < ( ) , V :: Error > {
494
+ pub fn unify_var_var < K1 , K2 > ( & mut self , a_id : K1 , b_id : K2 ) -> Result < ( ) , V :: Error >
495
+ where K1 : Into < K > , K2 : Into < K > ,
496
+ {
497
+ let a_id = a_id. into ( ) ;
498
+ let b_id = b_id. into ( ) ;
499
+
487
500
let root_a = self . get_root_key ( a_id) ;
488
501
let root_b = self . get_root_key ( b_id) ;
489
502
@@ -498,7 +511,10 @@ impl<'tcx, K, V> UnificationTable<K>
498
511
499
512
/// Sets the value of the key `a_id` to `b`, attempting to merge
500
513
/// with the previous value.
501
- pub fn unify_var_value ( & mut self , a_id : K , b : V ) -> Result < ( ) , V :: Error > {
514
+ pub fn unify_var_value < K1 > ( & mut self , a_id : K1 , b : V ) -> Result < ( ) , V :: Error >
515
+ where K1 : Into < K >
516
+ {
517
+ let a_id = a_id. into ( ) ;
502
518
let root_a = self . get_root_key ( a_id) ;
503
519
let value = V :: unify_values ( & self . value ( root_a) . value , & b) ?;
504
520
self . update_value ( root_a, |node| node. value = value) ;
@@ -507,7 +523,10 @@ impl<'tcx, K, V> UnificationTable<K>
507
523
508
524
/// Returns the current value for the given key. If the key has
509
525
/// been union'd, this will give the value from the current root.
510
- pub fn probe_value ( & mut self , id : K ) -> V {
526
+ pub fn probe_value < K1 > ( & mut self , id : K1 ) -> V
527
+ where K1 : Into < K >
528
+ {
529
+ let id = id. into ( ) ;
511
530
let id = self . get_root_key ( id) ;
512
531
self . value ( id) . value . clone ( )
513
532
}
0 commit comments