]> git.lizzy.rs Git - rust.git/commitdiff
Handle `ConstValue::Placeholder` in `canonicalizer`
authorvarkor <github@varkor.com>
Tue, 12 Mar 2019 20:55:19 +0000 (20:55 +0000)
committervarkor <github@varkor.com>
Wed, 1 May 2019 22:10:57 +0000 (23:10 +0100)
src/librustc/infer/canonical/canonicalizer.rs
src/librustc/infer/canonical/mod.rs

index 22e5767df3339685ec8ad826c2fd928ad422f8da..95310996c1859b1092544bebf79947e64b85aac3 100644 (file)
@@ -454,9 +454,9 @@ fn fold_const(&mut self, c: &'tcx ty::LazyConst<'tcx>) -> &'tcx ty::LazyConst<'t
                             }
                             return self.canonicalize_const_var(
                                 CanonicalVarInfo {
-                                    kind: CanonicalVarKind::Const(ui)
+                                    kind: CanonicalVarKind::Const(ui),
                                 },
-                                c
+                                c,
                             );
                         }
                     }
@@ -471,6 +471,14 @@ fn fold_const(&mut self, c: &'tcx ty::LazyConst<'tcx>) -> &'tcx ty::LazyConst<'t
                         return c;
                     }
                 }
+                ConstValue::Placeholder(placeholder) => {
+                    return self.canonicalize_const_var(
+                        CanonicalVarInfo {
+                            kind: CanonicalVarKind::PlaceholderConst(placeholder),
+                        },
+                        c,
+                    );
+                }
                 _ => {}
             }
         }
index 9fad1f47f13726f8452a53c7e56838cc81a74bf0..a5694818b98109587c06ecc95794ede97decbe46 100644 (file)
@@ -414,8 +414,17 @@ fn instantiate_canonical_var(
             CanonicalVarKind::PlaceholderConst(
                 ty::PlaceholderConst { universe, name },
             ) => {
-                let _ = (universe, name);
-                unimplemented!() // FIXME(const_generics)
+                let universe_mapped = universe_map(universe);
+                let placeholder_mapped = ty::PlaceholderConst {
+                    universe: universe_mapped,
+                    name,
+                };
+                self.tcx.mk_lazy_const(ty::LazyConst::Evaluated(
+                    ty::Const {
+                        val: ConstValue::Placeholder(placeholder_mapped),
+                        ty: self.tcx.types.err, // FIXME(const_generics)
+                    }
+                )).into()
             }
         }
     }