Skip to content

Commit

Permalink
Auto merge of rust-lang#128360 - matthiaskrgr:rollup-wwy5mkj, r=matth…
Browse files Browse the repository at this point in the history
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#126247 (rustdoc: word wrap CamelCase in the item list table and sidebar)
 - rust-lang#128104 (Not lint pub structs without pub constructors intentionally)
 - rust-lang#128153 (Stop using `MoveDataParamEnv` for places that don't need a param-env)
 - rust-lang#128284 (Stabilize offset_of_nested)
 - rust-lang#128342 (simplify the use of `CiEnv`)
 - rust-lang#128355 (triagebot: make sure Nora is called Nora)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Jul 29, 2024
2 parents 612a33f + c261620 commit 368e2fd
Show file tree
Hide file tree
Showing 70 changed files with 478 additions and 378 deletions.
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4826,6 +4826,7 @@ dependencies = [
"tracing",
"tracing-subscriber",
"tracing-tree",
"unicode-segmentation",
]

[[package]]
Expand Down
16 changes: 7 additions & 9 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use rustc_mir_dataflow::impls::{
use rustc_mir_dataflow::move_paths::{
InitIndex, InitLocation, LookupResult, MoveData, MoveOutIndex, MovePathIndex,
};
use rustc_mir_dataflow::{Analysis, MoveDataParamEnv};
use rustc_mir_dataflow::Analysis;
use rustc_session::lint::builtin::UNUSED_MUT;
use rustc_span::{Span, Symbol};
use rustc_target::abi::FieldIdx;
Expand Down Expand Up @@ -194,17 +194,15 @@ fn do_mir_borrowck<'tcx>(
.iter_enumerated()
.map(|(idx, body)| (idx, MoveData::gather_moves(body, tcx, param_env, |_| true)));

let mdpe = MoveDataParamEnv { move_data, param_env };

let mut flow_inits = MaybeInitializedPlaces::new(tcx, body, &mdpe)
let mut flow_inits = MaybeInitializedPlaces::new(tcx, body, &move_data)
.into_engine(tcx, body)
.pass_name("borrowck")
.iterate_to_fixpoint()
.into_results_cursor(body);

let locals_are_invalidated_at_exit = tcx.hir().body_owner_kind(def).is_fn_or_closure();
let borrow_set =
Rc::new(BorrowSet::build(tcx, body, locals_are_invalidated_at_exit, &mdpe.move_data));
Rc::new(BorrowSet::build(tcx, body, locals_are_invalidated_at_exit, &move_data));

// Compute non-lexical lifetimes.
let nll::NllOutput {
Expand All @@ -222,7 +220,7 @@ fn do_mir_borrowck<'tcx>(
&location_table,
param_env,
&mut flow_inits,
&mdpe.move_data,
&move_data,
&borrow_set,
tcx.closure_captures(def),
consumer_options,
Expand Down Expand Up @@ -254,11 +252,11 @@ fn do_mir_borrowck<'tcx>(
.into_engine(tcx, body)
.pass_name("borrowck")
.iterate_to_fixpoint();
let flow_uninits = MaybeUninitializedPlaces::new(tcx, body, &mdpe)
let flow_uninits = MaybeUninitializedPlaces::new(tcx, body, &move_data)
.into_engine(tcx, body)
.pass_name("borrowck")
.iterate_to_fixpoint();
let flow_ever_inits = EverInitializedPlaces::new(body, &mdpe)
let flow_ever_inits = EverInitializedPlaces::new(body, &move_data)
.into_engine(tcx, body)
.pass_name("borrowck")
.iterate_to_fixpoint();
Expand Down Expand Up @@ -324,7 +322,7 @@ fn do_mir_borrowck<'tcx>(
infcx: &infcx,
param_env,
body,
move_data: &mdpe.move_data,
move_data: &move_data,
location_table: &location_table,
movable_coroutine,
locals_are_invalidated_at_exit,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_error_codes/src/error_codes/E0795.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Invalid argument for the `offset_of!` macro.
Erroneous code example:

```compile_fail,E0795
#![feature(offset_of_enum, offset_of_nested)]
#![feature(offset_of_enum)]
let x = std::mem::offset_of!(Option<u8>, Some);
```
Expand All @@ -16,7 +16,7 @@ The offset of the contained `u8` in the `Option<u8>` can be found by specifying
the field name `0`:

```
#![feature(offset_of_enum, offset_of_nested)]
#![feature(offset_of_enum)]
let x: usize = std::mem::offset_of!(Option<u8>, Some.0);
```
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ declare_features! (
(accepted, non_exhaustive, "1.40.0", Some(44109)),
/// Allows `foo.rs` as an alternative to `foo/mod.rs`.
(accepted, non_modrs_mods, "1.30.0", Some(44660)),
/// Allows using multiple nested field accesses in offset_of!
(accepted, offset_of_nested, "CURRENT_RUSTC_VERSION", Some(120140)),
/// Allows the use of or-patterns (e.g., `0 | 1`).
(accepted, or_patterns, "1.53.0", Some(54883)),
/// Allows using `+bundle,+whole-archive` link modifiers with native libs.
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,6 @@ declare_features! (
(unstable, object_safe_for_dispatch, "1.40.0", Some(43561)),
/// Allows using enums in offset_of!
(unstable, offset_of_enum, "1.75.0", Some(120141)),
/// Allows using multiple nested field accesses in offset_of!
(unstable, offset_of_nested, "1.77.0", Some(120140)),
/// Allows using fields with slice type in offset_of!
(unstable, offset_of_slice, "CURRENT_RUSTC_VERSION", Some(126151)),
/// Allows using `#[optimize(X)]`.
Expand Down
12 changes: 0 additions & 12 deletions compiler/rustc_hir_typeck/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3338,18 +3338,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
) -> Ty<'tcx> {
let container = self.lower_ty(container).normalized;

if let Some(ident_2) = fields.get(1)
&& !self.tcx.features().offset_of_nested
{
rustc_session::parse::feature_err(
&self.tcx.sess,
sym::offset_of_nested,
ident_2.span,
"only a single ident or integer is stable as the field in offset_of",
)
.emit();
}

let mut field_indices = Vec::with_capacity(fields.len());
let mut current_container = container;
let mut fields = fields.into_iter();
Expand Down
7 changes: 2 additions & 5 deletions compiler/rustc_mir_dataflow/src/drop_flag_effects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use rustc_target::abi::VariantIdx;
use tracing::debug;

use super::move_paths::{InitKind, LookupResult, MoveData, MovePathIndex};
use super::MoveDataParamEnv;
use crate::elaborate_drops::DropFlagState;

pub fn move_path_children_matching<'tcx, F>(
Expand Down Expand Up @@ -70,12 +69,11 @@ pub fn on_all_children_bits<'tcx, F>(

pub fn drop_flag_effects_for_function_entry<'tcx, F>(
body: &Body<'tcx>,
ctxt: &MoveDataParamEnv<'tcx>,
move_data: &MoveData<'tcx>,
mut callback: F,
) where
F: FnMut(MovePathIndex, DropFlagState),
{
let move_data = &ctxt.move_data;
for arg in body.args_iter() {
let place = mir::Place::from(arg);
let lookup_result = move_data.rev_lookup.find(place.as_ref());
Expand All @@ -87,13 +85,12 @@ pub fn drop_flag_effects_for_function_entry<'tcx, F>(

pub fn drop_flag_effects_for_location<'tcx, F>(
body: &Body<'tcx>,
ctxt: &MoveDataParamEnv<'tcx>,
move_data: &MoveData<'tcx>,
loc: Location,
mut callback: F,
) where
F: FnMut(MovePathIndex, DropFlagState),
{
let move_data = &ctxt.move_data;
debug!("drop_flag_effects_for_location({:?})", loc);

// first, move out of the RHS
Expand Down
60 changes: 26 additions & 34 deletions compiler/rustc_mir_dataflow/src/impls/initialized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::move_paths::{HasMoveData, InitIndex, InitKind, LookupResult, MoveData
use crate::{
drop_flag_effects, drop_flag_effects_for_function_entry, drop_flag_effects_for_location,
lattice, on_all_children_bits, on_lookup_result_bits, AnalysisDomain, GenKill, GenKillAnalysis,
MaybeReachable, MoveDataParamEnv,
MaybeReachable,
};

/// `MaybeInitializedPlaces` tracks all places that might be
Expand Down Expand Up @@ -52,17 +52,13 @@ use crate::{
pub struct MaybeInitializedPlaces<'a, 'mir, 'tcx> {
tcx: TyCtxt<'tcx>,
body: &'mir Body<'tcx>,
mdpe: &'a MoveDataParamEnv<'tcx>,
move_data: &'a MoveData<'tcx>,
skip_unreachable_unwind: bool,
}

impl<'a, 'mir, 'tcx> MaybeInitializedPlaces<'a, 'mir, 'tcx> {
pub fn new(
tcx: TyCtxt<'tcx>,
body: &'mir Body<'tcx>,
mdpe: &'a MoveDataParamEnv<'tcx>,
) -> Self {
MaybeInitializedPlaces { tcx, body, mdpe, skip_unreachable_unwind: false }
pub fn new(tcx: TyCtxt<'tcx>, body: &'mir Body<'tcx>, move_data: &'a MoveData<'tcx>) -> Self {
MaybeInitializedPlaces { tcx, body, move_data, skip_unreachable_unwind: false }
}

pub fn skipping_unreachable_unwind(mut self) -> Self {
Expand All @@ -89,7 +85,7 @@ impl<'a, 'mir, 'tcx> MaybeInitializedPlaces<'a, 'mir, 'tcx> {

impl<'a, 'mir, 'tcx> HasMoveData<'tcx> for MaybeInitializedPlaces<'a, 'mir, 'tcx> {
fn move_data(&self) -> &MoveData<'tcx> {
&self.mdpe.move_data
self.move_data
}
}

Expand Down Expand Up @@ -131,22 +127,18 @@ impl<'a, 'mir, 'tcx> HasMoveData<'tcx> for MaybeInitializedPlaces<'a, 'mir, 'tcx
pub struct MaybeUninitializedPlaces<'a, 'mir, 'tcx> {
tcx: TyCtxt<'tcx>,
body: &'mir Body<'tcx>,
mdpe: &'a MoveDataParamEnv<'tcx>,
move_data: &'a MoveData<'tcx>,

mark_inactive_variants_as_uninit: bool,
skip_unreachable_unwind: BitSet<mir::BasicBlock>,
}

impl<'a, 'mir, 'tcx> MaybeUninitializedPlaces<'a, 'mir, 'tcx> {
pub fn new(
tcx: TyCtxt<'tcx>,
body: &'mir Body<'tcx>,
mdpe: &'a MoveDataParamEnv<'tcx>,
) -> Self {
pub fn new(tcx: TyCtxt<'tcx>, body: &'mir Body<'tcx>, move_data: &'a MoveData<'tcx>) -> Self {
MaybeUninitializedPlaces {
tcx,
body,
mdpe,
move_data,
mark_inactive_variants_as_uninit: false,
skip_unreachable_unwind: BitSet::new_empty(body.basic_blocks.len()),
}
Expand All @@ -173,7 +165,7 @@ impl<'a, 'mir, 'tcx> MaybeUninitializedPlaces<'a, 'mir, 'tcx> {

impl<'a, 'tcx> HasMoveData<'tcx> for MaybeUninitializedPlaces<'a, '_, 'tcx> {
fn move_data(&self) -> &MoveData<'tcx> {
&self.mdpe.move_data
self.move_data
}
}

Expand Down Expand Up @@ -213,18 +205,18 @@ impl<'a, 'tcx> HasMoveData<'tcx> for MaybeUninitializedPlaces<'a, '_, 'tcx> {
/// that would require a dynamic drop-flag at that statement.
pub struct DefinitelyInitializedPlaces<'a, 'tcx> {
body: &'a Body<'tcx>,
mdpe: &'a MoveDataParamEnv<'tcx>,
move_data: &'a MoveData<'tcx>,
}

impl<'a, 'tcx> DefinitelyInitializedPlaces<'a, 'tcx> {
pub fn new(body: &'a Body<'tcx>, mdpe: &'a MoveDataParamEnv<'tcx>) -> Self {
DefinitelyInitializedPlaces { body, mdpe }
pub fn new(body: &'a Body<'tcx>, move_data: &'a MoveData<'tcx>) -> Self {
DefinitelyInitializedPlaces { body, move_data }
}
}

impl<'a, 'tcx> HasMoveData<'tcx> for DefinitelyInitializedPlaces<'a, 'tcx> {
fn move_data(&self) -> &MoveData<'tcx> {
&self.mdpe.move_data
self.move_data
}
}

Expand Down Expand Up @@ -259,18 +251,18 @@ impl<'a, 'tcx> HasMoveData<'tcx> for DefinitelyInitializedPlaces<'a, 'tcx> {
/// ```
pub struct EverInitializedPlaces<'a, 'mir, 'tcx> {
body: &'mir Body<'tcx>,
mdpe: &'a MoveDataParamEnv<'tcx>,
move_data: &'a MoveData<'tcx>,
}

impl<'a, 'mir, 'tcx> EverInitializedPlaces<'a, 'mir, 'tcx> {
pub fn new(body: &'mir Body<'tcx>, mdpe: &'a MoveDataParamEnv<'tcx>) -> Self {
EverInitializedPlaces { body, mdpe }
pub fn new(body: &'mir Body<'tcx>, move_data: &'a MoveData<'tcx>) -> Self {
EverInitializedPlaces { body, move_data }
}
}

impl<'a, 'tcx> HasMoveData<'tcx> for EverInitializedPlaces<'a, '_, 'tcx> {
fn move_data(&self) -> &MoveData<'tcx> {
&self.mdpe.move_data
self.move_data
}
}

Expand Down Expand Up @@ -328,7 +320,7 @@ impl<'tcx> AnalysisDomain<'tcx> for MaybeInitializedPlaces<'_, '_, 'tcx> {
fn initialize_start_block(&self, _: &mir::Body<'tcx>, state: &mut Self::Domain) {
*state =
MaybeReachable::Reachable(ChunkedBitSet::new_empty(self.move_data().move_paths.len()));
drop_flag_effects_for_function_entry(self.body, self.mdpe, |path, s| {
drop_flag_effects_for_function_entry(self.body, self.move_data, |path, s| {
assert!(s == DropFlagState::Present);
state.gen_(path);
});
Expand All @@ -348,7 +340,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeInitializedPlaces<'_, '_, 'tcx> {
statement: &mir::Statement<'tcx>,
location: Location,
) {
drop_flag_effects_for_location(self.body, self.mdpe, location, |path, s| {
drop_flag_effects_for_location(self.body, self.move_data, location, |path, s| {
Self::update_bits(trans, path, s)
});

Expand Down Expand Up @@ -380,7 +372,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeInitializedPlaces<'_, '_, 'tcx> {
{
edges = TerminatorEdges::Single(target);
}
drop_flag_effects_for_location(self.body, self.mdpe, location, |path, s| {
drop_flag_effects_for_location(self.body, self.move_data, location, |path, s| {
Self::update_bits(state, path, s)
});
edges
Expand Down Expand Up @@ -465,7 +457,7 @@ impl<'tcx> AnalysisDomain<'tcx> for MaybeUninitializedPlaces<'_, '_, 'tcx> {
// set all bits to 1 (uninit) before gathering counter-evidence
state.insert_all();

drop_flag_effects_for_function_entry(self.body, self.mdpe, |path, s| {
drop_flag_effects_for_function_entry(self.body, self.move_data, |path, s| {
assert!(s == DropFlagState::Present);
state.remove(path);
});
Expand All @@ -485,7 +477,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeUninitializedPlaces<'_, '_, 'tcx> {
_statement: &mir::Statement<'tcx>,
location: Location,
) {
drop_flag_effects_for_location(self.body, self.mdpe, location, |path, s| {
drop_flag_effects_for_location(self.body, self.move_data, location, |path, s| {
Self::update_bits(trans, path, s)
});

Expand All @@ -499,7 +491,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeUninitializedPlaces<'_, '_, 'tcx> {
terminator: &'mir mir::Terminator<'tcx>,
location: Location,
) -> TerminatorEdges<'mir, 'tcx> {
drop_flag_effects_for_location(self.body, self.mdpe, location, |path, s| {
drop_flag_effects_for_location(self.body, self.move_data, location, |path, s| {
Self::update_bits(trans, path, s)
});
if self.skip_unreachable_unwind.contains(location.block) {
Expand Down Expand Up @@ -592,7 +584,7 @@ impl<'a, 'tcx> AnalysisDomain<'tcx> for DefinitelyInitializedPlaces<'a, 'tcx> {
fn initialize_start_block(&self, _: &mir::Body<'tcx>, state: &mut Self::Domain) {
state.0.clear();

drop_flag_effects_for_function_entry(self.body, self.mdpe, |path, s| {
drop_flag_effects_for_function_entry(self.body, self.move_data, |path, s| {
assert!(s == DropFlagState::Present);
state.0.insert(path);
});
Expand All @@ -612,7 +604,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for DefinitelyInitializedPlaces<'_, 'tcx> {
_statement: &mir::Statement<'tcx>,
location: Location,
) {
drop_flag_effects_for_location(self.body, self.mdpe, location, |path, s| {
drop_flag_effects_for_location(self.body, self.move_data, location, |path, s| {
Self::update_bits(trans, path, s)
})
}
Expand All @@ -623,7 +615,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for DefinitelyInitializedPlaces<'_, 'tcx> {
terminator: &'mir mir::Terminator<'tcx>,
location: Location,
) -> TerminatorEdges<'mir, 'tcx> {
drop_flag_effects_for_location(self.body, self.mdpe, location, |path, s| {
drop_flag_effects_for_location(self.body, self.move_data, location, |path, s| {
Self::update_bits(trans, path, s)
});
terminator.edges()
Expand Down
Loading

0 comments on commit 368e2fd

Please sign in to comment.