Skip to content

Commit b962488

Browse files
authored
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?
2 parents d1fd0be + 9ad2f34 commit b962488

File tree

0 file changed

+0
-0
lines changed

    0 file changed

    +0
    -0
    lines changed

    0 commit comments

    Comments
     (0)