Skip to content

Conversation

hkBst
Copy link
Member

@hkBst hkBst commented Sep 24, 2025

No description provided.

@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 Sep 24, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 24, 2025

r? @jdonszelmann

rustbot has assigned @jdonszelmann.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

// FIXME(hkBst): the big-O bound above would be accurate for the number
// of calls to `parameters_for`, which itself is some O(complexity of type).
// That would make this potentially cubic instead of merely quadratic...
// ...unless we cache those `parameters_for` calls.
Copy link
Contributor

Choose a reason for hiding this comment

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

which we don't currently, it seems

Copy link
Member Author

Choose a reason for hiding this comment

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

no we don't.

@jdonszelmann
Copy link
Contributor

jdonszelmann commented Sep 25, 2025

what is the goal of this PR? is the plan to modify this later not to be cubic? Though I think the code is indeed slightly cleaner I don't quite see that it's clearly an improvement over what was already there. In some sense, the largest code change here is combining three ifs into a single if-let which imo isn't necessarily clearer than the continue, especially the block-in-condition you have there

@jdonszelmann
Copy link
Contributor

looking at it more, I'm less and less convinced this is a real improvement except maybe the note that it could be cubic. Unless you're working on fixing that I'm not sure this is such a useful change.

@jdonszelmann
Copy link
Contributor

@rustbot author

@rustbot rustbot added 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 Sep 25, 2025
@hkBst
Copy link
Member Author

hkBst commented Sep 25, 2025

what is the goal of this PR? is the plan to modify this later not to be cubic?

I would, but I'm not familiar enough with the compiler to attempt it yet, I think.

Though I think the code is indeed slightly cleaner I don't quite see that it's clearly an improvement over what was already there. In some sense, the largest code change here is combining three ifs into a single if-let which imo isn't necessarily clearer than the continue, especially the block-in-condition you have there

Well, there are currently 3 continues inside this while loop, so who knows what it does? The proposed code makes it clear that it's just a complicated way to write if-conditions. The block-in-condition can easily be changed to not require the block, if you think that would help. It's just inherited like this from the current code.

@jdonszelmann
Copy link
Contributor

Hmm, well I think that right now the old version is equally clear if not clearer. A large if let chain with a block in it isn't much better than some continues. If you can change it so it's actually clear what the codepaths are (maybe name some variables?) I think it'd be much better

@hkBst
Copy link
Member Author

hkBst commented Sep 25, 2025

The big difference between a loop body with 3 continues and one with none, is that in one case you don't know how much of the loop body is executed for each iteration, and for the other case you know that the whole loop body is executed each time.

One very concrete benefit: in the current code line 215 and 219-222 are separated by an else {continue;} which obscures the fact that these lines are always executed together. The location of this else {continue;} within these lines is completely arbitrary and obscures that they belong together and together form the then-clause of a big if-statement, as is apparent in my proposed replacement.

@hkBst
Copy link
Member Author

hkBst commented Sep 29, 2025

I've now flattened the conditional block.

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 29, 2025
@jdonszelmann
Copy link
Contributor

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Sep 30, 2025

📌 Commit 1a16755 has been approved by jdonszelmann

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 Sep 30, 2025
bors added a commit that referenced this pull request Oct 1, 2025
Rollup of 11 pull requests

Successful merges:

 - #146918 (add regression test)
 - #146980 (simplify setup_constraining_predicates, and note it is potentially cubic)
 - #147170 (compiletest: Pass around `DirectiveLine` instead of bare strings)
 - #147180 (add tests)
 - #147188 (Remove usage of `compiletest-use-stage0-libtest` from CI)
 - #147189 (Replace `rustc_span::Span` with a stripped down version for librustdoc's highlighter)
 - #147199 (remove outdated comment in (inner) `InferCtxt`)
 - #147200 (Fix autodiff empty ret regression)
 - #147209 (Remove `no-remap-src-base` from tests)
 - #147213 (Fix broken STD build for ESP-IDF)
 - #147217 (Don't create a top-level `true` directory when running UI tests)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit f8ae00a into rust-lang:master Oct 1, 2025
10 checks passed
@rustbot rustbot added this to the 1.92.0 milestone Oct 1, 2025
rust-timer added a commit that referenced this pull request Oct 1, 2025
Rollup merge of #146980 - hkBst:hir-analysis-1, r=jdonszelmann

simplify setup_constraining_predicates, and note it is potentially cubic
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.

4 participants