@@ -440,7 +440,7 @@ impl UnificationContext {
440
440
continue ;
441
441
}
442
442
443
- if let Some ( cs) = self . constraints . get ( m) {
443
+ if let Some ( cs) = self . constraints . remove ( m) {
444
444
for c in cs
445
445
. iter ( )
446
446
. filter ( |c| !matches ! ( c, Constraint :: Equal ( _) ) )
@@ -450,7 +450,6 @@ impl UnificationContext {
450
450
{
451
451
self . add_constraint ( combined_meta, c. clone ( ) ) ;
452
452
}
453
- self . constraints . remove ( m) . unwrap ( ) ;
454
453
merged. insert ( * m) ;
455
454
// Record a new meta the first time that we use it; don't
456
455
// bother recording a new meta if we don't add any
@@ -538,27 +537,21 @@ impl UnificationContext {
538
537
/// available. When there are variables, we should leave the graph as it is,
539
538
/// but make sure that no matter what they're instantiated to, the graph
540
539
/// still makes sense (should pass the extension validation check)
541
- pub fn results ( & mut self ) -> Result < ExtensionSolution , InferExtensionError > {
540
+ pub fn results ( & self ) -> Result < ExtensionSolution , InferExtensionError > {
542
541
// Check that all of the metavariables associated with nodes of the
543
542
// graph are solved
544
543
let mut results: ExtensionSolution = HashMap :: new ( ) ;
545
544
for ( loc, meta) in self . extensions . iter ( ) {
546
- let rs = match self . get_solution ( meta) {
547
- Some ( rs) => Ok ( rs. clone ( ) ) ,
548
- None => {
549
- // If it depends on some other live meta, that's bad news.
550
- // If it only depends on graph variables, then we don't have
551
- // a *solution*, but it's fine
552
- if self . live_var ( meta) . is_some ( ) {
553
- Err ( InferExtensionError :: Unsolved { location : * loc } )
554
- } else {
555
- continue ;
556
- }
545
+ if let Some ( rs) = self . get_solution ( meta) {
546
+ if loc. 1 == Direction :: Incoming {
547
+ results. insert ( loc. 0 , rs. clone ( ) ) ;
557
548
}
558
- } ? ;
559
- if loc . 1 == Direction :: Incoming {
560
- results . insert ( loc. 0 , rs ) ;
549
+ } else if self . live_var ( meta ) . is_some ( ) {
550
+ // If it depends on some other live meta, that's bad news.
551
+ return Err ( InferExtensionError :: Unsolved { location : * loc } ) ;
561
552
}
553
+ // If it only depends on graph variables, then we don't have
554
+ // a *solution*, but it's fine
562
555
}
563
556
debug_assert ! ( self . live_metas( ) . is_empty( ) ) ;
564
557
Ok ( results)
0 commit comments