start hovering default values of generic constants
This commit is contained in:
parent
d548146c30
commit
fec5ff9890
@ -366,6 +366,11 @@ fn write_generic_params(
|
||||
delim(f)?;
|
||||
write!(f, "const {}: ", name.display(f.db.upcast()))?;
|
||||
c.ty.hir_fmt(f)?;
|
||||
|
||||
if let Some(default) = &c.default {
|
||||
f.write_str(" = ")?;
|
||||
write!(f, "{}", default.display(f.db.upcast()))?;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3335,7 +3335,50 @@ fn const_generic_order() {
|
||||
```
|
||||
|
||||
```rust
|
||||
struct ST<const C: usize, T = Foo>
|
||||
struct ST<const C: usize = 1, T = Foo>
|
||||
```
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn const_generic_default_value() {
|
||||
check(
|
||||
r#"
|
||||
struct Foo;
|
||||
struct S$0T<const C: usize = {40 + 2}, T = Foo>(T);
|
||||
"#,
|
||||
expect![[r#"
|
||||
*ST*
|
||||
|
||||
```rust
|
||||
test
|
||||
```
|
||||
|
||||
```rust
|
||||
struct ST<const C: usize = {const}, T = Foo>
|
||||
```
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn const_generic_default_value_2() {
|
||||
check(
|
||||
r#"
|
||||
struct Foo;
|
||||
const VAL = 1;
|
||||
struct S$0T<const C: usize = VAL, T = Foo>(T);
|
||||
"#,
|
||||
expect![[r#"
|
||||
*ST*
|
||||
|
||||
```rust
|
||||
test
|
||||
```
|
||||
|
||||
```rust
|
||||
struct ST<const C: usize = VAL, T = Foo>
|
||||
```
|
||||
"#]],
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user