Skip to content

Conversation

@Shunpoco
Copy link
Contributor

@Shunpoco Shunpoco commented Oct 19, 2025

Context

This PR continues from #138679 (comment).
In the last PR, I introduced typeck result's tainted_by_error in check_pat. But as we've discussed, I should put the check to a better place which all lints get benefit from the check.

Change

Since visit_nested_body in late.rs is the starting point of late lint for a nested body, I moved the error check to the function.
I also rename one ui test case which I introduced in the last PR. I think the new name describes what the test wants to check more.

This PR fixes #138361 .

Note that we need to use actually_rustdoc to call typeck_body() in visit_nested_body. Otherwise rustdoc returns an error. However, as its comment describes we shouldn't use actually_rustdoc if there is an alternative solution. So far I only come up with using actually_rustdoc (this change), or checking tainted_by_error in each check_xxx functions (e.g., check on check_pat in #138679, and on check_expr for #138361).

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 19, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@Shunpoco Shunpoco force-pushed the lint-check-tainted-error branch from 4d84ca4 to 34be164 Compare October 19, 2025 15:11
…rror

We started to check typeck result's tainted_by_errors in check_pat for LateLint,
But ideally the check should be in a better place which all lints profit from it.
visit_nested_body is the place because it's the starting point of linting body.
@Shunpoco Shunpoco force-pushed the lint-check-tainted-error branch from 34be164 to f61c361 Compare October 31, 2025 22:14
@Shunpoco
Copy link
Contributor Author

r? @oli-obk

@rustbot
Copy link
Collaborator

rustbot commented Oct 31, 2025

oli-obk is not on the review rotation at the moment.
They may take a while to respond.

@Shunpoco Shunpoco marked this pull request as ready for review October 31, 2025 22:34
@rustbot
Copy link
Collaborator

rustbot commented Oct 31, 2025

This PR changes a file inside tests/crashes. If a crash was fixed, please move into the corresponding ui subdir and add 'Fixes #' to the PR description to autoclose the issue upon merge.

@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 Oct 31, 2025
@oli-obk
Copy link
Contributor

oli-obk commented Nov 1, 2025

@bors try @rust-timer queue

I think this may cause major perf issues. Maybe we need to integrate it with the typeck_results method. Let's check

@rust-timer

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Nov 1, 2025
@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 1, 2025
@rust-bors
Copy link

rust-bors bot commented Nov 1, 2025

☀️ Try build successful (CI)
Build commit: b571264 (b5712648d4b50898a2b3edfb8a3de2940f029877, parent: d85276b256a8ab18e03b6394b4f7a7b246176db7)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (b571264): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.2% [0.2%, 0.3%] 3
Improvements ✅
(primary)
-2.9% [-2.9%, -2.9%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.9% [-2.9%, -2.9%] 1

Max RSS (memory usage)

Results (primary 2.4%, secondary -2.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
4.1% [0.7%, 7.5%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.8% [-0.8%, -0.8%] 1
Improvements ✅
(secondary)
-2.7% [-2.7%, -2.7%] 1
All ❌✅ (primary) 2.4% [-0.8%, 7.5%] 3

Cycles

Results (primary -3.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-3.5% [-3.5%, -3.5%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -3.5% [-3.5%, -3.5%] 1

Binary size

Results (primary -1.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

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

Bootstrap: 476.797s -> 473.568s (-0.68%)
Artifact size: 390.82 MiB -> 390.85 MiB (0.01%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Nov 1, 2025
// The typeck_result shouldn't be tainted, otherwise it will cause ICE.
// If rustdoc is the caller of this function, we shouldn't run typeck_body here.
if !self.context.tcx.sess.opts.actually_rustdoc
&& self.context.tcx.typeck_body(body_id).tainted_by_errors.is_some()
Copy link
Contributor

Choose a reason for hiding this comment

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

Considering this can be called unconditionally outside rustdoc, perform it further down where we do self.context.cached_typeck_results.set(None); and just always set it to Some unless in rustdoc mode or if tainted (keep returning in the tainted case of course).

The cache still needs to be an option as we also have lints outside of bodies

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks,

Considering this can be called unconditionally outside rustdoc, perform it further down where we do self.context.cached_typeck_results.set(None);

Do you mean I should call typeck_body in the block which cached_typeck_results.set(None) is called or I should call typeck_body other place where rustdoc doesn't use?

Copy link
Contributor

Choose a reason for hiding this comment

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

you can call it there, but still behind an !actually_rustdoc check, and then just overwrite the freshly set None with a Some of the data you just loaded.

At that point I think we can even change the method for obtaining the cached typeck results to just unwrap the option

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

Labels

perf-regression Performance regression. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ICE: sty: None

5 participants