Unnamed repository; edit this file 'description' to name the repository.
Auto merge of #14285 - HKalbasi:mir, r=Veykril
Evaluate consts in `path_to_const` fix #14275
bors 2023-03-08
parent c951093 · parent cf47c15 · commit db64f3a
-rw-r--r--crates/hir-ty/src/consteval.rs1
-rw-r--r--crates/hir-ty/src/tests/simple.rs14
2 files changed, 15 insertions, 0 deletions
diff --git a/crates/hir-ty/src/consteval.rs b/crates/hir-ty/src/consteval.rs
index 5830c48988..2762bdc6ca 100644
--- a/crates/hir-ty/src/consteval.rs
+++ b/crates/hir-ty/src/consteval.rs
@@ -100,6 +100,7 @@ pub(crate) fn path_to_const(
};
Some(ConstData { ty, value }.intern(Interner))
}
+ Some(ValueNs::ConstId(c)) => db.const_eval(c).ok(),
_ => None,
}
}
diff --git a/crates/hir-ty/src/tests/simple.rs b/crates/hir-ty/src/tests/simple.rs
index 1a07a2c51d..1648396eb1 100644
--- a/crates/hir-ty/src/tests/simple.rs
+++ b/crates/hir-ty/src/tests/simple.rs
@@ -3274,3 +3274,17 @@ fn func() {
"#]],
);
}
+
+#[test]
+fn issue_14275() {
+ check_types(
+ r#"
+struct Foo<const T: bool>;
+fn main() {
+ const B: bool = false;
+ let foo = Foo::<B>;
+ //^^^ Foo<false>
+}
+"#,
+ );
+}