diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-03-02 15:28:41 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-03-02 15:28:41 +0000 |
commit | 04abf80b5f51b0efd1884fabc441bef16b75e89a (patch) | |
tree | c83a205fd1684eb7427c20d99a9d4bc3f07ff5ae /crates/cfg | |
parent | f8152171bbe160c4273d692d42c06eb7c6d66e1a (diff) | |
parent | 2c3c728e0aea90f80b6d066f97e59663371e91c5 (diff) |
Merge #7824
7824: feat: add type ascription r=matklad a=conradludgate
Based on this conversation: https://twitter.com/rust_analyzer/status/1366092401278922757
Built off of `add_turbo_fish`, finds the current `let` statement, checks if it has type/turbofish already and checks if the rhs function is generic.
There's one case I couldn't figure out how to implement that would be nice:
```rust
#[test]
fn add_type_ascription_function_result() {
check_assist(
add_type_ascription,
r#"
fn make<T>() -> Result<T, &'static str> {}
fn main() {
let x = make()$0;
}
"#,
r#"
fn make<T>() -> Result<T, &'static str> {}
fn main() {
let x: Result<${0:_}, &'static str> = make();
}
"#,
);
}
```
The `Function::ret_type` fn wasn't returning anything much useful so I'm not sure how to identity such scenarios just yet
Co-authored-by: Conrad Ludgate <[email protected]>
Diffstat (limited to 'crates/cfg')
0 files changed, 0 insertions, 0 deletions