Skip to content

Commit 368e2fd

Browse files
committed
Auto merge of rust-lang#128360 - matthiaskrgr:rollup-wwy5mkj, r=matthiaskrgr
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
2 parents 612a33f + c261620 commit 368e2fd

File tree

70 files changed

+478
-378
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+478
-378
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -4826,6 +4826,7 @@ dependencies = [
48264826
"tracing",
48274827
"tracing-subscriber",
48284828
"tracing-tree",
4829+
"unicode-segmentation",
48294830
]
48304831

48314832
[[package]]

compiler/rustc_borrowck/src/lib.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use rustc_mir_dataflow::impls::{
4545
use rustc_mir_dataflow::move_paths::{
4646
InitIndex, InitLocation, LookupResult, MoveData, MoveOutIndex, MovePathIndex,
4747
};
48-
use rustc_mir_dataflow::{Analysis, MoveDataParamEnv};
48+
use rustc_mir_dataflow::Analysis;
4949
use rustc_session::lint::builtin::UNUSED_MUT;
5050
use rustc_span::{Span, Symbol};
5151
use rustc_target::abi::FieldIdx;
@@ -194,17 +194,15 @@ fn do_mir_borrowck<'tcx>(
194194
.iter_enumerated()
195195
.map(|(idx, body)| (idx, MoveData::gather_moves(body, tcx, param_env, |_| true)));
196196

197-
let mdpe = MoveDataParamEnv { move_data, param_env };
198-
199-
let mut flow_inits = MaybeInitializedPlaces::new(tcx, body, &mdpe)
197+
let mut flow_inits = MaybeInitializedPlaces::new(tcx, body, &move_data)
200198
.into_engine(tcx, body)
201199
.pass_name("borrowck")
202200
.iterate_to_fixpoint()
203201
.into_results_cursor(body);
204202

205203
let locals_are_invalidated_at_exit = tcx.hir().body_owner_kind(def).is_fn_or_closure();
206204
let borrow_set =
207-
Rc::new(BorrowSet::build(tcx, body, locals_are_invalidated_at_exit, &mdpe.move_data));
205+
Rc::new(BorrowSet::build(tcx, body, locals_are_invalidated_at_exit, &move_data));
208206

209207
// Compute non-lexical lifetimes.
210208
let nll::NllOutput {
@@ -222,7 +220,7 @@ fn do_mir_borrowck<'tcx>(
222220
&location_table,
223221
param_env,
224222
&mut flow_inits,
225-
&mdpe.move_data,
223+
&move_data,
226224
&borrow_set,
227225
tcx.closure_captures(def),
228226
consumer_options,
@@ -254,11 +252,11 @@ fn do_mir_borrowck<'tcx>(
254252
.into_engine(tcx, body)
255253
.pass_name("borrowck")
256254
.iterate_to_fixpoint();
257-
let flow_uninits = MaybeUninitializedPlaces::new(tcx, body, &mdpe)
255+
let flow_uninits = MaybeUninitializedPlaces::new(tcx, body, &move_data)
258256
.into_engine(tcx, body)
259257
.pass_name("borrowck")
260258
.iterate_to_fixpoint();
261-
let flow_ever_inits = EverInitializedPlaces::new(body, &mdpe)
259+
let flow_ever_inits = EverInitializedPlaces::new(body, &move_data)
262260
.into_engine(tcx, body)
263261
.pass_name("borrowck")
264262
.iterate_to_fixpoint();
@@ -324,7 +322,7 @@ fn do_mir_borrowck<'tcx>(
324322
infcx: &infcx,
325323
param_env,
326324
body,
327-
move_data: &mdpe.move_data,
325+
move_data: &move_data,
328326
location_table: &location_table,
329327
movable_coroutine,
330328
locals_are_invalidated_at_exit,

compiler/rustc_error_codes/src/error_codes/E0795.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Invalid argument for the `offset_of!` macro.
33
Erroneous code example:
44

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

1818
```
19-
#![feature(offset_of_enum, offset_of_nested)]
19+
#![feature(offset_of_enum)]
2020
2121
let x: usize = std::mem::offset_of!(Option<u8>, Some.0);
2222
```

compiler/rustc_feature/src/accepted.rs

+2
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ declare_features! (
292292
(accepted, non_exhaustive, "1.40.0", Some(44109)),
293293
/// Allows `foo.rs` as an alternative to `foo/mod.rs`.
294294
(accepted, non_modrs_mods, "1.30.0", Some(44660)),
295+
/// Allows using multiple nested field accesses in offset_of!
296+
(accepted, offset_of_nested, "CURRENT_RUSTC_VERSION", Some(120140)),
295297
/// Allows the use of or-patterns (e.g., `0 | 1`).
296298
(accepted, or_patterns, "1.53.0", Some(54883)),
297299
/// Allows using `+bundle,+whole-archive` link modifiers with native libs.

compiler/rustc_feature/src/unstable.rs

-2
Original file line numberDiff line numberDiff line change
@@ -560,8 +560,6 @@ declare_features! (
560560
(unstable, object_safe_for_dispatch, "1.40.0", Some(43561)),
561561
/// Allows using enums in offset_of!
562562
(unstable, offset_of_enum, "1.75.0", Some(120141)),
563-
/// Allows using multiple nested field accesses in offset_of!
564-
(unstable, offset_of_nested, "1.77.0", Some(120140)),
565563
/// Allows using fields with slice type in offset_of!
566564
(unstable, offset_of_slice, "CURRENT_RUSTC_VERSION", Some(126151)),
567565
/// Allows using `#[optimize(X)]`.

compiler/rustc_hir_typeck/src/expr.rs

-12
Original file line numberDiff line numberDiff line change
@@ -3338,18 +3338,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
33383338
) -> Ty<'tcx> {
33393339
let container = self.lower_ty(container).normalized;
33403340

3341-
if let Some(ident_2) = fields.get(1)
3342-
&& !self.tcx.features().offset_of_nested
3343-
{
3344-
rustc_session::parse::feature_err(
3345-
&self.tcx.sess,
3346-
sym::offset_of_nested,
3347-
ident_2.span,
3348-
"only a single ident or integer is stable as the field in offset_of",
3349-
)
3350-
.emit();
3351-
}
3352-
33533341
let mut field_indices = Vec::with_capacity(fields.len());
33543342
let mut current_container = container;
33553343
let mut fields = fields.into_iter();

compiler/rustc_mir_dataflow/src/drop_flag_effects.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use rustc_target::abi::VariantIdx;
33
use tracing::debug;
44

55
use super::move_paths::{InitKind, LookupResult, MoveData, MovePathIndex};
6-
use super::MoveDataParamEnv;
76
use crate::elaborate_drops::DropFlagState;
87

98
pub fn move_path_children_matching<'tcx, F>(
@@ -70,12 +69,11 @@ pub fn on_all_children_bits<'tcx, F>(
7069

7170
pub fn drop_flag_effects_for_function_entry<'tcx, F>(
7271
body: &Body<'tcx>,
73-
ctxt: &MoveDataParamEnv<'tcx>,
72+
move_data: &MoveData<'tcx>,
7473
mut callback: F,
7574
) where
7675
F: FnMut(MovePathIndex, DropFlagState),
7776
{
78-
let move_data = &ctxt.move_data;
7977
for arg in body.args_iter() {
8078
let place = mir::Place::from(arg);
8179
let lookup_result = move_data.rev_lookup.find(place.as_ref());
@@ -87,13 +85,12 @@ pub fn drop_flag_effects_for_function_entry<'tcx, F>(
8785

8886
pub fn drop_flag_effects_for_location<'tcx, F>(
8987
body: &Body<'tcx>,
90-
ctxt: &MoveDataParamEnv<'tcx>,
88+
move_data: &MoveData<'tcx>,
9189
loc: Location,
9290
mut callback: F,
9391
) where
9492
F: FnMut(MovePathIndex, DropFlagState),
9593
{
96-
let move_data = &ctxt.move_data;
9794
debug!("drop_flag_effects_for_location({:?})", loc);
9895

9996
// first, move out of the RHS

compiler/rustc_mir_dataflow/src/impls/initialized.rs

+26-34
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::move_paths::{HasMoveData, InitIndex, InitKind, LookupResult, MoveData
1111
use crate::{
1212
drop_flag_effects, drop_flag_effects_for_function_entry, drop_flag_effects_for_location,
1313
lattice, on_all_children_bits, on_lookup_result_bits, AnalysisDomain, GenKill, GenKillAnalysis,
14-
MaybeReachable, MoveDataParamEnv,
14+
MaybeReachable,
1515
};
1616

1717
/// `MaybeInitializedPlaces` tracks all places that might be
@@ -52,17 +52,13 @@ use crate::{
5252
pub struct MaybeInitializedPlaces<'a, 'mir, 'tcx> {
5353
tcx: TyCtxt<'tcx>,
5454
body: &'mir Body<'tcx>,
55-
mdpe: &'a MoveDataParamEnv<'tcx>,
55+
move_data: &'a MoveData<'tcx>,
5656
skip_unreachable_unwind: bool,
5757
}
5858

5959
impl<'a, 'mir, 'tcx> MaybeInitializedPlaces<'a, 'mir, 'tcx> {
60-
pub fn new(
61-
tcx: TyCtxt<'tcx>,
62-
body: &'mir Body<'tcx>,
63-
mdpe: &'a MoveDataParamEnv<'tcx>,
64-
) -> Self {
65-
MaybeInitializedPlaces { tcx, body, mdpe, skip_unreachable_unwind: false }
60+
pub fn new(tcx: TyCtxt<'tcx>, body: &'mir Body<'tcx>, move_data: &'a MoveData<'tcx>) -> Self {
61+
MaybeInitializedPlaces { tcx, body, move_data, skip_unreachable_unwind: false }
6662
}
6763

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

9086
impl<'a, 'mir, 'tcx> HasMoveData<'tcx> for MaybeInitializedPlaces<'a, 'mir, 'tcx> {
9187
fn move_data(&self) -> &MoveData<'tcx> {
92-
&self.mdpe.move_data
88+
self.move_data
9389
}
9490
}
9591

@@ -131,22 +127,18 @@ impl<'a, 'mir, 'tcx> HasMoveData<'tcx> for MaybeInitializedPlaces<'a, 'mir, 'tcx
131127
pub struct MaybeUninitializedPlaces<'a, 'mir, 'tcx> {
132128
tcx: TyCtxt<'tcx>,
133129
body: &'mir Body<'tcx>,
134-
mdpe: &'a MoveDataParamEnv<'tcx>,
130+
move_data: &'a MoveData<'tcx>,
135131

136132
mark_inactive_variants_as_uninit: bool,
137133
skip_unreachable_unwind: BitSet<mir::BasicBlock>,
138134
}
139135

140136
impl<'a, 'mir, 'tcx> MaybeUninitializedPlaces<'a, 'mir, 'tcx> {
141-
pub fn new(
142-
tcx: TyCtxt<'tcx>,
143-
body: &'mir Body<'tcx>,
144-
mdpe: &'a MoveDataParamEnv<'tcx>,
145-
) -> Self {
137+
pub fn new(tcx: TyCtxt<'tcx>, body: &'mir Body<'tcx>, move_data: &'a MoveData<'tcx>) -> Self {
146138
MaybeUninitializedPlaces {
147139
tcx,
148140
body,
149-
mdpe,
141+
move_data,
150142
mark_inactive_variants_as_uninit: false,
151143
skip_unreachable_unwind: BitSet::new_empty(body.basic_blocks.len()),
152144
}
@@ -173,7 +165,7 @@ impl<'a, 'mir, 'tcx> MaybeUninitializedPlaces<'a, 'mir, 'tcx> {
173165

174166
impl<'a, 'tcx> HasMoveData<'tcx> for MaybeUninitializedPlaces<'a, '_, 'tcx> {
175167
fn move_data(&self) -> &MoveData<'tcx> {
176-
&self.mdpe.move_data
168+
self.move_data
177169
}
178170
}
179171

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

219211
impl<'a, 'tcx> DefinitelyInitializedPlaces<'a, 'tcx> {
220-
pub fn new(body: &'a Body<'tcx>, mdpe: &'a MoveDataParamEnv<'tcx>) -> Self {
221-
DefinitelyInitializedPlaces { body, mdpe }
212+
pub fn new(body: &'a Body<'tcx>, move_data: &'a MoveData<'tcx>) -> Self {
213+
DefinitelyInitializedPlaces { body, move_data }
222214
}
223215
}
224216

225217
impl<'a, 'tcx> HasMoveData<'tcx> for DefinitelyInitializedPlaces<'a, 'tcx> {
226218
fn move_data(&self) -> &MoveData<'tcx> {
227-
&self.mdpe.move_data
219+
self.move_data
228220
}
229221
}
230222

@@ -259,18 +251,18 @@ impl<'a, 'tcx> HasMoveData<'tcx> for DefinitelyInitializedPlaces<'a, 'tcx> {
259251
/// ```
260252
pub struct EverInitializedPlaces<'a, 'mir, 'tcx> {
261253
body: &'mir Body<'tcx>,
262-
mdpe: &'a MoveDataParamEnv<'tcx>,
254+
move_data: &'a MoveData<'tcx>,
263255
}
264256

265257
impl<'a, 'mir, 'tcx> EverInitializedPlaces<'a, 'mir, 'tcx> {
266-
pub fn new(body: &'mir Body<'tcx>, mdpe: &'a MoveDataParamEnv<'tcx>) -> Self {
267-
EverInitializedPlaces { body, mdpe }
258+
pub fn new(body: &'mir Body<'tcx>, move_data: &'a MoveData<'tcx>) -> Self {
259+
EverInitializedPlaces { body, move_data }
268260
}
269261
}
270262

271263
impl<'a, 'tcx> HasMoveData<'tcx> for EverInitializedPlaces<'a, '_, 'tcx> {
272264
fn move_data(&self) -> &MoveData<'tcx> {
273-
&self.mdpe.move_data
265+
self.move_data
274266
}
275267
}
276268

@@ -328,7 +320,7 @@ impl<'tcx> AnalysisDomain<'tcx> for MaybeInitializedPlaces<'_, '_, 'tcx> {
328320
fn initialize_start_block(&self, _: &mir::Body<'tcx>, state: &mut Self::Domain) {
329321
*state =
330322
MaybeReachable::Reachable(ChunkedBitSet::new_empty(self.move_data().move_paths.len()));
331-
drop_flag_effects_for_function_entry(self.body, self.mdpe, |path, s| {
323+
drop_flag_effects_for_function_entry(self.body, self.move_data, |path, s| {
332324
assert!(s == DropFlagState::Present);
333325
state.gen_(path);
334326
});
@@ -348,7 +340,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeInitializedPlaces<'_, '_, 'tcx> {
348340
statement: &mir::Statement<'tcx>,
349341
location: Location,
350342
) {
351-
drop_flag_effects_for_location(self.body, self.mdpe, location, |path, s| {
343+
drop_flag_effects_for_location(self.body, self.move_data, location, |path, s| {
352344
Self::update_bits(trans, path, s)
353345
});
354346

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

468-
drop_flag_effects_for_function_entry(self.body, self.mdpe, |path, s| {
460+
drop_flag_effects_for_function_entry(self.body, self.move_data, |path, s| {
469461
assert!(s == DropFlagState::Present);
470462
state.remove(path);
471463
});
@@ -485,7 +477,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeUninitializedPlaces<'_, '_, 'tcx> {
485477
_statement: &mir::Statement<'tcx>,
486478
location: Location,
487479
) {
488-
drop_flag_effects_for_location(self.body, self.mdpe, location, |path, s| {
480+
drop_flag_effects_for_location(self.body, self.move_data, location, |path, s| {
489481
Self::update_bits(trans, path, s)
490482
});
491483

@@ -499,7 +491,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeUninitializedPlaces<'_, '_, 'tcx> {
499491
terminator: &'mir mir::Terminator<'tcx>,
500492
location: Location,
501493
) -> TerminatorEdges<'mir, 'tcx> {
502-
drop_flag_effects_for_location(self.body, self.mdpe, location, |path, s| {
494+
drop_flag_effects_for_location(self.body, self.move_data, location, |path, s| {
503495
Self::update_bits(trans, path, s)
504496
});
505497
if self.skip_unreachable_unwind.contains(location.block) {
@@ -592,7 +584,7 @@ impl<'a, 'tcx> AnalysisDomain<'tcx> for DefinitelyInitializedPlaces<'a, 'tcx> {
592584
fn initialize_start_block(&self, _: &mir::Body<'tcx>, state: &mut Self::Domain) {
593585
state.0.clear();
594586

595-
drop_flag_effects_for_function_entry(self.body, self.mdpe, |path, s| {
587+
drop_flag_effects_for_function_entry(self.body, self.move_data, |path, s| {
596588
assert!(s == DropFlagState::Present);
597589
state.0.insert(path);
598590
});
@@ -612,7 +604,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for DefinitelyInitializedPlaces<'_, 'tcx> {
612604
_statement: &mir::Statement<'tcx>,
613605
location: Location,
614606
) {
615-
drop_flag_effects_for_location(self.body, self.mdpe, location, |path, s| {
607+
drop_flag_effects_for_location(self.body, self.move_data, location, |path, s| {
616608
Self::update_bits(trans, path, s)
617609
})
618610
}
@@ -623,7 +615,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for DefinitelyInitializedPlaces<'_, 'tcx> {
623615
terminator: &'mir mir::Terminator<'tcx>,
624616
location: Location,
625617
) -> TerminatorEdges<'mir, 'tcx> {
626-
drop_flag_effects_for_location(self.body, self.mdpe, location, |path, s| {
618+
drop_flag_effects_for_location(self.body, self.move_data, location, |path, s| {
627619
Self::update_bits(trans, path, s)
628620
});
629621
terminator.edges()

0 commit comments

Comments
 (0)