Skip to content

Fix bad suggestion for clone/is_some in field init shorthand #109355

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

Merged
merged 1 commit into from
Mar 25, 2023

Conversation

chenyukang
Copy link
Member

Fixes #108470

@rustbot
Copy link
Collaborator

rustbot commented Mar 19, 2023

r? @oli-obk

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 19, 2023
@compiler-errors
Copy link
Member

I think you can use maybe_get_struct_pattern_shorthand_field here instead of matching on the hir yourself?

@compiler-errors
Copy link
Member

Or better yet -- i wonder if we could make an even better helper method that simplifies the duplicated logic between all of the suggestions that handle field init shorthand syntax specially...

@chenyukang
Copy link
Member Author

Or better yet -- i wonder if we could make an even better helper method that simplifies the duplicated logic between all of the suggestions that handle field init shorthand syntax specially...

try to move the span part to maybe_get_struct_pattern_shorthand_field, seems better now?

@compiler-errors
Copy link
Member

Hmm... I don't really like the new calls to span_to_snippet... I wonder if we could just return a Vec<(Span, String)> that's either "field: " or empty that we can then use for the multipart suggestion...

@oli-obk
Copy link
Contributor

oli-obk commented Mar 20, 2023

r? @compiler-errors

@rustbot rustbot assigned compiler-errors and unassigned oli-obk Mar 20, 2023
@chenyukang
Copy link
Member Author

Hmm... I don't really like the new calls to span_to_snippet... I wonder if we could just return a Vec<(Span, String)> that's either "field: " or empty that we can then use for the multipart suggestion...

I have a try, but seems maybe_get_struct_pattern_shorthand_field is not only used for fields and multipart suggestion, so we need to return an Option<> which also will make the code somehow not easy to read.

I rollback my last commit, and use the original maybe_get_struct_pattern_shorthand_field now.

@compiler-errors
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Mar 24, 2023

📌 Commit 64f6e4f 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-review Status: Awaiting review from the assignee but also interested parties. labels Mar 24, 2023
@compiler-errors
Copy link
Member

@bors rollup

bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 25, 2023
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#109355 (Fix bad suggestion for clone/is_some in field init shorthand)
 - rust-lang#109484 (Bugfix: avoid panic on invalid json output from libtest)
 - rust-lang#109539 (Refactor `find_*_stability` functions)
 - rust-lang#109542 (rustdoc: clean up `storage.js`)
 - rust-lang#109545 (Deeply check well-formedness of return-position `impl Trait` in trait)
 - rust-lang#109568 (miri: fix raw pointer dyn receivers)
 - rust-lang#109570 (Add GUI test for "Auto-hide item methods' documentation" setting)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit f3d3f35 into rust-lang:master Mar 25, 2023
@rustbot rustbot added this to the 1.70.0 milestone Mar 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in 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.

Bad suggestion for clone in field init shorthand
5 participants