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

Lowering unnamed fields and anonymous adt #115367

Merged
merged 8 commits into from Feb 12, 2024

Conversation

frank-king
Copy link
Contributor

@frank-king frank-king commented Aug 30, 2023

This implements #49804.

Goals:

  • lowering anonymous ADTs from AST to HIR
  • generating definitions of anonymous ADTs
  • uniqueness check of the unnamed fields
  • field projection of anonymous ADTs
  • #[repr(C)] check of the anonymous ADTs

Non-Goals (will be in the next PRs)

  • capturing generic params for the anonymous ADTs from the parent ADT
  • pattern matching of anonymous ADTs
  • structural expressions of anonymous ADTs
  • rustdoc support of anonymous ADTs

@rustbot
Copy link
Collaborator

rustbot commented Aug 30, 2023

r? @cjgillot

(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. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 30, 2023
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added the WG-trait-system-refactor The Rustc Trait System Refactor Initiative label Sep 2, 2023
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

compiler/rustc_ast_lowering/src/lib.rs Outdated Show resolved Hide resolved
compiler/rustc_ast_lowering/src/lib.rs Outdated Show resolved Hide resolved
compiler/rustc_ast_lowering/src/lib.rs Outdated Show resolved Hide resolved
compiler/rustc_hir/src/definitions.rs Outdated Show resolved Hide resolved
compiler/rustc_ast_lowering/src/lib.rs Show resolved Hide resolved
compiler/rustc_trait_selection/src/traits/select/mod.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/ty/context.rs Show resolved Hide resolved
compiler/rustc_hir_analysis/src/astconv/mod.rs Outdated Show resolved Hide resolved
compiler/rustc_mir_dataflow/src/value_analysis.rs Outdated Show resolved Hide resolved
@bors

This comment was marked as resolved.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bors

This comment was marked as resolved.

@frank-king frank-king force-pushed the feature/unnamed-fields-hir branch 3 times, most recently from 3dce559 to bf6482b Compare January 6, 2024 10:26
Fix the `AssertBoundIsClone` error for anonymous adts.
- improve diagnostics of field uniqueness check and representation check
- simplify the implementation of field uniqueness check
- remove some useless codes and improvement neatness
Copy link
Member

@davidtwco davidtwco left a comment

Choose a reason for hiding this comment

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

I think this is good enough to merge as-is, we can refactor and make further improvements in follow-ups, but this is a big PR and it's going to be prone to conflicts so best to get this progress landed.

@davidtwco
Copy link
Member

@bors r+ rollup=never

@bors
Copy link
Contributor

bors commented Feb 12, 2024

📌 Commit 0dbd6e9 has been approved by davidtwco

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 12, 2024
@bors
Copy link
Contributor

bors commented Feb 12, 2024

⌛ Testing commit 0dbd6e9 with merge bdc1592...

@bors
Copy link
Contributor

bors commented Feb 12, 2024

☀️ Test successful - checks-actions
Approved by: davidtwco
Pushing bdc1592 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Feb 12, 2024
@bors bors merged commit bdc1592 into rust-lang:master Feb 12, 2024
12 checks passed
@rustbot rustbot added this to the 1.78.0 milestone Feb 12, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (bdc1592): comparison URL.

Overall result: ❌✅ regressions and improvements - ACTION NEEDED

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
6.1% [0.3%, 20.7%] 9
Improvements ✅
(primary)
-1.1% [-1.1%, -1.1%] 1
Improvements ✅
(secondary)
-0.3% [-0.3%, -0.3%] 1
All ❌✅ (primary) -1.1% [-1.1%, -1.1%] 1

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)
-2.0% [-2.0%, -2.0%] 1
Improvements ✅
(secondary)
-5.3% [-5.3%, -5.3%] 1
All ❌✅ (primary) -2.0% [-2.0%, -2.0%] 1

Cycles

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)
6.9% [2.7%, 13.8%] 6
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.1% [-3.2%, -3.1%] 3
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 661.706s -> 662.09s (0.06%)
Artifact size: 308.30 MiB -> 308.34 MiB (0.01%)

@Kobzol
Copy link
Contributor

Kobzol commented Feb 13, 2024

There seems to be a big regression here on this benchmark, which has a struct with many fields.

Should this have affected performance of non-anonymous fields?

@frank-king
Copy link
Contributor Author

The query find_field seems to be inefficient and affects FnCtxt::check_field for tuple fields as well.

Is this problem serious? I'm going to do some refactoring work on this query (to implement struct patterns and struct expressions of unnamed fields), but I'm afraid I won't have much time till next week.

@Kobzol
Copy link
Contributor

Kobzol commented Feb 13, 2024

It would be nice to improve it eventually, it's probably not that rare to have structs with many fields, e.g. generated by macros. But there's no immediate rush :)

@Kobzol
Copy link
Contributor

Kobzol commented Feb 13, 2024

Oh, I only now noticed that it's a tuple struct. Yeah, so tuple structs with many fields are probably quite rare. In any case, if you find any wins here in the future, that would be great!

@frank-king
Copy link
Contributor Author

No problem, I'll look into this benchmark in the next step of implementation.

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. perf-regression Performance regression. 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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants