11112: Evaluate constants in array repeat expression r=HKalbasi a=HKalbasi

cc #8655 

Co-authored-by: hkalbasi <hamidrezakalbasi@protonmail.com>
This commit is contained in:
bors[bot] 2022-01-04 21:51:37 +00:00 committed by GitHub
commit ac3ea3e81c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 94 additions and 27 deletions

View file

@ -3350,6 +3350,31 @@ const FOO$0: usize = 1 << 10;
check(
r#"
/// This is a doc
const FOO$0: usize = {
let b = 4;
let a = { let b = 2; let a = b; a } + { let a = 1; a + b };
a
};
"#,
expect![[r#"
*FOO*
```rust
test
```
```rust
const FOO: usize = 7
```
---
This is a doc
"#]],
);
check(
r#"
/// This is a doc
const FOO$0: usize = 2 - 3;
"#,
expect![[r#"
@ -3443,6 +3468,24 @@ fn foo() {
);
}
#[test]
fn array_repeat_exp() {
check(
r#"
fn main() {
let til$0e4 = [0_u32; (4 * 8 * 8) / 32];
}
"#,
expect![[r#"
*tile4*
```rust
let tile4: [u32; 8]
```
"#]],
);
}
#[test]
fn hover_mod_def() {
check(