Skip to content

Commit a59b7ea

Browse files
committed
Also fix lifetimes and consts in opaque types
1 parent 6b47cba commit a59b7ea

File tree

1 file changed

+15
-2
lines changed
  • src/librustc_typeck/check

1 file changed

+15
-2
lines changed

src/librustc_typeck/check/mod.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ fn fixup_opaque_types<'tcx, T>(tcx: TyCtxt<'tcx>, val: &T) -> T where T: TypeFol
893893
match ty.kind {
894894
ty::Opaque(def_id, substs) => {
895895
debug!("fixup_opaque_types: found type {:?}", ty);
896-
if ty.has_infer_types() {
896+
if ty.needs_infer() {
897897
let new_substs = InternalSubsts::for_item(self.tcx, def_id, |param, _| {
898898
let old_param = substs[param.index as usize];
899899
match old_param.unpack() {
@@ -905,7 +905,20 @@ fn fixup_opaque_types<'tcx, T>(tcx: TyCtxt<'tcx>, val: &T) -> T where T: TypeFol
905905
old_param.fold_with(self)
906906
}
907907
},
908-
_ => old_param
908+
GenericArgKind::Const(old_const) => {
909+
if let ConstValue::Infer(_) = old_const.val {
910+
self.tcx.mk_param_from_def(param)
911+
} else {
912+
old_param.fold_with(self)
913+
}
914+
}
915+
GenericArgKind::Lifetime(old_region) => {
916+
if let RegionKind::ReVar(_) = old_region {
917+
self.tcx.mk_param_from_def(param)
918+
} else {
919+
old_param.fold_with(self)
920+
}
921+
}
909922
}
910923
});
911924
let new_ty = self.tcx.mk_opaque(def_id, new_substs);

0 commit comments

Comments
 (0)