about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEduard-Mihai Burtescu <edy.burt@gmail.com>2019-11-30 01:15:15 +0200
committerEduard-Mihai Burtescu <edy.burt@gmail.com>2019-11-30 01:15:15 +0200
commit584ede5f3034af8b1b64518385e201de4942637c (patch)
tree6c61bd8b940beefaa7ea04f217f81f14d7d32ecb
parentde30d319761c6fed04c87a41e62828d0b275e01e (diff)
downloadrust-584ede5f3034af8b1b64518385e201de4942637c.tar.gz
rust-584ede5f3034af8b1b64518385e201de4942637c.zip
rustc_typeck: gate AnonConst's generics on feature(const_generics).
-rw-r--r--src/librustc_typeck/collect.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs
index 652f081e176..301b0ff3503 100644
--- a/src/librustc_typeck/collect.rs
+++ b/src/librustc_typeck/collect.rs
@@ -909,14 +909,12 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::Generics {
             let parent_id = tcx.hir().get_parent_item(hir_id);
             Some(tcx.hir().local_def_id(parent_id))
         }
-        // FIXME(#43408) enable this in all cases when we get lazy normalization.
-        Node::AnonConst(&anon_const) => {
-            // HACK(eddyb) this provides the correct generics when the workaround
-            // for a const parameter `AnonConst` is being used elsewhere, as then
-            // there won't be the kind of cyclic dependency blocking #43408.
-            let expr = &tcx.hir().body(anon_const.body).value;
-            let icx = ItemCtxt::new(tcx, def_id);
-            if AstConv::const_param_def_id(&icx, expr).is_some() {
+        // FIXME(#43408) enable this always when we get lazy normalization.
+        Node::AnonConst(_) => {
+            // HACK(eddyb) this provides the correct generics when
+            // `feature(const_generics)` is enabled, so that const expressions
+            // used with const generics, e.g. `Foo<{N+1}>`, can work at all.
+            if tcx.features().const_generics {
                 let parent_id = tcx.hir().get_parent_item(hir_id);
                 Some(tcx.hir().local_def_id(parent_id))
             } else {