Skip to content
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

Improve suggest construct with literal syntax instead of calling #139014

Merged
merged 2 commits into from
Mar 27, 2025

Conversation

xizheyin
Copy link
Contributor

@xizheyin xizheyin commented Mar 27, 2025

Fixes #138931

When constructing a structure through a format similar to calling a constructor, we can use verbose suggestions to hint at using literal syntax for clearer advice. The case of multiple fields is also considered here, provided that the field has the same number of arguments as CallExpr.

r? compiler

@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 27, 2025
@oli-obk
Copy link
Contributor

oli-obk commented Mar 27, 2025

Please make your ui test commit pass on its own so the second commit shows the difference. That makes it a bit easier to review

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
@xizheyin
Copy link
Contributor Author

Ok, I submitted the test in the first commit and got it to pass on the original version of the code. In the second commit I modified the code and submitted the changes to the ui test output.
@oli-obk

Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
@oli-obk
Copy link
Contributor

oli-obk commented Mar 27, 2025

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Mar 27, 2025

📌 Commit 4648650 has been approved by oli-obk

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 27, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 27, 2025
Rollup of 7 pull requests

Successful merges:

 - rust-lang#138844 (expand: Leave traces when expanding `cfg` attributes)
 - rust-lang#138926 (Remove `kw::Empty` uses from `rustc_middle`.)
 - rust-lang#138989 (Clean up a few things in rustc_hir_analysis::check::region)
 - rust-lang#138999 (Report compiletest pass mode if forced)
 - rust-lang#139014 (Improve suggest construct with literal syntax instead of calling)
 - rust-lang#139015 (Remove unneeded LLVM CI test assertions)
 - rust-lang#139016 (Add job duration changes to post-merge analysis report)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit d517a4f into rust-lang:master Mar 27, 2025
6 checks passed
@rustbot rustbot added this to the 1.87.0 milestone Mar 27, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Mar 27, 2025
Rollup merge of rust-lang#139014 - xizheyin:issue-138931, r=oli-obk

Improve suggest construct with literal syntax instead of calling

Closing rust-lang#138931

When constructing a structure through a format similar to calling a constructor, we can use verbose suggestions to hint at using literal syntax for clearer advice. The case of multiple fields is also considered here, provided that the field has the same number of arguments as CallExpr.

r? compiler
@xizheyin xizheyin deleted the issue-138931 branch March 28, 2025 00:20
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.

Offer a suggested fix for structs with a single field
4 participants