mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Add tests. The tests with coercion fail, but I have no clue why.
This commit is contained in:
parent
cf696c0ed6
commit
67a9c457e6
1 changed files with 64 additions and 0 deletions
|
@ -4510,4 +4510,68 @@ fn foo() -> Option<()> {
|
||||||
```"#]],
|
```"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn hover_deref_expr() {
|
||||||
|
check_hover_range(
|
||||||
|
r#"
|
||||||
|
//- minicore: deref
|
||||||
|
struct DerefExample<T> {
|
||||||
|
value: T
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> Deref for DerefExample<T> {
|
||||||
|
type Target = T;
|
||||||
|
|
||||||
|
fn deref(&self) -> &Self::Target {
|
||||||
|
&self.value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn foo() {
|
||||||
|
let x = DerefExample { value: 0 };
|
||||||
|
let y: i32 = $0*x$0;
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
```text
|
||||||
|
Type: i32
|
||||||
|
Derefenced from: DerefExample<i32>
|
||||||
|
```
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn hover_deref_expr_with_coercion() {
|
||||||
|
check_hover_range(
|
||||||
|
r#"
|
||||||
|
//- minicore: deref
|
||||||
|
struct DerefExample<T> {
|
||||||
|
value: T
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> Deref for DerefExample<T> {
|
||||||
|
type Target = T;
|
||||||
|
|
||||||
|
fn deref(&self) -> &Self::Target {
|
||||||
|
&self.value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn foo() {
|
||||||
|
let x = DerefExample { value: &&&&&0 };
|
||||||
|
let y: &i32 = $0*x$0;
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
```text
|
||||||
|
Type: &&&&&i32
|
||||||
|
Coerced to: &i32
|
||||||
|
Derefenced from: DerefExample<&&&&&i32>
|
||||||
|
```
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue