@@ -4,6 +4,7 @@ use derive_where::derive_where;
4
4
#[ cfg( feature = "nightly" ) ]
5
5
use rustc_macros:: { HashStable_NoContext , TyDecodable , TyEncodable } ;
6
6
use rustc_type_ir:: data_structures:: { HashMap , HashSet , ensure_sufficient_stack} ;
7
+ use rustc_type_ir:: fast_reject:: DeepRejectCtxt ;
7
8
use rustc_type_ir:: fold:: { TypeFoldable , TypeFolder , TypeSuperFoldable } ;
8
9
use rustc_type_ir:: inherent:: * ;
9
10
use rustc_type_ir:: relate:: Relate ;
@@ -18,9 +19,9 @@ use crate::delegate::SolverDelegate;
18
19
use crate :: solve:: inspect:: { self , ProofTreeBuilder } ;
19
20
use crate :: solve:: search_graph:: SearchGraph ;
20
21
use crate :: solve:: {
21
- CanonicalInput , CanonicalResponse , Certainty , FIXPOINT_STEP_LIMIT , Goal , GoalEvaluationKind ,
22
- GoalSource , HasChanged , NestedNormalizationGoals , NoSolution , PredefinedOpaquesData ,
23
- QueryResult , SolverMode ,
22
+ CanonicalInput , Certainty , FIXPOINT_STEP_LIMIT , Goal , GoalEvaluationKind , GoalSource ,
23
+ HasChanged , NestedNormalizationGoals , NoSolution , PredefinedOpaquesData , QueryResult ,
24
+ SolverMode ,
24
25
} ;
25
26
26
27
pub ( super ) mod canonical;
@@ -987,40 +988,22 @@ where
987
988
988
989
// Do something for each opaque/hidden pair defined with `def_id` in the
989
990
// current inference context.
990
- pub ( super ) fn unify_existing_opaque_tys (
991
+ pub ( super ) fn probe_existing_opaque_ty (
991
992
& mut self ,
992
- param_env : I :: ParamEnv ,
993
993
key : ty:: OpaqueTypeKey < I > ,
994
- ty : I :: Ty ,
995
- ) -> Vec < CanonicalResponse < I > > {
996
- // FIXME: Super inefficient to be cloning this...
997
- let opaques = self . delegate . clone_opaque_types_for_query_response ( ) ;
998
-
999
- let mut values = vec ! [ ] ;
1000
- for ( candidate_key, candidate_ty) in opaques {
1001
- if candidate_key. def_id != key. def_id {
1002
- continue ;
1003
- }
1004
- values. extend (
1005
- self . probe ( |result| inspect:: ProbeKind :: OpaqueTypeStorageLookup {
1006
- result : * result,
1007
- } )
1008
- . enter ( |ecx| {
1009
- for ( a, b) in std:: iter:: zip ( candidate_key. args . iter ( ) , key. args . iter ( ) ) {
1010
- ecx. eq ( param_env, a, b) ?;
1011
- }
1012
- ecx. eq ( param_env, candidate_ty, ty) ?;
1013
- ecx. add_item_bounds_for_hidden_type (
1014
- candidate_key. def_id . into ( ) ,
1015
- candidate_key. args ,
1016
- param_env,
1017
- candidate_ty,
1018
- ) ;
1019
- ecx. evaluate_added_goals_and_make_canonical_response ( Certainty :: Yes )
1020
- } ) ,
994
+ ) -> Option < ( ty:: OpaqueTypeKey < I > , I :: Ty ) > {
995
+ let mut matching =
996
+ self . delegate . clone_opaque_types_for_query_response ( ) . into_iter ( ) . filter (
997
+ |( candidate_key, _) | {
998
+ candidate_key. def_id == key. def_id
999
+ && DeepRejectCtxt :: relate_rigid_rigid ( self . cx ( ) )
1000
+ . args_may_unify ( candidate_key. args , key. args )
1001
+ } ,
1021
1002
) ;
1022
- }
1023
- values
1003
+ let first = matching. next ( ) ;
1004
+ let second = matching. next ( ) ;
1005
+ assert_eq ! ( second, None ) ;
1006
+ first
1024
1007
}
1025
1008
1026
1009
// Try to evaluate a const, or return `None` if the const is too generic.
0 commit comments