]> git.lizzy.rs Git - rust.git/commitdiff
Merge #7824
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>
Tue, 2 Mar 2021 15:28:41 +0000 (15:28 +0000)
committerGitHub <noreply@github.com>
Tue, 2 Mar 2021 15:28:41 +0000 (15:28 +0000)
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 <conradludgate@gmail.com>

Trivial merge