File tree 2 files changed +17
-1
lines changed
compiler/rustc_borrowck/src
2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -179,7 +179,11 @@ pub(crate) fn compute_regions<'a, 'tcx>(
179
179
infcx. set_tainted_by_errors ( guar) ;
180
180
}
181
181
182
- let remapped_opaque_tys = regioncx. infer_opaque_types ( infcx, opaque_type_values) ;
182
+ let remapped_opaque_tys = regioncx. infer_opaque_types (
183
+ infcx,
184
+ infcx. tcx . is_typeck_child ( body. source . def_id ( ) ) ,
185
+ opaque_type_values,
186
+ ) ;
183
187
184
188
NllOutput {
185
189
regioncx,
Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
65
65
pub ( crate ) fn infer_opaque_types (
66
66
& self ,
67
67
infcx : & InferCtxt < ' tcx > ,
68
+ is_typeck_child : bool ,
68
69
opaque_ty_decls : FxIndexMap < OpaqueTypeKey < ' tcx > , OpaqueHiddenType < ' tcx > > ,
69
70
) -> FxIndexMap < LocalDefId , OpaqueHiddenType < ' tcx > > {
70
71
let mut result: FxIndexMap < LocalDefId , OpaqueHiddenType < ' tcx > > = FxIndexMap :: default ( ) ;
@@ -73,6 +74,17 @@ impl<'tcx> RegionInferenceContext<'tcx> {
73
74
74
75
for ( opaque_type_key, concrete_type) in opaque_ty_decls {
75
76
debug ! ( ?opaque_type_key, ?concrete_type) ;
77
+ if is_typeck_child && opaque_type_key. args . iter ( ) . any ( |arg| arg. as_region ( ) . is_some ( ) ) {
78
+ let guar = infcx. dcx ( ) . span_err (
79
+ concrete_type. span ,
80
+ "defining of opaque type in closure involving regions" ,
81
+ ) ;
82
+ result. insert ( opaque_type_key. def_id , OpaqueHiddenType {
83
+ span : concrete_type. span ,
84
+ ty : Ty :: new_error ( infcx. tcx , guar) ,
85
+ } ) ;
86
+ continue ;
87
+ }
76
88
77
89
let mut arg_regions: Vec < ( ty:: RegionVid , ty:: Region < ' _ > ) > =
78
90
vec ! [ ( self . universal_regions( ) . fr_static, infcx. tcx. lifetimes. re_static) ] ;
You can’t perform that action at this time.
0 commit comments