From cf47c158215a6e106f78843d08344889bce2945e Mon Sep 17 00:00:00 2001 From: hkalbasi Date: Wed, 8 Mar 2023 16:40:58 +0330 Subject: [PATCH] Evaluate consts in `path_to_const` --- crates/hir-ty/src/consteval.rs | 1 + crates/hir-ty/src/tests/simple.rs | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/crates/hir-ty/src/consteval.rs b/crates/hir-ty/src/consteval.rs index 5830c48988f..2762bdc6ca8 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 1a07a2c51d8..1648396eb1a 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; +fn main() { + const B: bool = false; + let foo = Foo::; + //^^^ Foo +} +"#, + ); +}