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

rustc_infer cleanups #131226

Merged
merged 12 commits into from
Oct 7, 2024
Merged

rustc_infer cleanups #131226

merged 12 commits into from
Oct 7, 2024

Conversation

nnethercote
Copy link
Contributor

Various small improvements I found while reading over this code.

r? @lcnr

@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 Oct 4, 2024
@rustbot
Copy link
Collaborator

rustbot commented Oct 4, 2024

changes to the core type system

cc @compiler-errors, @lcnr

changes to the core type system

cc @compiler-errors, @lcnr

@@ -377,7 +377,7 @@ impl<'tcx> InferCtxt<'tcx> {
///
/// We ignore any type parameters because impl trait values are assumed to
/// capture all the in-scope type parameters.
pub struct ConstrainOpaqueTypeRegionVisitor<'tcx, OP: FnMut(ty::Region<'tcx>)> {
struct ConstrainOpaqueTypeRegionVisitor<'tcx, OP: FnMut(ty::Region<'tcx>)> {
pub tcx: TyCtxt<'tcx>,
Copy link
Contributor

Choose a reason for hiding this comment

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

now that the type is private, it's fields can be as well. Also... interesting that we don't have a lint for this case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The unreachable_pub lint was deliberately changed to not warn on this case in #126040, because it was deemed annoying. Specifically:

This PR restrict the unreachable_pub lint by not linting on pub fields of pub(restricted) structs and unions. This is done because that can quickly clutter the code for an uncertain value, in particular since the "real" visibility is defined by the parent (the struct it-self).

The implementation does more than that description indicates -- it also doesn't lint on pub fields of non-pub structs and unions. Perhaps it should?

Copy link
Contributor

@lcnr lcnr left a comment

Choose a reason for hiding this comment

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

some nits, then r=me

compiler/rustc_infer/src/infer/resolve.rs Show resolved Hide resolved
@bors
Copy link
Contributor

bors commented Oct 5, 2024

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

It's simpler, for this tiny module.
Three of the modules don't need to be `pub`, and then
`warn(unreachable_pub)` identifies a bunch more things that also
shouldn't be `pub`, plus a couple of things that are unused.
It helps people reading the code understand how widely things are used.
It's no longer used meaningfully.

This also means `DiagCtxtHandle::err_count_excluding_lint_errs` can be
removed.
`FixupError` is isomorphic with `TyOrConstInferVar`, so this commit
changes it to just be a wrapper around `TyOrConstInferVar`.

Also, move the `Display` impl for `FixupError` next to `FixupError`.
Inline and remove `next_const_var_id`, `next_int_var_id`,
`next_float_var_id`, all of which have a single call site.
Matches involving `GenericArgKind` pairs typically use a single `_` for
the impossible case. This commit shortens two verbose matches in this
way.
@nnethercote nnethercote force-pushed the rustc_infer-cleanups branch from ebd7a1e to 3fdcde7 Compare October 6, 2024 22:59
@nnethercote
Copy link
Contributor Author

I addressed the comments and rebased.

@bors r=lcnr

@bors
Copy link
Contributor

bors commented Oct 6, 2024

📌 Commit 3fdcde7 has been approved by lcnr

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 Oct 6, 2024
@bors
Copy link
Contributor

bors commented Oct 7, 2024

⌛ Testing commit 3fdcde7 with merge 8841a3d...

@bors
Copy link
Contributor

bors commented Oct 7, 2024

☀️ Test successful - checks-actions
Approved by: lcnr
Pushing 8841a3d to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Oct 7, 2024
@bors bors merged commit 8841a3d into rust-lang:master Oct 7, 2024
7 checks passed
@rustbot rustbot added this to the 1.83.0 milestone Oct 7, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (8841a3d): 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)
0.8% [0.4%, 1.0%] 8
Improvements ✅
(primary)
-0.3% [-0.5%, -0.2%] 40
Improvements ✅
(secondary)
-0.3% [-0.5%, -0.2%] 15
All ❌✅ (primary) -0.3% [-0.5%, -0.2%] 40

Max RSS (memory usage)

Results (primary 4.5%)

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

Cycles

Results (secondary -6.8%)

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)
- - 0
Improvements ✅
(secondary)
-6.8% [-8.9%, -4.2%] 5
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 773.837s -> 775.129s (0.17%)
Artifact size: 329.55 MiB -> 329.51 MiB (-0.01%)

@rustbot rustbot added the perf-regression Performance regression. label Oct 7, 2024
@nnethercote nnethercote deleted the rustc_infer-cleanups branch October 7, 2024 21:26
@nnethercote
Copy link
Contributor Author

Huh, those perf results look like they could be genuine improvements? Not sure how that would happen, this commit is the only one I can imagine might have a perf impact, and even then it would be surprising.

(ty::GenericArgKind::Const(unpacked), x) => {
bug!("impossible case reached: can't relate: {:?} with {:?}", unpacked, x)
}
_ => bug!("impossible case reached: can't relate: {a:?} with {b:?}"),
Copy link
Contributor

Choose a reason for hiding this comment

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

this may also cause the improvement. I would expect that this is some incredibly hot code and likely these paths couldn't get deduplicated because of line information?

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 8, 2024
…ups, r=lcnr

More `rustc_infer` cleanups

A sequel to rust-lang#131226.

r? `@lcnr`
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Oct 8, 2024
Rollup merge of rust-lang#131348 - nnethercote:rustc_infer-more-cleanups, r=lcnr

More `rustc_infer` cleanups

A sequel to rust-lang#131226.

r? `@lcnr`
@rylev
Copy link
Member

rylev commented Oct 9, 2024

Perf improvements outweigh the regressions so marking this as triaged

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Oct 9, 2024
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. perf-regression-triaged The performance regression has been triaged. 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.

6 participants