Skip to content

Stop suggesting adding generic args for turbofish #100986

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Conversation

TaKO8Ki
Copy link
Member

@TaKO8Ki TaKO8Ki commented Aug 25, 2022

Fixes #100137

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Aug 25, 2022
@rustbot
Copy link
Collaborator

rustbot commented Aug 25, 2022

Some changes occurred in need_type_info.rs

cc @lcnr

@rust-highfive
Copy link
Contributor

r? @compiler-errors

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 25, 2022
--> $DIR/do-not-suggest-generic-arguments-for-turbofish.rs:8:5
|
LL | OhNo::C::<u32, _>;
| ^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `U` declared on the enum `OhNo`
Copy link
Member Author

@TaKO8Ki TaKO8Ki Aug 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this suggestion should point at the type parameter. I will work on it later in a follow-up PR.

@lcnr
Copy link
Contributor

lcnr commented Aug 29, 2022

I personally like the suggestions, even if the generic args are already specified, but include _. Maybe with a slightly changed wording. If you get an error with collect::<Vec<_>>() the correct fix would be collect::<Vec<MyType>>(), so we should still point at this collect call instead of searching for something else.

A more targeted fix for #100137 would be to not add an InsertableGenericArgs for enum types if there are explicit generic arguments on the variant. Because OhNo::<u32, _>::C is absolutely fine, and even preferred over OhNo::C::<u32, _>. This only breaks if the generic arguments are specified for both the enum and the variant

@bors
Copy link
Collaborator

bors commented Aug 29, 2022

☔ The latest upstream changes (presumably #101143) made this pull request unmergeable. Please resolve the merge conflicts.

@TaKO8Ki TaKO8Ki force-pushed the do-not-suggest-adding-generic-args-for-turbofish branch from 5228379 to a2b1543 Compare August 30, 2022 10:58
@compiler-errors
Copy link
Member

r=me with nit fixed

@compiler-errors compiler-errors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 7, 2022
@TaKO8Ki TaKO8Ki force-pushed the do-not-suggest-adding-generic-args-for-turbofish branch from a2b1543 to 4525796 Compare October 5, 2022 08:00
@TaKO8Ki
Copy link
Member Author

TaKO8Ki commented Oct 5, 2022

I forgot about this PR.

@bors r=compiler-errors

@bors
Copy link
Collaborator

bors commented Oct 5, 2022

📌 Commit 4525796 has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 5, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 5, 2022
Rollup of 5 pull requests

Successful merges:

 - rust-lang#100986 (Stop suggesting adding generic args for turbofish)
 - rust-lang#101061 (panic-on-uninit: adjust checks to 0x01-filling)
 - rust-lang#102440 (Only export `__tls_*` on wasm32-unknown-unknown.)
 - rust-lang#102496 (Suggest `.into()` when all other coercion suggestions fail)
 - rust-lang#102699 (Fix hamburger button color)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors
Copy link
Collaborator

bors commented Oct 5, 2022

⌛ Testing commit 4525796 with merge 24ac6a2...

@bors bors merged commit f8f5019 into rust-lang:master Oct 5, 2022
@rustbot rustbot added this to the 1.66.0 milestone Oct 5, 2022
@TaKO8Ki TaKO8Ki deleted the do-not-suggest-adding-generic-args-for-turbofish branch October 5, 2022 17:59
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect suggestion when type annotation on turbofished enum is needed
6 participants