about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-03-22 20:31:29 +0100
committerGitHub <noreply@github.com>2024-03-22 20:31:29 +0100
commit4e594572b44a06f8b63529452a08730f9697f390 (patch)
treebd08ed32f5a781f18df728c3e2298a033e8f8b8d /compiler/rustc_codegen_llvm/src
parentaa184c558f9705dbe4bcf875e2218e01b250b850 (diff)
parent3bbbe3cf64ca15e2fb746661e8fa069c6de640e8 (diff)
downloadrust-4e594572b44a06f8b63529452a08730f9697f390.tar.gz
rust-4e594572b44a06f8b63529452a08730f9697f390.zip
Rollup merge of #122651 - kornelski:flat-turbofish, r=spastorino,compiler-errors
Suggest `_` for missing generic arguments in turbofish

The compiler may suggest unusable generic type names for missing generic arguments in an expression context:

```rust
fn main() {
    (0..1).collect::<Vec>()
}
```

> help: add missing generic argument
>
>      (0..1).collect::<Vec<T>>()

but `T` is not a valid name in this context, and this suggestion won't compile.

I've changed it to use `_` inside method calls (turbofish), so it will suggest `(0..1).collect::<Vec<_>>()` which _may_ compile.

It's possible that the suggested `_` will be ambiguous, but there is very extensive E0283 that will help resolve that, which is more helpful than a basic "cannot find type `T` in this scope" users would get otherwise.

Out of caution to limit scope of the change I've limited it to just turbofish, but I suspect `_` could be the better choice in more cases. Perhaps in all expressions?
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions