about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAaron Hill <aa1ronham@gmail.com>2019-11-11 13:31:46 -0500
committerAaron Hill <aa1ronham@gmail.com>2019-11-24 14:37:24 -0500
commita59b7eabe691695c66a9d3b95735121af1ba0166 (patch)
treea7b58c3e994cb2ff11ff758eb12a3390f0de1cca
parent6b47cbaee6ae009937bf796da9fb5ae662d5c9f1 (diff)
downloadrust-a59b7eabe691695c66a9d3b95735121af1ba0166.tar.gz
rust-a59b7eabe691695c66a9d3b95735121af1ba0166.zip
Also fix lifetimes and consts in opaque types
-rw-r--r--src/librustc_typeck/check/mod.rs17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index c0b49bb5918..a6dc4fc851f 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -893,7 +893,7 @@ fn fixup_opaque_types<'tcx, T>(tcx: TyCtxt<'tcx>, val: &T) -> T where T: TypeFol
             match ty.kind {
                 ty::Opaque(def_id, substs) => {
                     debug!("fixup_opaque_types: found type {:?}", ty);
-                    if ty.has_infer_types() {
+                    if ty.needs_infer() {
                         let new_substs = InternalSubsts::for_item(self.tcx, def_id, |param, _| {
                             let old_param = substs[param.index as usize];
                             match old_param.unpack() {
@@ -905,7 +905,20 @@ fn fixup_opaque_types<'tcx, T>(tcx: TyCtxt<'tcx>, val: &T) -> T where T: TypeFol
                                         old_param.fold_with(self)
                                     }
                                 },
-                                _ => old_param
+                                GenericArgKind::Const(old_const) => {
+                                    if let ConstValue::Infer(_) = old_const.val {
+                                        self.tcx.mk_param_from_def(param)
+                                    } else {
+                                        old_param.fold_with(self)
+                                    }
+                                }
+                                GenericArgKind::Lifetime(old_region) => {
+                                    if let RegionKind::ReVar(_) = old_region {
+                                        self.tcx.mk_param_from_def(param)
+                                    } else {
+                                        old_param.fold_with(self)
+                                    }
+                                }
                             }
                         });
                         let new_ty = self.tcx.mk_opaque(def_id, new_substs);