File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
compiler/rustc_trait_selection/src/solve/project_goals Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,10 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
44
44
// Prefer opaques registered already.
45
45
let opaque_type_key =
46
46
ty:: OpaqueTypeKey { def_id : opaque_ty_def_id, args : opaque_ty. args } ;
47
+ // FIXME: This also unifies the previous hidden type with the expected.
48
+ //
49
+ // If that fails, we insert `expected` as a new hidden type instead of
50
+ // eagerly emitting an error.
47
51
let matches =
48
52
self . unify_existing_opaque_tys ( goal. param_env , opaque_type_key, expected) ;
49
53
if !matches. is_empty ( ) {
@@ -53,6 +57,23 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
53
57
return self . flounder ( & matches) ;
54
58
}
55
59
}
60
+
61
+ let expected = match self . try_normalize_ty ( goal. param_env , expected) {
62
+ Some ( ty) => {
63
+ if ty. is_ty_var ( ) {
64
+ return self . evaluate_added_goals_and_make_canonical_response (
65
+ Certainty :: AMBIGUOUS ,
66
+ ) ;
67
+ } else {
68
+ ty
69
+ }
70
+ }
71
+ None => {
72
+ return self
73
+ . evaluate_added_goals_and_make_canonical_response ( Certainty :: OVERFLOW ) ;
74
+ }
75
+ } ;
76
+
56
77
// Otherwise, define a new opaque type
57
78
self . insert_hidden_type ( opaque_type_key, goal. param_env , expected) ?;
58
79
self . add_item_bounds_for_hidden_type (
You can’t perform that action at this time.
0 commit comments