Skip to content

Conversation

chenyukang
Copy link
Member

Fixes #104867
r? @estebank

@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 Nov 25, 2022
Comment on lines 295 to 302
let prev_is_semi = {
if let Ok(prev_code) = self.sess.source_map().span_to_prev_source(lhs.span) &&
prev_code.trim_end().ends_with(";") {
true
} else {
false
}
};
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a bit of a hack, but fair given where it lives. I would like to do a perf run of an alternative approach: modify lhs to hold a starts_statement: bool field. I think that it might hit memory a bit, but that would be far less brittle to refactors breaking this heuristic. Would you have time to try doing that as part of this PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

You means add a field with boolean type to LhsExpr type?

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated the code.
I don't think there is a perf regerssion here, we are at error report codepath,
but you may have a double-check.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, maybe cost a little bit more memory.

--> $DIR/issue-104867-inc-dec-2.rs:18:18
|
LL | let _ = i + i++;
| ^^ not a valid postfix operator
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the hardest case to handle well, so I removed the suggestion for this scenario.
There maybe a solution to get it right, I think it may not worth to do it.

@estebank
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Dec 12, 2022

📌 Commit ded10a1 has been approved by estebank

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 Dec 12, 2022
@bors
Copy link
Collaborator

bors commented Dec 14, 2022

⌛ Testing commit ded10a1 with merge 309c469...

@bors
Copy link
Collaborator

bors commented Dec 14, 2022

☀️ Test successful - checks-actions
Approved by: estebank
Pushing 309c469 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 14, 2022
@bors bors merged commit 309c469 into rust-lang:master Dec 14, 2022
@rustbot rustbot added this to the 1.68.0 milestone Dec 14, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (309c469): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-3.4% [-3.6%, -3.2%] 2
Improvements ✅
(secondary)
-2.1% [-2.1%, -2.1%] 2
All ❌✅ (primary) -3.4% [-3.6%, -3.2%] 2

Cycles

This benchmark run did not return any relevant results for this metric.

Aaron1011 pushed a commit to Aaron1011/rust that referenced this pull request Jan 6, 2023
…estebank

Properly handle postfix inc/dec in standalone and subexpr scenarios

Fixes rust-lang#104867
r? `@estebank`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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.

postfix_increment show both type of suggestion for single statement
5 participants