Skip to content

Redundant suggestion on E0283 #97899

New issue

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

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

Already on GitHub? Sign in to your account

Closed
estebank opened this issue Jun 8, 2022 · 3 comments
Closed

Redundant suggestion on E0283 #97899

estebank opened this issue Jun 8, 2022 · 3 comments
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-inference Area: Type inference A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. D-verbose Diagnostics: Too much output caused by a single piece of incorrect code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@estebank
Copy link
Contributor

estebank commented Jun 8, 2022

error[E0283]: type annotations needed
 --> src/main.rs:2:44
  |
2 |     Some(()).into_iter().filter(|_| false).collect();
  |                                            ^^^^^^^ cannot infer type of the type parameter `B` declared on the associated function `collect`
  |
  = note: cannot satisfy `_: FromIterator<()>`
note: required by a bound in `collect`
help: consider specifying the generic argument
  |
2 |     Some(()).into_iter().filter(|_| false).collect::<B>();
  |                                                   +++++
help: consider specifying the type argument in the function call
  |
2 |     Some(()).into_iter().filter(|_| false).collect::<B>();
  |                                                   +++++

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=459892bb874954bdc6749fea03bfcf6d

@estebank estebank added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-inference Area: Type inference A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. D-verbose Diagnostics: Too much output caused by a single piece of incorrect code. labels Jun 8, 2022
@ChayimFriedman2
Copy link
Contributor

It duplicates the suggestion even without the .filter() call (https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=61df79395f43232a9d13a924c2ac860c) and on any iterator type I tried (not just IntoIterator).

@TaKO8Ki
Copy link
Member

TaKO8Ki commented Jun 11, 2022

#93506 is related to this.

@TaKO8Ki TaKO8Ki self-assigned this Jun 14, 2022
@estebank
Copy link
Contributor Author

Closing in favor of #93506

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-inference Area: Type inference A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. D-verbose Diagnostics: Too much output caused by a single piece of incorrect code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants