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

Rollup of 9 pull requests #105378

Merged
merged 25 commits into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3d31e5c
s/WithStableHash/WithCachedTypeInfo/
oli-obk Nov 25, 2022
87a04f5
move WithCachedTypeInfo to rustc_type_ir
oli-obk Nov 25, 2022
147b854
Remove TyS
oli-obk Nov 25, 2022
46ba154
Update documentation
oli-obk Nov 28, 2022
907ef22
Remove PredicateS type
oli-obk Nov 30, 2022
14a9cf2
Generalize some InternedInSet impls
oli-obk Nov 30, 2022
0e24cee
fix #105028, Only suggest removing struct field from destructive bind…
chenyukang Nov 30, 2022
5c7278a
return when expr has error
TaKO8Ki Nov 28, 2022
3bf7d88
Add -Z maximal-hir-to-mir-coverage flag
willcrichton Dec 5, 2022
32765fb
rustdoc: simplify CSS selectors on top-doc and non-exhaustive toggles
notriddle Dec 5, 2022
d595884
Move -Z maximal-hir-to-mir-coverage implementation to new `maybe_new_…
willcrichton Dec 5, 2022
9c9c476
Point at args in associated const fn pointers
compiler-errors Dec 6, 2022
cf031a3
Replace usage of `ResumeTy` in async lowering with `Context`
Swatinem Dec 4, 2022
07fbb1b
Cleanup macro-expanded code in `rustc_type_ir`
WaffleLapkin Dec 6, 2022
e12d222
Add debug asserts to hand-implemented `Ord`/`Eq` impls
WaffleLapkin Dec 6, 2022
12ce0c2
Remove outdated syntax from trait alias pretty printing
WaffleLapkin Dec 6, 2022
db416ea
Rollup merge of #104898 - oli-obk:group_all_the_things, r=wesleywiser
matthiaskrgr Dec 6, 2022
b29a4f9
Rollup merge of #105004 - TaKO8Ki:fix-104897, r=wesleywiser
matthiaskrgr Dec 6, 2022
90d84ce
Rollup merge of #105174 - chenyukang:yukang/fix-105028-unused, r=eholk
matthiaskrgr Dec 6, 2022
967085e
Rollup merge of #105250 - Swatinem:async-rm-resumety, r=oli-obk
matthiaskrgr Dec 6, 2022
c699b05
Rollup merge of #105286 - willcrichton:maximal-hir-to-mir-coverage, r…
matthiaskrgr Dec 6, 2022
dc07e1b
Rollup merge of #105320 - notriddle:notriddle/rustdoc-toggle-hideme-2…
matthiaskrgr Dec 6, 2022
4f919e4
Rollup merge of #105349 - compiler-errors:point-at-assoc-ct-fn-ptr-ar…
matthiaskrgr Dec 6, 2022
4f527a5
Rollup merge of #105362 - WaffleLapkin:🙅, r=oli-obk
matthiaskrgr Dec 6, 2022
97008a2
Rollup merge of #105370 - WaffleLapkin:pp, r=oli-obk
matthiaskrgr Dec 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move -Z maximal-hir-to-mir-coverage implementation to new `maybe_new_…
…source_scope` method
  • Loading branch information
willcrichton committed Dec 5, 2022
commit d595884302240f07576239288c771b0e9717fc19
10 changes: 0 additions & 10 deletions compiler/rustc_middle/src/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,6 @@ impl TyCtxt<'_> {
/// Walks upwards from `id` to find a node which might change lint levels with attributes.
/// It stops at `bound` and just returns it if reached.
pub fn maybe_lint_level_root_bounded(self, mut id: HirId, bound: HirId) -> HirId {
// Some consumers of rustc need to map MIR locations back to HIR nodes. Currently the
// the only part of rustc that tracks MIR -> HIR is the `SourceScopeLocalData::lint_root`
// field that tracks lint levels for MIR locations. Normally the number of source scopes
// is limited to the set of nodes with lint annotations. The -Zmaximal-hir-to-mir-coverage
// flag changes this behavior to maximize the number of source scopes, increasing the
// granularity of the MIR->HIR mapping.
if self.sess.opts.unstable_opts.maximal_hir_to_mir_coverage {
return id;
}

let hir = self.hir();
loop {
if id == bound {
Expand Down
20 changes: 6 additions & 14 deletions compiler/rustc_mir_build/src/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -948,20 +948,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
original_source_scope: SourceScope,
pattern_span: Span,
) {
let tcx = self.tcx;
let current_root = tcx.maybe_lint_level_root_bounded(arg_hir_id, self.hir_id);
let parent_root = tcx.maybe_lint_level_root_bounded(
self.source_scopes[original_source_scope]
.local_data
.as_ref()
.assert_crate_local()
.lint_root,
self.hir_id,
);
if current_root != parent_root {
self.source_scope =
self.new_source_scope(pattern_span, LintLevel::Explicit(current_root), None);
}
let parent_id = self.source_scopes[original_source_scope]
.local_data
.as_ref()
.assert_crate_local()
.lint_root;
self.maybe_new_source_scope(pattern_span, None, arg_hir_id, parent_id);
}

fn get_unit_temp(&mut self) -> Place<'tcx> {
Expand Down
56 changes: 38 additions & 18 deletions compiler/rustc_mir_build/src/build/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ use std::mem;

use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder, CFG};
use rustc_data_structures::fx::FxHashMap;
use rustc_hir::HirId;
use rustc_index::vec::IndexVec;
use rustc_middle::middle::region;
use rustc_middle::mir::*;
Expand Down Expand Up @@ -567,25 +568,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
F: FnOnce(&mut Builder<'a, 'tcx>) -> BlockAnd<R>,
{
let source_scope = self.source_scope;
let tcx = self.tcx;
if let LintLevel::Explicit(current_hir_id) = lint_level {
// Use `maybe_lint_level_root_bounded` with `root_lint_level` as a bound
// to avoid adding Hir dependencies on our parents.
// We estimate the true lint roots here to avoid creating a lot of source scopes.

let parent_root = tcx.maybe_lint_level_root_bounded(
self.source_scopes[source_scope].local_data.as_ref().assert_crate_local().lint_root,
self.hir_id,
);
let current_root = tcx.maybe_lint_level_root_bounded(current_hir_id, self.hir_id);

if parent_root != current_root {
self.source_scope = self.new_source_scope(
region_scope.1.span,
LintLevel::Explicit(current_root),
None,
);
}
let parent_id =
self.source_scopes[source_scope].local_data.as_ref().assert_crate_local().lint_root;
self.maybe_new_source_scope(region_scope.1.span, None, current_hir_id, parent_id);
}
self.push_scope(region_scope);
let mut block;
Expand Down Expand Up @@ -758,6 +744,40 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
))
}

/// Possibly creates a new source scope if `current_root` and `parent_root`
/// are different, or if -Zmaximal-hir-to-mir-coverage is enabled.
pub(crate) fn maybe_new_source_scope(
&mut self,
span: Span,
safety: Option<Safety>,
current_id: HirId,
parent_id: HirId,
) {
let (current_root, parent_root) =
if self.tcx.sess.opts.unstable_opts.maximal_hir_to_mir_coverage {
// Some consumers of rustc need to map MIR locations back to HIR nodes. Currently the
// the only part of rustc that tracks MIR -> HIR is the `SourceScopeLocalData::lint_root`
// field that tracks lint levels for MIR locations. Normally the number of source scopes
// is limited to the set of nodes with lint annotations. The -Zmaximal-hir-to-mir-coverage
// flag changes this behavior to maximize the number of source scopes, increasing the
// granularity of the MIR->HIR mapping.
(current_id, parent_id)
} else {
// Use `maybe_lint_level_root_bounded` with `self.hir_id` as a bound
// to avoid adding Hir dependencies on our parents.
// We estimate the true lint roots here to avoid creating a lot of source scopes.
(
self.tcx.maybe_lint_level_root_bounded(current_id, self.hir_id),
self.tcx.maybe_lint_level_root_bounded(parent_id, self.hir_id),
)
};

if current_root != parent_root {
let lint_level = LintLevel::Explicit(current_root);
self.source_scope = self.new_source_scope(span, lint_level, safety);
}
}

/// Creates a new source scope, nested in the current one.
pub(crate) fn new_source_scope(
&mut self,
Expand Down