Skip to content

Commit ffecffb

Browse files
committed
Auto merge of #160601 - jhpratt:rollup-c8grRaT, r=<try>
Rollup of 7 pull requests try-job: dist-various-1 try-job: test-various try-job: x86_64-gnu-aux try-job: x86_64-gnu-llvm-21-3 try-job: x86_64-msvc-1 try-job: aarch64-apple try-job: x86_64-mingw-1 try-job: i686-msvc-*
2 parents f73951d + 1b198cb commit ffecffb

39 files changed

Lines changed: 484 additions & 163 deletions

compiler/rustc_attr_parsing/src/attributes/unroll.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ use super::prelude::*;
66

77
pub(crate) struct UnrollParser;
88
impl SingleAttributeParser for UnrollParser {
9-
const PATH: &[Symbol] = &[sym::unroll];
9+
// FIXME(#159429): temporarily renamed to mitigate `#[unroll]` nameres ambiguity.
10+
const PATH: &[Symbol] = &[sym::rustc_unroll];
1011
const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[
1112
Allow(Target::Loop),
1213
Allow(Target::ForLoop),

compiler/rustc_borrowck/src/dataflow.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ use std::fmt;
22

33
use rustc_data_structures::fx::FxIndexMap;
44
use rustc_index::bit_set::{DenseBitSet, MixedBitSet};
5-
use rustc_middle::mir::{
6-
self, BasicBlock, Body, CallReturnPlaces, Location, Place, TerminatorEdges,
7-
};
5+
use rustc_middle::mir::{self, BasicBlock, Body, CallReturnPlaces, Location, Place};
86
use rustc_middle::ty::{RegionVid, TyCtxt};
97
use rustc_mir_dataflow::fmt::DebugWithContext;
108
use rustc_mir_dataflow::impls::{
@@ -76,19 +74,15 @@ impl<'a, 'tcx> Analysis<'tcx> for Borrowck<'a, 'tcx> {
7674
self.ever_inits.apply_early_terminator_effect(&mut state.ever_inits, term, loc);
7775
}
7876

79-
fn apply_primary_terminator_effect<'mir>(
77+
fn apply_primary_terminator_effect(
8078
&self,
8179
state: &mut Self::Domain,
82-
term: &'mir mir::Terminator<'tcx>,
80+
term: &mir::Terminator<'tcx>,
8381
loc: Location,
84-
) -> TerminatorEdges<'mir, 'tcx> {
82+
) {
8583
self.borrows.apply_primary_terminator_effect(&mut state.borrows, term, loc);
8684
self.uninits.apply_primary_terminator_effect(&mut state.uninits, term, loc);
8785
self.ever_inits.apply_primary_terminator_effect(&mut state.ever_inits, term, loc);
88-
89-
// This return value doesn't matter. It's only used by `iterate_to_fixpoint`, which this
90-
// analysis doesn't use.
91-
TerminatorEdges::None
9286
}
9387

9488
fn apply_call_return_effect(
@@ -598,12 +592,12 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
598592
self.kill_loans_out_of_scope_at_location(state, location);
599593
}
600594

601-
fn apply_primary_terminator_effect<'mir>(
595+
fn apply_primary_terminator_effect(
602596
&self,
603597
state: &mut Self::Domain,
604-
terminator: &'mir mir::Terminator<'tcx>,
598+
terminator: &mir::Terminator<'tcx>,
605599
_location: Location,
606-
) -> TerminatorEdges<'mir, 'tcx> {
600+
) {
607601
if let mir::TerminatorKind::InlineAsm { operands, .. } = &terminator.kind {
608602
for op in operands {
609603
if let mir::InlineAsmOperand::Out { place: Some(place), .. }
@@ -613,7 +607,6 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
613607
}
614608
}
615609
}
616-
terminator.edges()
617610
}
618611
}
619612

compiler/rustc_const_eval/src/check_consts/resolver.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::marker::PhantomData;
88
use rustc_index::bit_set::MixedBitSet;
99
use rustc_middle::mir::visit::Visitor;
1010
use rustc_middle::mir::{
11-
self, BasicBlock, CallReturnPlaces, Local, Location, Statement, StatementKind, TerminatorEdges,
11+
self, BasicBlock, CallReturnPlaces, Local, Location, Statement, StatementKind,
1212
};
1313
use rustc_mir_dataflow::fmt::DebugWithContext;
1414
use rustc_mir_dataflow::{Analysis, JoinSemiLattice};
@@ -351,14 +351,13 @@ where
351351
self.transfer_function(state).visit_statement(statement, location);
352352
}
353353

354-
fn apply_primary_terminator_effect<'mir>(
354+
fn apply_primary_terminator_effect(
355355
&self,
356356
state: &mut Self::Domain,
357-
terminator: &'mir mir::Terminator<'tcx>,
357+
terminator: &mir::Terminator<'tcx>,
358358
location: Location,
359-
) -> TerminatorEdges<'mir, 'tcx> {
359+
) {
360360
self.transfer_function(state).visit_terminator(terminator, location);
361-
terminator.edges()
362361
}
363362

364363
fn apply_call_return_effect(

compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,12 @@ pub static BUILTIN_ATTRIBUTES: &[Symbol] = &[
217217
// - https://github.com/rust-lang/rust/issues/153629
218218
sym::rustc_splat,
219219

220-
// The `#[unroll]` attribute.
220+
// The `#[rustc_unroll]` attribute.
221221
//
222222
// - https://github.com/rust-lang/rust/pull/156816
223-
sym::unroll,
223+
//
224+
// FIXME(#159429): temporarily renamed to mitigate `#[unroll]` nameres ambiguity
225+
sym::rustc_unroll,
224226

225227
// `#[instrument_fn = "on|off"]` to insert or inhibit instrumentation function
226228
// calls inside a function, usually around the prologue.

compiler/rustc_hir/src/attrs/data_structures.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1706,7 +1706,8 @@ pub enum AttributeKind {
17061706
limit: Limit,
17071707
},
17081708

1709-
/// Represents `#[unroll]`
1709+
/// Represents `#[rustc_unroll]`
1710+
// FIXME(#159429): temporarily renamed from `#[unroll]` to mitigate nameres ambiguity
17101711
Unroll(UnrollAttr),
17111712

17121713
/// Represents `#[unstable_feature_bound]`.

compiler/rustc_mir_dataflow/src/framework/direction.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,9 @@ impl Direction for Forward {
194194
let terminator = block_data.terminator();
195195
let location = Location { block, statement_index: block_data.statements.len() };
196196
analysis.apply_early_terminator_effect(state, terminator, location);
197-
let edges = analysis.apply_primary_terminator_effect(state, terminator, location);
197+
// Edges are obtained *before* calling `apply_primary_terminator_effect`.
198+
let edges = analysis.get_terminator_edges(state, terminator, location);
199+
analysis.apply_primary_terminator_effect(state, terminator, location);
198200

199201
let exit_state = state;
200202
match edges {

compiler/rustc_mir_dataflow/src/framework/mod.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,19 +196,30 @@ pub trait Analysis<'tcx> {
196196
) {
197197
}
198198

199+
/// Gets the terminator edges. Used by forward analyses only. Called *before*
200+
/// `apply_primary_terminator_effect` is applied; this might seem strange but in practice
201+
/// `MaybeInitializedPlaces` needs that ordering and other analyses work with either ordering.
202+
fn get_terminator_edges<'mir>(
203+
&self,
204+
_state: &Self::Domain,
205+
terminator: &'mir mir::Terminator<'tcx>,
206+
_location: Location,
207+
) -> TerminatorEdges<'mir, 'tcx> {
208+
terminator.edges()
209+
}
210+
199211
/// Updates the current dataflow state with the effect of evaluating a terminator.
200212
///
201213
/// The effect of a successful return from a `Call` terminator should **not** be accounted for
202214
/// in this function. That should go in `apply_call_return_effect`. For example, in the
203215
/// `InitializedPlaces` analyses, the return place for a function call is not marked as
204216
/// initialized here.
205-
fn apply_primary_terminator_effect<'mir>(
217+
fn apply_primary_terminator_effect(
206218
&self,
207219
_state: &mut Self::Domain,
208-
terminator: &'mir mir::Terminator<'tcx>,
220+
_terminator: &mir::Terminator<'tcx>,
209221
_location: Location,
210-
) -> TerminatorEdges<'mir, 'tcx> {
211-
terminator.edges()
222+
) {
212223
}
213224

214225
/* Edge-specific effects */

compiler/rustc_mir_dataflow/src/framework/tests.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,15 +197,14 @@ impl<'tcx, D: Direction> Analysis<'tcx> for MockAnalysis<'tcx, D> {
197197
assert!(state.insert(idx));
198198
}
199199

200-
fn apply_primary_terminator_effect<'mir>(
200+
fn apply_primary_terminator_effect(
201201
&self,
202202
state: &mut Self::Domain,
203-
terminator: &'mir mir::Terminator<'tcx>,
203+
_terminator: &mir::Terminator<'tcx>,
204204
location: Location,
205-
) -> TerminatorEdges<'mir, 'tcx> {
205+
) {
206206
let idx = self.effect(Effect::Primary.at_index(location.statement_index));
207207
assert!(state.insert(idx));
208-
terminator.edges()
209208
}
210209
}
211210

compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,13 @@ impl<'tcx> Analysis<'tcx> for MaybeBorrowedLocals {
4141
Self::transfer_function(state).visit_statement(statement, location);
4242
}
4343

