about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src
diff options
context:
space:
mode:
authorBoxy <rust@boxyuwu.dev>2024-08-19 01:14:09 +0100
committerBoxy <rust@boxyuwu.dev>2024-08-19 01:14:22 +0100
commitb8eedfa3d217e19f806fd4f46a89b074f5e8659f (patch)
treed6b049a54b54f6086ec0314b887ba7fcaf4c59f7 /compiler/rustc_resolve/src
parentf04f6ca36d2439375d20a98be013384afbab0782 (diff)
downloadrust-b8eedfa3d217e19f806fd4f46a89b074f5e8659f.tar.gz
rust-b8eedfa3d217e19f806fd4f46a89b074f5e8659f.zip
Retroactively feature gate `ConstArgKind::Path`
Diffstat (limited to 'compiler/rustc_resolve/src')
-rw-r--r--compiler/rustc_resolve/src/def_collector.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/compiler/rustc_resolve/src/def_collector.rs b/compiler/rustc_resolve/src/def_collector.rs
index ed23870dfdf..3595db78e93 100644
--- a/compiler/rustc_resolve/src/def_collector.rs
+++ b/compiler/rustc_resolve/src/def_collector.rs
@@ -314,13 +314,15 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
     }
 
     fn visit_anon_const(&mut self, constant: &'a AnonConst) {
-        // HACK(min_generic_const_args): don't create defs for anon consts if we think they will
-        // later be turned into ConstArgKind::Path's. because this is before resolve is done, we
-        // may accidentally identify a construction of a unit struct as a param and not create a
-        // def. we'll then create a def later in ast lowering in this case. the parent of nested
-        // items will be messed up, but that's ok because there can't be any if we're just looking
-        // for bare idents.
-        if constant.value.is_potential_trivial_const_arg() {
+        if self.resolver.tcx.features().const_arg_path
+            && constant.value.is_potential_trivial_const_arg()
+        {
+            // HACK(min_generic_const_args): don't create defs for anon consts if we think they will
+            // later be turned into ConstArgKind::Path's. because this is before resolve is done, we
+            // may accidentally identify a construction of a unit struct as a param and not create a
+            // def. we'll then create a def later in ast lowering in this case. the parent of nested
+            // items will be messed up, but that's ok because there can't be any if we're just looking
+            // for bare idents.
             visit::walk_anon_const(self, constant)
         } else {
             let def =