Skip to content

Suggest let for assignment, and some code refactor - #101908

Merged
bors merged 1 commit into
rust-lang:masterfrom
chenyukang:fix-101880
Oct 23, 2022
Merged

Suggest let for assignment, and some code refactor#101908
bors merged 1 commit into
rust-lang:masterfrom
chenyukang:fix-101880

Conversation

@chenyukang

Copy link
Copy Markdown
Member

Fixes#101880

@rustbotrustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Sep 16, 2022
@rust-highfive

Copy link
Copy Markdown
Contributor

r? @oli-obk

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

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 16, 2022
Comment threadsrc/test/ui/suggestions/suggest-let-for-assignment.stderr Outdated
@chenyukang
chenyukang marked this pull request as draft September 16, 2022 16:56
@rust-log-analyzer

This comment has been minimized.

Comment threadcompiler/rustc_resolve/src/late/diagnostics.rs Outdated
Comment threadcompiler/rustc_resolve/src/late/diagnostics.rs Outdated
Comment threadcompiler/rustc_resolve/src/late/diagnostics.rs Outdated
Comment threadsrc/test/ui/suggestions/suggest-let-for-assignment.stderr Outdated
Comment threadcompiler/rustc_resolve/src/late/diagnostics.rs Outdated
@chenyukang

chenyukang commented Sep 17, 2022

Copy link
Copy Markdown
MemberAuthor

By the way, smart_resolve_report_errors is tooo long and seems hard to maintain 😂
Should we refactor this part? @estebank

Comment threadsrc/test/ui/suggestions/suggest-let-for-assignment.stderr Outdated
@chenyukang
chenyukang marked this pull request as ready for review September 17, 2022 06:21
Comment threadcompiler/rustc_resolve/src/late/diagnostics.rs Outdated
@estebank

Copy link
Copy Markdown
Contributor

By the way, smart_resolve_report_errors is tooo long and seems hard to maintain 😂 Should we refactor this part?

We should, but better to do it as part of its own PR.

@bors

bors commented Sep 29, 2022

Copy link
Copy Markdown
Collaborator

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

@chenyukang
chenyukangforce-pushed the fix-101880 branch 4 times, most recently from 99a33b3 to 7d201c9CompareSeptember 29, 2022 15:29
@chenyukang

Copy link
Copy Markdown
MemberAuthor

r? @estebank

@bors

bors commented Oct 20, 2022

Copy link
Copy Markdown
Collaborator

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

@estebankestebank left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

r=me after rebasing (ping me and I'll approve)

Comment on lines 1715 to 1716

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This can now be written as follows

Suggested change
let has_eq = matches!(sm.span_to_snippet(eq_span),Ok(ref snippet)if snippet == "=");
if has_eq {
ifletOk(ref snippet) = sm.span_to_snippet(eq_span) && snippet == "="{

Comment on lines 1747 to 1742

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this check to protect against macros or something else?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah, yes. Saw the dbg!(binding) case in the test. Hacky, but makes sense!

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

emm, I will add a comment for this.

@rust-log-analyzer

This comment has been minimized.

break;
}
}
let closing_span = sm.span_look_ahead(span, Some("}"), Some(50));

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Since the next_point bug is fixed, this is changed from 100 to 50 😂

@chenyukang

Copy link
Copy Markdown
MemberAuthor

r? @estebank

@estebank

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Oct 21, 2022

Copy link
Copy Markdown
Collaborator

📌 Commit eb68e27 has been approved by estebank

It is now in the queue for this repository.

@borsbors 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 Oct 21, 2022
notriddle added a commit to notriddle/rust that referenced this pull request Oct 21, 2022
@Dylan-DPCDylan-DPC mentioned this pull request Oct 23, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 23, 2022
Rollup of 6 pull requests
Successful merges:
- rust-lang#101293 (Recover when unclosed char literal is parsed as a lifetime in some positions)
- rust-lang#101908 (Suggest let for assignment, and some code refactor)
- rust-lang#103192 (rustdoc: Eliminate uses of `EarlyDocLinkResolver::all_traits`)
- rust-lang#103226 (Check `needs_infer` before `needs_drop` during HIR generator analysis)
- rust-lang#103249 (resolve: Revert "Set effective visibilities for imports more precisely")
- rust-lang#103305 (Move some tests to more reasonable places)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit 518d5eb into rust-lang:masterOct 23, 2022
@rustbotrustbot added this to the 1.66.0 milestone Oct 23, 2022
@Kaligule

Copy link
Copy Markdown

Thank you @chenyukang

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant 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.

Better error messages: Tell programmer about forgotten let

9 participants

@chenyukang@rust-highfive@rust-log-analyzer@estebank@bors@Kaligule@Rageking8@oli-obk@rustbot