@@ -15,51 +15,48 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
15
15
let opaque_ty = goal. predicate . projection_ty ;
16
16
let expected = goal. predicate . term . ty ( ) . expect ( "no such thing as an opaque const" ) ;
17
17
18
- match goal. param_env . reveal ( ) {
19
- Reveal :: UserFacing => match self . solver_mode ( ) {
20
- SolverMode :: Normal => {
21
- let Some ( opaque_ty_def_id) = opaque_ty. def_id . as_local ( ) else {
22
- return Err ( NoSolution ) ;
23
- } ;
24
- let opaque_ty =
25
- ty:: OpaqueTypeKey { def_id : opaque_ty_def_id, substs : opaque_ty. substs } ;
26
- // FIXME: at some point we should call queries without defining
27
- // new opaque types but having the existing opaque type definitions.
28
- // This will require moving this below "Prefer opaques registered already".
29
- if !self . can_define_opaque_ty ( opaque_ty_def_id) {
30
- return Err ( NoSolution ) ;
31
- }
32
- // FIXME: This may have issues when the substs contain aliases...
33
- match self . tcx ( ) . uses_unique_placeholders_ignoring_regions ( opaque_ty. substs ) {
34
- Err ( NotUniqueParam :: NotParam ( param) ) if param. is_non_region_infer ( ) => {
35
- return self . evaluate_added_goals_and_make_canonical_response (
36
- Certainty :: AMBIGUOUS ,
37
- ) ;
38
- }
39
- Err ( _) => {
40
- return Err ( NoSolution ) ;
41
- }
42
- Ok ( ( ) ) => { }
18
+ match ( goal. param_env . reveal ( ) , self . solver_mode ( ) ) {
19
+ ( Reveal :: UserFacing , SolverMode :: Normal ) => {
20
+ let Some ( opaque_ty_def_id) = opaque_ty. def_id . as_local ( ) else {
21
+ return Err ( NoSolution ) ;
22
+ } ;
23
+ let opaque_ty =
24
+ ty:: OpaqueTypeKey { def_id : opaque_ty_def_id, substs : opaque_ty. substs } ;
25
+ // FIXME: at some point we should call queries without defining
26
+ // new opaque types but having the existing opaque type definitions.
27
+ // This will require moving this below "Prefer opaques registered already".
28
+ if !self . can_define_opaque_ty ( opaque_ty_def_id) {
29
+ return Err ( NoSolution ) ;
30
+ }
31
+ // FIXME: This may have issues when the substs contain aliases...
32
+ match self . tcx ( ) . uses_unique_placeholders_ignoring_regions ( opaque_ty. substs ) {
33
+ Err ( NotUniqueParam :: NotParam ( param) ) if param. is_non_region_infer ( ) => {
34
+ return self . evaluate_added_goals_and_make_canonical_response (
35
+ Certainty :: AMBIGUOUS ,
36
+ ) ;
43
37
}
44
- // Prefer opaques registered already.
45
- let matches =
46
- self . unify_existing_opaque_tys ( goal. param_env , opaque_ty, expected) ;
47
- if !matches. is_empty ( ) {
48
- if let Some ( response) = self . try_merge_responses ( & matches) {
49
- return Ok ( response) ;
50
- } else {
51
- return self . flounder ( & matches) ;
52
- }
38
+ Err ( _) => {
39
+ return Err ( NoSolution ) ;
53
40
}
54
- // Otherwise, define a new opaque type
55
- self . register_opaque_ty ( opaque_ty, expected, goal. param_env ) ?;
56
- self . evaluate_added_goals_and_make_canonical_response ( Certainty :: Yes )
41
+ Ok ( ( ) ) => { }
57
42
}
58
- SolverMode :: Coherence => {
59
- self . evaluate_added_goals_and_make_canonical_response ( Certainty :: AMBIGUOUS )
43
+ // Prefer opaques registered already.
44
+ let matches = self . unify_existing_opaque_tys ( goal. param_env , opaque_ty, expected) ;
45
+ if !matches. is_empty ( ) {
46
+ if let Some ( response) = self . try_merge_responses ( & matches) {
47
+ return Ok ( response) ;
48
+ } else {
49
+ return self . flounder ( & matches) ;
50
+ }
60
51
}
61
- } ,
62
- Reveal :: All => {
52
+ // Otherwise, define a new opaque type
53
+ self . register_opaque_ty ( opaque_ty, expected, goal. param_env ) ?;
54
+ self . evaluate_added_goals_and_make_canonical_response ( Certainty :: Yes )
55
+ }
56
+ ( Reveal :: UserFacing , SolverMode :: Coherence ) => {
57
+ self . evaluate_added_goals_and_make_canonical_response ( Certainty :: AMBIGUOUS )
58
+ }
59
+ ( Reveal :: All , _) => {
63
60
// FIXME: Add an assertion that opaque type storage is empty.
64
61
let actual = tcx. type_of ( opaque_ty. def_id ) . subst ( tcx, opaque_ty. substs ) ;
65
62
self . eq ( goal. param_env , expected, actual) ?;
0 commit comments