mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Evaluate constants in array repeat expression
This commit is contained in:
parent
7b7a1ed062
commit
75c2acae6e
5 changed files with 94 additions and 27 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue