about summary refs log tree commit diff
path: root/compiler/rustc_ty_utils/src
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2022-07-15 05:37:32 +0000
committerMichael Goulet <michael@errs.io>2022-07-22 18:58:07 +0000
commit22b2aae73720b8928859d3500119c9a47ff7bdb0 (patch)
treeb5d22cb58d7f25aa9a45e3cf98d185bd96c51422 /compiler/rustc_ty_utils/src
parent22d25f21dc008785f52e7c2833de4f4236b1066b (diff)
downloadrust-22b2aae73720b8928859d3500119c9a47ff7bdb0.tar.gz
rust-22b2aae73720b8928859d3500119c9a47ff7bdb0.zip
Do not resolve associated const when there is no provided value
Diffstat (limited to 'compiler/rustc_ty_utils/src')
-rw-r--r--compiler/rustc_ty_utils/src/instance.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/rustc_ty_utils/src/instance.rs b/compiler/rustc_ty_utils/src/instance.rs
index 5e58f237982..979e997f244 100644
--- a/compiler/rustc_ty_utils/src/instance.rs
+++ b/compiler/rustc_ty_utils/src/instance.rs
@@ -280,6 +280,11 @@ fn resolve_associated_item<'tcx>(
                 return Ok(None);
             }
 
+            // If the item does not have a value, then we cannot return an instance.
+            if !leaf_def.item.defaultness.has_value() {
+                return Ok(None);
+            }
+
             let substs = tcx.erase_regions(substs);
 
             // Check if we just resolved an associated `const` declaration from