Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit ada5e2c

Browse files
committed
Auto merge of rust-lang#125824 - matthiaskrgr:rollup-eam7i0p, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#125652 (Revert propagation of drop-live information from Polonius) - rust-lang#125730 (Apply `x clippy --fix` and `x fmt` on Rustc) - rust-lang#125756 (coverage: Optionally instrument the RHS of lazy logical operators) - rust-lang#125776 (Stop using `translate_args` in the new solver) - rust-lang#125796 (Also InstSimplify `&raw*`) - rust-lang#125807 (Also resolve the type of constants, even if we already turned it into an error constant) - rust-lang#125816 (Don't build the `rust-demangler` binary for coverage tests) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 2a2c29a + df9cd17 commit ada5e2c

File tree

51 files changed

+876
-162
lines changed

Some content is hidden

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

51 files changed

+876
-162
lines changed

compiler/rustc_borrowck/src/type_check/liveness/mod.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use std::rc::Rc;
1414
use crate::{
1515
constraints::OutlivesConstraintSet,
1616
facts::{AllFacts, AllFactsExt},
17-
location::LocationTable,
1817
region_infer::values::LivenessValues,
1918
universal_regions::UniversalRegions,
2019
};
@@ -39,7 +38,6 @@ pub(super) fn generate<'mir, 'tcx>(
3938
elements: &Rc<DenseLocationMap>,
4039
flow_inits: &mut ResultsCursor<'mir, 'tcx, MaybeInitializedPlaces<'mir, 'tcx>>,
4140
move_data: &MoveData<'tcx>,
42-
location_table: &LocationTable,
4341
use_polonius: bool,
4442
) {
4543
debug!("liveness::generate");
@@ -53,11 +51,9 @@ pub(super) fn generate<'mir, 'tcx>(
5351
compute_relevant_live_locals(typeck.tcx(), &free_regions, body);
5452
let facts_enabled = use_polonius || AllFacts::enabled(typeck.tcx());
5553

56-
let polonius_drop_used = facts_enabled.then(|| {
57-
let mut drop_used = Vec::new();
58-
polonius::populate_access_facts(typeck, body, location_table, move_data, &mut drop_used);
59-
drop_used
60-
});
54+
if facts_enabled {
55+
polonius::populate_access_facts(typeck, body, move_data);
56+
};
6157

6258
trace::trace(
6359
typeck,
@@ -67,7 +63,6 @@ pub(super) fn generate<'mir, 'tcx>(
6763
move_data,
6864
relevant_live_locals,
6965
boring_locals,
70-
polonius_drop_used,
7166
);
7267

7368
// Mark regions that should be live where they appear within rvalues or within a call: like

compiler/rustc_borrowck/src/type_check/liveness/polonius.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,10 @@ impl<'a, 'tcx> Visitor<'tcx> for UseFactsExtractor<'a, 'tcx> {
8585
pub(super) fn populate_access_facts<'a, 'tcx>(
8686
typeck: &mut TypeChecker<'a, 'tcx>,
8787
body: &Body<'tcx>,
88-
location_table: &LocationTable,
8988
move_data: &MoveData<'tcx>,
90-
//FIXME: this is not mutated, but expected to be modified as
91-
// out param, bug?
92-
dropped_at: &mut Vec<(Local, Location)>,
9389
) {
9490
debug!("populate_access_facts()");
91+
let location_table = typeck.borrowck_context.location_table;
9592

9693
if let Some(facts) = typeck.borrowck_context.all_facts.as_mut() {
9794
let mut extractor = UseFactsExtractor {
@@ -104,10 +101,6 @@ pub(super) fn populate_access_facts<'a, 'tcx>(
104101
};
105102
extractor.visit_body(body);
106103

107-
facts.var_dropped_at.extend(
108-
dropped_at.iter().map(|&(local, location)| (local, location_table.mid_index(location))),
109-
);
110-
111104
for (local, local_decl) in body.local_decls.iter_enumerated() {
112105
debug!(
113106
"add use_of_var_derefs_origin facts - local={:?}, type={:?}",

compiler/rustc_borrowck/src/type_check/liveness/trace.rs

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
1616
use rustc_mir_dataflow::move_paths::{HasMoveData, MoveData, MovePathIndex};
1717
use rustc_mir_dataflow::ResultsCursor;
1818

19+
use crate::location::RichLocation;
1920
use crate::{
2021
region_infer::values::{self, LiveLoans},
2122
type_check::liveness::local_use_map::LocalUseMap,
@@ -46,7 +47,6 @@ pub(super) fn trace<'mir, 'tcx>(
4647
move_data: &MoveData<'tcx>,
4748
relevant_live_locals: Vec<Local>,
4849
boring_locals: Vec<Local>,
49-
polonius_drop_used: Option<Vec<(Local, Location)>>,
5050
) {
5151
let local_use_map = &LocalUseMap::build(&relevant_live_locals, elements, body);
5252

@@ -93,9 +93,7 @@ pub(super) fn trace<'mir, 'tcx>(
9393

9494
let mut results = LivenessResults::new(cx);
9595

96-
if let Some(drop_used) = polonius_drop_used {
97-
results.add_extra_drop_facts(drop_used, relevant_live_locals.iter().copied().collect())
98-
}
96+
results.add_extra_drop_facts(&relevant_live_locals);
9997

10098
results.compute_for_all_locals(relevant_live_locals);
10199

@@ -218,21 +216,38 @@ impl<'me, 'typeck, 'flow, 'tcx> LivenessResults<'me, 'typeck, 'flow, 'tcx> {
218216
///
219217
/// Add facts for all locals with free regions, since regions may outlive
220218
/// the function body only at certain nodes in the CFG.
221-
fn add_extra_drop_facts(
222-
&mut self,
223-
drop_used: Vec<(Local, Location)>,
224-
relevant_live_locals: FxIndexSet<Local>,
225-
) {
219+
fn add_extra_drop_facts(&mut self, relevant_live_locals: &[Local]) -> Option<()> {
220+
let drop_used = self
221+
.cx
222+
.typeck
223+
.borrowck_context
224+
.all_facts
225+
.as_ref()
226+
.map(|facts| facts.var_dropped_at.clone())?;
227+
228+
let relevant_live_locals: FxIndexSet<_> = relevant_live_locals.iter().copied().collect();
229+
226230
let locations = IntervalSet::new(self.cx.elements.num_points());
227231

228-
for (local, location) in drop_used {
232+
for (local, location_index) in drop_used {
229233
if !relevant_live_locals.contains(&local) {
230234
let local_ty = self.cx.body.local_decls[local].ty;
231235
if local_ty.has_free_regions() {
236+
let location = match self
237+
.cx
238+
.typeck
239+
.borrowck_context
240+
.location_table
241+
.to_location(location_index)
242+
{
243+
RichLocation::Start(l) => l,
244+
RichLocation::Mid(l) => l,
245+
};
232246
self.cx.add_drop_live_facts_for(local, local_ty, &[location], &locations);
233247
}
234248
}
235249
}
250+
Some(())
236251
}
237252

238253
/// Clear the value of fields that are "per local variable".

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,7 @@ pub(crate) fn type_check<'mir, 'tcx>(
188188
checker.equate_inputs_and_outputs(body, universal_regions, &normalized_inputs_and_output);
189189
checker.check_signature_annotation(body);
190190

191-
liveness::generate(
192-
&mut checker,
193-
body,
194-
elements,
195-
flow_inits,
196-
move_data,
197-
location_table,
198-
use_polonius,
199-
);
191+
liveness::generate(&mut checker, body, elements, flow_inits, move_data, use_polonius);
200192

201193
translate_outlives_facts(&mut checker);
202194
let opaque_type_values = infcx.take_opaque_types();

compiler/rustc_data_structures/src/graph/dominators/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ fn dominators_impl<G: ControlFlowGraph>(graph: &G) -> Inner<G::Node> {
9393
// These are all done here rather than through one of the 'standard'
9494
// graph traversals to help make this fast.
9595
'recurse: while let Some(frame) = stack.last_mut() {
96-
while let Some(successor) = frame.iter.next() {
96+
for successor in frame.iter.by_ref() {
9797
if real_to_pre_order[successor].is_none() {
9898
let pre_order_idx = pre_order_to_real.push(successor);
9999
real_to_pre_order[successor] = Some(pre_order_idx);

compiler/rustc_data_structures/src/graph/iterate/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ fn post_order_walk<G: DirectedGraph + Successors>(
4848
let node = frame.node;
4949
visited[node] = true;
5050

51-
while let Some(successor) = frame.iter.next() {
51+
for successor in frame.iter.by_ref() {
5252
if !visited[successor] {
5353
stack.push(PostOrderFrame { node: successor, iter: graph.successors(successor) });
5454
continue 'recurse;
@@ -112,7 +112,7 @@ where
112112
/// This is equivalent to just invoke `next` repeatedly until
113113
/// you get a `None` result.
114114
pub fn complete_search(&mut self) {
115-
while let Some(_) = self.next() {}
115+
for _ in self.by_ref() {}
116116
}
117117

118118
/// Returns true if node has been visited thus far.

compiler/rustc_data_structures/src/graph/scc/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub struct SccData<S: Idx> {
4040
}
4141

4242
impl<N: Idx, S: Idx + Ord> Sccs<N, S> {
43-
pub fn new(graph: &(impl DirectedGraph<Node = N> + Successors)) -> Self {
43+
pub fn new(graph: &impl Successors<Node = N>) -> Self {
4444
SccsConstruction::construct(graph)
4545
}
4646

compiler/rustc_data_structures/src/profiling.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ impl SelfProfiler {
562562
// ASLR is disabled and the heap is otherwise deterministic.
563563
let pid: u32 = process::id();
564564
let filename = format!("{crate_name}-{pid:07}.rustc_profile");
565-
let path = output_directory.join(&filename);
565+
let path = output_directory.join(filename);
566566
let profiler =
567567
Profiler::with_counter(&path, measureme::counters::Counter::by_name(counter_name)?)?;
568568

compiler/rustc_data_structures/src/sorted_map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,13 @@ impl<K: Ord, V> SortedMap<K, V> {
125125

126126
/// Iterate over the keys, sorted
127127
#[inline]
128-
pub fn keys(&self) -> impl Iterator<Item = &K> + ExactSizeIterator + DoubleEndedIterator {
128+
pub fn keys(&self) -> impl ExactSizeIterator<Item = &K> + DoubleEndedIterator {
129129
self.data.iter().map(|(k, _)| k)
130130
}
131131

132132
/// Iterate over values, sorted by key
133133
#[inline]
134-
pub fn values(&self) -> impl Iterator<Item = &V> + ExactSizeIterator + DoubleEndedIterator {
134+
pub fn values(&self) -> impl ExactSizeIterator<Item = &V> + DoubleEndedIterator {
135135
self.data.iter().map(|(_, v)| v)
136136
}
137137

compiler/rustc_data_structures/src/sync/lock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ mod maybe_sync {
6969
match self.mode {
7070
Mode::NoSync => {
7171
let cell = unsafe { &self.lock.mode_union.no_sync };
72-
debug_assert_eq!(cell.get(), true);
72+
debug_assert!(cell.get());
7373
cell.set(false);
7474
}
7575
// SAFETY (unlock): We know that the lock is locked as this type is a proof of that.

0 commit comments

Comments
 (0)