Skip to content

Rollup of 7 pull requests #133120

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

Merged
merged 18 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
b368110
Stabilize `const_atomic_from_ptr`
tgross35 Oct 14, 2024
3350edf
Replace `BorrowckResults` with `Borrowck`.
nnethercote Oct 31, 2024
c904c6a
Remove `ResultsVisitable`.
nnethercote Oct 31, 2024
7651fc6
mark is_val_statically_known intrinsic as stably const-callable
RalfJung Nov 1, 2024
58abbaf
Revert "Skip late-bound lifetimes when crossing an AnonConst."
compiler-errors Nov 9, 2024
8d871b7
Deny capturing late-bound ty/ct params in nested opaques
compiler-errors Nov 10, 2024
1236656
Make Visitor::FnKind and MutVisitor::FnKind compatible
maxcabrajac Nov 8, 2024
6180173
Add WalkItemKind::Ctxt so AssocCtxt is not sent to non-Assoc ItemKinds
maxcabrajac Nov 8, 2024
516a3b0
Make WalkItemKind::walk signature compatible between Visitor versions
maxcabrajac Nov 12, 2024
cd46ff6
rustdoc search: allow queries to end in an empty path segment
lolbinarycat Nov 3, 2024
dd688cb
Opt out TaKO8Ki from review rotation for now
jieyouxu Nov 16, 2024
07b0336
Rollup merge of #131717 - tgross35:stabilize-const_atomic_from_ptr, r…
matthiaskrgr Nov 16, 2024
5c81dbf
Rollup merge of #132134 - nnethercote:rm-ResultsVisitable, r=cjgillot
matthiaskrgr Nov 16, 2024
fb5bd7f
Rollup merge of #132449 - RalfJung:is_val_statically_known, r=compile…
matthiaskrgr Nov 16, 2024
eff2b70
Rollup merge of #132569 - lolbinarycat:rustdoc-search-path-end-empty-…
matthiaskrgr Nov 16, 2024
6b47c6d
Rollup merge of #132787 - maxcabrajac:fnctxt, r=petrochenkov
matthiaskrgr Nov 16, 2024
a1c98ca
Rollup merge of #132832 - compiler-errors:late-ty, r=cjgillot
matthiaskrgr Nov 16, 2024
17a9a7e
Rollup merge of #133097 - jieyouxu:opt-out-review-rotation, r=jieyouxu
matthiaskrgr Nov 16, 2024
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
Remove ResultsVisitable.
Now that `Results` is the only impl of `ResultsVisitable`, the trait can
be removed. This simplifies things by removining unnecessary layers of
indirection and abstraction.

- `ResultsVisitor` is simpler.
  - Its type parameter changes from `R` (an analysis result) to the
    simpler `A` (an analysis).
  - It no longer needs the `Domain` associated type, because it can use
    `A::Domain`.
  - Occurrences of `R` become `Results<'tcx, A>`, because there is now
    only one kind of analysis results.

- `save_as_intervals` also changes type parameter from `R` to `A`.

- The `results.reconstruct_*` method calls are replaced with
  `results.analysis.apply_*` method calls, which are equivalent.

- `Direction::visit_results_in_block` is simpler, with a single generic
  param (`A`) instead of two (`D` and `R`/`F`, with a bound connecting
  them). Likewise for `visit_results`.

- The `ResultsVisitor` impls for `MirBorrowCtxt` and
  `StorageConflictVisitor` are now specific about the type of the
  analysis results they work with. They both used to have a type param
  `R` but they weren't genuinely generic. In both cases there was only a
  single results type that made sense to instantiate them with.
  • Loading branch information
