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

Add -Z maximal-hir-to-mir-coverage flag #105286

Merged
merged 2 commits into from
Dec 6, 2022

Conversation

willcrichton
Copy link
Contributor

This PR adds a new unstable flag -Z maximal-hir-to-mir-coverage that changes the behavior of maybe_lint_level_root_bounded, pursuant to a discussion on Zulip. When enabled, this function will not search upwards for a lint root, but rather immediately return the provided HIR node ID. This change increases the granularity of the mapping between MIR locations and HIR nodes inside the SourceScopeLocalData data structures. This increase in granularity is useful for rustc consumers like Flowistry that rely on getting source-mapping information about the MIR CFG that is as precise as possible.

A test maximal_mir_to_hir_coverage.rs has been added to verify that this flag does not break anything.

r? @cjgillot

cc @gavinleroy

@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 Dec 5, 2022
@rust-log-analyzer

This comment has been minimized.

if self.sess.opts.unstable_opts.maximal_hir_to_mir_coverage {
return id;
}

Copy link
Contributor

@cjgillot cjgillot Dec 5, 2022

Choose a reason for hiding this comment

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

The name of this function does not hint any relationship to MIR. Could you prefer using this flag in rustc_mir_build?
There are only 2 places where it's used, with the same pattern. Refactoring them to a single maybe_create_source_scope that checks this option may be the better option.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just refactored as requested. I named the method maybe_new_source_scope for consistency with new_source_scope.

@@ -579,13 +580,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
);
let current_root = tcx.maybe_lint_level_root_bounded(current_hir_id, self.hir_id);
Copy link
Contributor

Choose a reason for hiding this comment

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

Those 2 calls should go into maybe_new_source_scope.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes I was just fixing this when you left his comment :-)

@willcrichton willcrichton force-pushed the maximal-hir-to-mir-coverage branch 2 times, most recently from cecb35a to cbe2687 Compare December 5, 2022 20:46
Copy link
Contributor

@cjgillot cjgillot left a comment

Choose a reason for hiding this comment

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

@bors r+

@cjgillot
Copy link
Contributor

cjgillot commented Dec 6, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Dec 6, 2022

📌 Commit d595884 has been approved by cjgillot

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 6, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 6, 2022
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#104898 (Put all cached values into a central struct instead of just the stable hash)
 - rust-lang#105004 (Fix `emit_unused_delims_expr` ICE)
 - rust-lang#105174 (Suggest removing struct field from destructive binding only in shorthand scenario)
 - rust-lang#105250 (Replace usage of `ResumeTy` in async lowering with `Context`)
 - rust-lang#105286 (Add -Z maximal-hir-to-mir-coverage flag)
 - rust-lang#105320 (rustdoc: simplify CSS selectors on top-doc and non-exhaustive toggles)
 - rust-lang#105349 (Point at args in associated const fn pointers)
 - rust-lang#105362 (Cleanup macro-expanded code in `rustc_type_ir`)
 - rust-lang#105370 (Remove outdated syntax from trait alias pretty printing)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit c699b05 into rust-lang:master Dec 6, 2022
@rustbot rustbot added this to the 1.67.0 milestone Dec 6, 2022
@willcrichton
Copy link
Contributor Author

willcrichton/flowistry@5eb8f45

Net -140 lines of code! Thanks @cjgillot!!!

@workingjubilee workingjubilee added the A-CLI Area: Command-line interface (CLI) to the compiler label Mar 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-CLI Area: Command-line interface (CLI) to the compiler 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