44-
fn apply_primary_terminator_effect<'mir>(
44+
fn apply_primary_terminator_effect(
4545
&self,
4646
state: &mut Self::Domain,
47-
terminator: &'mir Terminator<'tcx>,
47+
terminator: &Terminator<'tcx>,
4848
location: Location,
49-
) -> TerminatorEdges<'mir, 'tcx> {
49+
) {
5050
Self::transfer_function(state).visit_terminator(terminator, location);
51-
terminator.edges()
5251
}
5352
}
5453

compiler/rustc_mir_dataflow/src/impls/initialized.rs

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -391,14 +391,15 @@ impl<'tcx> Analysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
391391
}
392392
}
393393

394-
fn apply_primary_terminator_effect<'mir>(
394+
fn get_terminator_edges<'mir>(
395395
&self,
396-
state: &mut Self::Domain,
396+
state: &Self::Domain,
397397
terminator: &'mir mir::Terminator<'tcx>,
398-
location: Location,
398+
_location: Location,
399399
) -> TerminatorEdges<'mir, 'tcx> {
400-
// Note: `edges` must be computed first because `drop_flag_effects_for_location` can change
401-
// the result of `is_unwind_dead`.
400+
// Note: this relies on `get_terminator_edges` being called before
401+
// `apply_primary_terminator_effect` because the result of `is_unwind_dead` is affected by
402+
// the `drop_flag_effects_for_location` in `apply_primary_terminator_effect`.
402403
let mut edges = terminator.edges();
403404
if self.skip_unreachable_unwind
404405
&& let mir::TerminatorKind::Drop { target, unwind, place, replace: _, drop: _ } =
@@ -408,10 +409,18 @@ impl<'tcx> Analysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
408409
{
409410
edges = TerminatorEdges::Single(target);
410411
}
412+
edges
413+
}
414+
415+
fn apply_primary_terminator_effect(
416+
&self,
417+
state: &mut Self::Domain,
418+
_terminator: &mir::Terminator<'tcx>,
419+
location: Location,
420+
) {
411421
drop_flag_effects_for_location(self.body, self.move_data, location, |path, s| {
412422
Self::update_bits(state, path, s)
413423
});
414-
edges
415424
}
416425

417426
fn apply_call_return_effect(
@@ -514,15 +523,12 @@ impl<'tcx> Analysis<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
514523
// mutable borrow occurs. Places cannot become uninitialized through a mutable reference.
515524
}
516525

517-
fn apply_primary_terminator_effect<'mir>(
526+
fn get_terminator_edges<'mir>(
518527
&self,
519-
state: &mut Self::Domain,
528+
_state: &Self::Domain,
520529
terminator: &'mir mir::Terminator<'tcx>,
521530
location: Location,
522531
) -> TerminatorEdges<'mir, 'tcx> {
523-
drop_flag_effects_for_location(self.body, self.move_data, location, |path, s| {
524-
Self::update_bits(state, path, s)
525-
});
526532
if self.skip_unreachable_unwind.contains(location.block) {
527533
let mir::TerminatorKind::Drop { target, unwind, .. } = terminator.kind else { bug!() };
528534
assert_matches!(unwind, mir::UnwindAction::Cleanup(_));
@@ -532,6 +538,17 @@ impl<'tcx> Analysis<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
532538
}
533539
}
534540

541+
fn apply_primary_terminator_effect(
542+
&self,
543+
state: &mut Self::Domain,
544+
_terminator: &mir::Terminator<'tcx>,
545+
location: Location,
546+
) {
547+
drop_flag_effects_for_location(self.body, self.move_data, location, |path, s| {
548+
Self::update_bits(state, path, s)
549+
});
550+
}
551+
535552
fn apply_call_return_effect(
536553
&self,
537554
state: &mut Self::Domain,
@@ -633,13 +650,13 @@ impl<'tcx> Analysis<'tcx> for EverInitializedPlaces<'_, 'tcx> {
633650
}
634651
}
635652

636-
#[instrument(skip(self, state, terminator), level = "debug")]
637-
fn apply_primary_terminator_effect<'mir>(
653+
#[instrument(skip(self, state, _terminator), level = "debug")]
654+
fn apply_primary_terminator_effect(
638655
&self,
639656
state: &mut Self::Domain,
640-
terminator: &'mir mir::Terminator<'tcx>,
657+
_terminator: &mir::Terminator<'tcx>,
641658
location: Location,
642-
) -> TerminatorEdges<'mir, 'tcx> {
659+
) {
643660
let move_data = self.move_data();
644661
let init_loc_map = &move_data.init_loc_map;
645662

@@ -652,7 +669,6 @@ impl<'tcx> Analysis<'tcx> for EverInitializedPlaces<'_, 'tcx> {
652669
None
653670
}
654671
}));
655-
terminator.edges()
656672
}
657673

658674
fn apply_call_return_effect(

0 commit comments

Comments
 (0)