nnethercote committed Nov 4, 2024
commit c904c6aaffa10f92e8f203f69bd8b87b0b0f4353
16 changes: 6 additions & 10 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use rustc_mir_dataflow::impls::{
use rustc_mir_dataflow::move_paths::{
InitIndex, InitLocation, LookupResult, MoveData, MoveOutIndex, MovePathIndex,
};
use rustc_mir_dataflow::{Analysis, EntrySets, Results};
use rustc_mir_dataflow::{Analysis, EntrySets, Results, ResultsVisitor, visit_results};
use rustc_session::lint::builtin::UNUSED_MUT;
use rustc_span::{Span, Symbol};
use smallvec::SmallVec;
Expand Down Expand Up @@ -318,7 +318,7 @@ fn do_mir_borrowck<'tcx>(
mbcx.report_region_errors(nll_errors);

let mut flow_results = get_flow_results(tcx, body, &move_data, &borrow_set, &regioncx);
rustc_mir_dataflow::visit_results(
visit_results(
body,
traversal::reverse_postorder(body).map(|(bb, _)| bb),
&mut flow_results,
Expand Down Expand Up @@ -607,14 +607,10 @@ struct MirBorrowckCtxt<'a, 'infcx, 'tcx> {
// 2. loans made in overlapping scopes do not conflict
// 3. assignments do not affect things loaned out as immutable
// 4. moves do not affect things loaned out in any way
impl<'a, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'a, 'tcx, R>
for MirBorrowckCtxt<'a, '_, 'tcx>
{
type Domain = BorrowckDomain<'a, 'tcx>;

impl<'a, 'tcx> ResultsVisitor<'a, 'tcx, Borrowck<'a, 'tcx>> for MirBorrowckCtxt<'a, '_, 'tcx> {
fn visit_statement_before_primary_effect(
&mut self,
_results: &mut R,
_results: &mut Results<'tcx, Borrowck<'a, 'tcx>>,
state: &BorrowckDomain<'a, 'tcx>,
stmt: &'a Statement<'tcx>,
location: Location,
Expand Down Expand Up @@ -686,7 +682,7 @@ impl<'a, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'a, 'tcx, R>

fn visit_terminator_before_primary_effect(
&mut self,
_results: &mut R,
_results: &mut Results<'tcx, Borrowck<'a, 'tcx>>,
state: &BorrowckDomain<'a, 'tcx>,
term: &'a Terminator<'tcx>,
loc: Location,
Expand Down Expand Up @@ -799,7 +795,7 @@ impl<'a, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'a, 'tcx, R>

fn visit_terminator_after_primary_effect(
&mut self,
_results: &mut R,
_results: &mut Results<'tcx, Borrowck<'a, 'tcx>>,
state: &BorrowckDomain<'a, 'tcx>,
term: &'a Terminator<'tcx>,
loc: Location,
Expand Down
56 changes: 28 additions & 28 deletions compiler/rustc_mir_dataflow/src/framework/direction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use rustc_middle::mir::{
self, BasicBlock, CallReturnPlaces, Location, SwitchTargets, TerminatorEdges,
};

use super::visitor::{ResultsVisitable, ResultsVisitor};
use super::{Analysis, Effect, EffectIndex, SwitchIntTarget};
use super::visitor::ResultsVisitor;
use super::{Analysis, Effect, EffectIndex, Results, SwitchIntTarget};

pub trait Direction {
const IS_FORWARD: bool;
Expand Down Expand Up @@ -33,14 +33,14 @@ pub trait Direction {
where
A: Analysis<'tcx>;

fn visit_results_in_block<'mir, 'tcx, D, R>(
state: &mut D,
fn visit_results_in_block<'mir, 'tcx, A>(
state: &mut A::Domain,
block: BasicBlock,
block_data: &'mir mir::BasicBlockData<'tcx>,
results: &mut R,
vis: &mut impl ResultsVisitor<'mir, 'tcx, R, Domain = D>,
results: &mut Results<'tcx, A>,
vis: &mut impl ResultsVisitor<'mir, 'tcx, A>,
) where
R: ResultsVisitable<'tcx, Domain = D>;
A: Analysis<'tcx>;

fn join_state_into_successors_of<'tcx, A>(
analysis: &mut A,
Expand All @@ -53,7 +53,7 @@ pub trait Direction {
A: Analysis<'tcx>;
}

/// Dataflow that runs from the exit of a block (the terminator), to its entry (the first statement).
/// Dataflow that runs from the exit of a block (terminator), to its entry (the first statement).
pub struct Backward;

impl Direction for Backward {
Expand Down Expand Up @@ -157,32 +157,32 @@ impl Direction for Backward {
analysis.apply_statement_effect(state, statement, location);
}

fn visit_results_in_block<'mir, 'tcx, D, R>(
state: &mut D,
fn visit_results_in_block<'mir, 'tcx, A>(
state: &mut A::Domain,
block: BasicBlock,
block_data: &'mir mir::BasicBlockData<'tcx>,
results: &mut R,
vis: &mut impl ResultsVisitor<'mir, 'tcx, R, Domain = D>,
results: &mut Results<'tcx, A>,
vis: &mut impl ResultsVisitor<'mir, 'tcx, A>,
) where
R: ResultsVisitable<'tcx, Domain = D>,
A: Analysis<'tcx>,
{
results.reset_to_block_entry(state, block);
state.clone_from(results.entry_set_for_block(block));

vis.visit_block_end(state);

// Terminator
let loc = Location { block, statement_index: block_data.statements.len() };
let term = block_data.terminator();
results.reconstruct_before_terminator_effect(state, term, loc);
results.analysis.apply_before_terminator_effect(state, term, loc);
vis.visit_terminator_before_primary_effect(results, state, term, loc);
results.reconstruct_terminator_effect(state, term, loc);
results.analysis.apply_terminator_effect(state, term, loc);
vis.visit_terminator_after_primary_effect(results, state, term, loc);

for (statement_index, stmt) in block_data.statements.iter().enumerate().rev() {
let loc = Location { block, statement_index };
results.reconstruct_before_statement_effect(state, stmt, loc);
results.analysis.apply_before_statement_effect(state, stmt, loc);
vis.visit_statement_before_primary_effect(results, state, stmt, loc);
results.reconstruct_statement_effect(state, stmt, loc);
results.analysis.apply_statement_effect(state, stmt, loc);
vis.visit_statement_after_primary_effect(results, state, stmt, loc);
}

Expand Down Expand Up @@ -389,32 +389,32 @@ impl Direction for Forward {
}
}

fn visit_results_in_block<'mir, 'tcx, F, R>(
state: &mut F,
fn visit_results_in_block<'mir, 'tcx, A>(
state: &mut A::Domain,
block: BasicBlock,
block_data: &'mir mir::BasicBlockData<'tcx>,
results: &mut R,
vis: &mut impl ResultsVisitor<'mir, 'tcx, R, Domain = F>,
results: &mut Results<'tcx, A>,
vis: &mut impl ResultsVisitor<'mir, 'tcx, A>,
) where
R: ResultsVisitable<'tcx, Domain = F>,
A: Analysis<'tcx>,
{
results.reset_to_block_entry(state, block);
state.clone_from(results.entry_set_for_block(block));

vis.visit_block_start(state);

for (statement_index, stmt) in block_data.statements.iter().enumerate() {
let loc = Location { block, statement_index };
results.reconstruct_before_statement_effect(state, stmt, loc);
results.analysis.apply_before_statement_effect(state, stmt, loc);
vis.visit_statement_before_primary_effect(results, state, stmt, loc);
results.reconstruct_statement_effect(state, stmt, loc);
results.analysis.apply_statement_effect(state, stmt, loc);
vis.visit_statement_after_primary_effect(results, state, stmt, loc);
}

let loc = Location { block, statement_index: block_data.statements.len() };
let term = block_data.terminator();
results.reconstruct_before_terminator_effect(state, term, loc);
results.analysis.apply_before_terminator_effect(state, term, loc);
vis.visit_terminator_before_primary_effect(results, state, term, loc);
results.reconstruct_terminator_effect(state, term, loc);
results.analysis.apply_terminator_effect(state, term, loc);
vis.visit_terminator_after_primary_effect(results, state, term, loc);

vis.visit_block_end(state);
Expand Down
16 changes: 7 additions & 9 deletions compiler/rustc_mir_dataflow/src/framework/graphviz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,20 +544,18 @@ impl<D> StateDiffCollector<D> {
}
}

impl<'tcx, A> ResultsVisitor<'_, 'tcx, Results<'tcx, A>> for StateDiffCollector<A::Domain>
impl<'tcx, A> ResultsVisitor<'_, 'tcx, A> for StateDiffCollector<A::Domain>
where
A: Analysis<'tcx>,
A::Domain: DebugWithContext<A>,
{
type Domain = A::Domain;

fn visit_block_start(&mut self, state: &Self::Domain) {
fn visit_block_start(&mut self, state: &A::Domain) {
if A::Direction::IS_FORWARD {
self.prev_state.clone_from(state);
}
}

fn visit_block_end(&mut self, state: &Self::Domain) {
fn visit_block_end(&mut self, state: &A::Domain) {
if A::Direction::IS_BACKWARD {
self.prev_state.clone_from(state);
}
Expand All @@ -566,7 +564,7 @@ where
fn visit_statement_before_primary_effect(
&mut self,
results: &mut Results<'tcx, A>,
state: &Self::Domain,
state: &A::Domain,
_statement: &mir::Statement<'tcx>,
_location: Location,
) {
Expand All @@ -579,7 +577,7 @@ where
fn visit_statement_after_primary_effect(
&mut self,
results: &mut Results<'tcx, A>,
state: &Self::Domain,
state: &A::Domain,
_statement: &mir::Statement<'tcx>,
_location: Location,
) {
Expand All @@ -590,7 +588,7 @@ where
fn visit_terminator_before_primary_effect(
&mut self,
results: &mut Results<'tcx, A>,
state: &Self::Domain,
state: &A::Domain,
_terminator: &mir::Terminator<'tcx>,
_location: Location,
) {
Expand All @@ -603,7 +601,7 @@ where
fn visit_terminator_after_primary_effect(
&mut self,
results: &mut Results<'tcx, A>,
state: &Self::Domain,
state: &A::Domain,
_terminator: &mir::Terminator<'tcx>,
_location: Location,
) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_dataflow/src/framework/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub use self::cursor::ResultsCursor;
pub use self::direction::{Backward, Direction, Forward};
pub use self::lattice::{JoinSemiLattice, MaybeReachable};
pub use self::results::{EntrySets, Results};
pub use self::visitor::{ResultsVisitable, ResultsVisitor, visit_results};
pub use self::visitor::{ResultsVisitor, visit_results};

/// Analysis domains are all bitsets of various kinds. This trait holds
/// operations needed by all of them.
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_mir_dataflow/src/framework/results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ where
&mut self,
body: &'mir mir::Body<'tcx>,
blocks: impl IntoIterator<Item = BasicBlock>,
vis: &mut impl ResultsVisitor<'mir, 'tcx, Self, Domain = A::Domain>,
vis: &mut impl ResultsVisitor<'mir, 'tcx, A>,
) {
visit_results(body, blocks, self, vis)
}

pub fn visit_reachable_with<'mir>(
&mut self,
body: &'mir mir::Body<'tcx>,
vis: &mut impl ResultsVisitor<'mir, 'tcx, Self, Domain = A::Domain>,
vis: &mut impl ResultsVisitor<'mir, 'tcx, A>,
) {
let blocks = traversal::reachable(body);
visit_results(body, blocks.map(|(bb, _)| bb), self, vis)
Expand Down
Loading
Loading