@@ -140,20 +140,40 @@ impl<'tcx> InferCtxt<'tcx> {
140
140
return None ;
141
141
}
142
142
143
- if let ty:: Alias ( ty:: Opaque , ty :: AliasTy { def_id : b_def_id , .. } ) = * b. kind ( ) {
143
+ if let ty:: Alias ( ty:: Opaque , b ) = * b. kind ( ) {
144
144
// We could accept this, but there are various ways to handle this situation, and we don't
145
145
// want to make a decision on it right now. Likely this case is so super rare anyway, that
146
146
// no one encounters it in practice.
147
147
// It does occur however in `fn fut() -> impl Future<Output = i32> { async { 42 } }`,
148
148
// where it is of no concern, so we only check for TAITs.
149
- if self . can_define_opaque_ty ( b_def_id )
150
- && self . tcx . is_type_alias_impl_trait ( b_def_id )
149
+ if self . can_define_opaque_ty ( b . def_id )
150
+ && self . tcx . is_type_alias_impl_trait ( b . def_id )
151
151
{
152
- self . tcx . dcx ( ) . emit_err ( OpaqueHiddenTypeDiag {
152
+ let guar = self . tcx . dcx ( ) . emit_err ( OpaqueHiddenTypeDiag {
153
153
span : cause. span ,
154
- hidden_type : self . tcx . def_span ( b_def_id ) ,
154
+ hidden_type : self . tcx . def_span ( b . def_id ) ,
155
155
opaque_type : self . tcx . def_span ( def_id) ,
156
156
} ) ;
157
+ let mut obligations = vec ! [ ] ;
158
+ return Some (
159
+ try {
160
+ self . insert_hidden_type (
161
+ OpaqueTypeKey { def_id, args } ,
162
+ & cause,
163
+ param_env,
164
+ Ty :: new_error ( self . tcx , guar) ,
165
+ & mut obligations,
166
+ ) ?;
167
+ self . insert_hidden_type (
168
+ OpaqueTypeKey { def_id : b. def_id . expect_local ( ) , args : b. args } ,
169
+ & cause,
170
+ param_env,
171
+ Ty :: new_error ( self . tcx , guar) ,
172
+ & mut obligations,
173
+ ) ?;
174
+ InferOk { value : ( ) , obligations }
175
+ } ,
176
+ ) ;
157
177
}
158
178
}
159
179
Some ( self . register_hidden_type (
0 commit comments