diff options
| author | hkalbasi <hamidrezakalbasi@protonmail.com> | 2023-03-08 16:40:58 +0330 |
|---|---|---|
| committer | hkalbasi <hamidrezakalbasi@protonmail.com> | 2023-03-08 16:42:20 +0330 |
| commit | cf47c158215a6e106f78843d08344889bce2945e (patch) | |
| tree | ed38c6ab3704cc4d16cdd20dc57a32ea27d15689 | |
| parent | c9510933a5e1abe50f86c838a17b588f2f93344b (diff) | |
| download | rust-cf47c158215a6e106f78843d08344889bce2945e.tar.gz rust-cf47c158215a6e106f78843d08344889bce2945e.zip | |
Evaluate consts in `path_to_const`
| -rw-r--r-- | crates/hir-ty/src/consteval.rs | 1 | ||||
| -rw-r--r-- | crates/hir-ty/src/tests/simple.rs | 14 |
2 files changed, 15 insertions, 0 deletions
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<const T: bool>; +fn main() { + const B: bool = false; + let foo = Foo::<B>; + //^^^ Foo<false> +} +"#, + ); +} |
