about summary refs log tree commit diff
path: root/compiler/rustc_mir_dataflow
diff options
context:
space:
mode:
authorFolkert de Vries <flokkievids@gmail.com>2025-08-03 10:44:41 +0000
committerGitHub <noreply@github.com>2025-08-03 10:44:41 +0000
commitc691374cc19d583103f3da5d655efb308a1648b9 (patch)
tree767496caef5b54e56f46a834d0d612705ce5e488 /compiler/rustc_mir_dataflow
parentdaa742afe5970109c1e15b391226f78087b10439 (diff)
parent49aa0ecc7b251003e61c38a56471195a2d3dabee (diff)
downloadrust-c691374cc19d583103f3da5d655efb308a1648b9.tar.gz
rust-c691374cc19d583103f3da5d655efb308a1648b9.zip
Merge pull request #1889 from rust-lang/rustc-pull
Rustc pull update
Diffstat (limited to 'compiler/rustc_mir_dataflow')
-rw-r--r--compiler/rustc_mir_dataflow/src/drop_flag_effects.rs5
-rw-r--r--compiler/rustc_mir_dataflow/src/impls/initialized.rs13
-rw-r--r--compiler/rustc_mir_dataflow/src/rustc_peek.rs48
-rw-r--r--compiler/rustc_mir_dataflow/src/value_analysis.rs8
4 files changed, 34 insertions, 40 deletions
diff --git a/compiler/rustc_mir_dataflow/src/drop_flag_effects.rs b/compiler/rustc_mir_dataflow/src/drop_flag_effects.rs
index c9c7fddae5a..1402a1a8b91 100644
--- a/compiler/rustc_mir_dataflow/src/drop_flag_effects.rs
+++ b/compiler/rustc_mir_dataflow/src/drop_flag_effects.rs
@@ -124,10 +124,9 @@ pub fn drop_flag_effects_for_location<'tcx, F>(
     // Drop does not count as a move but we should still consider the variable uninitialized.
     if let Some(Terminator { kind: TerminatorKind::Drop { place, .. }, .. }) =
         body.stmt_at(loc).right()
+        && let LookupResult::Exact(mpi) = move_data.rev_lookup.find(place.as_ref())
     {
-        if let LookupResult::Exact(mpi) = move_data.rev_lookup.find(place.as_ref()) {
-            on_all_children_bits(move_data, mpi, |mpi| callback(mpi, DropFlagState::Absent))
-        }
+        on_all_children_bits(move_data, mpi, |mpi| callback(mpi, DropFlagState::Absent))
     }
 
     debug!("drop_flag_effects: assignment for location({:?})", loc);
diff --git a/compiler/rustc_mir_dataflow/src/impls/initialized.rs b/compiler/rustc_mir_dataflow/src/impls/initialized.rs
index 085757f0fb6..117525eb777 100644
--- a/compiler/rustc_mir_dataflow/src/impls/initialized.rs
+++ b/compiler/rustc_mir_dataflow/src/impls/initialized.rs
@@ -637,16 +637,13 @@ impl<'tcx> Analysis<'tcx> for EverInitializedPlaces<'_, 'tcx> {
         debug!("initializes move_indexes {:?}", init_loc_map[location]);
         state.gen_all(init_loc_map[location].iter().copied());
 
-        if let mir::StatementKind::StorageDead(local) = stmt.kind {
+        if let mir::StatementKind::StorageDead(local) = stmt.kind
             // End inits for StorageDead, so that an immutable variable can
             // be reinitialized on the next iteration of the loop.
-            if let Some(move_path_index) = rev_lookup.find_local(local) {
-                debug!(
-                    "clears the ever initialized status of {:?}",
-                    init_path_map[move_path_index]
-                );
-                state.kill_all(init_path_map[move_path_index].iter().copied());
-            }
+            && let Some(move_path_index) = rev_lookup.find_local(local)
+        {
+            debug!("clears the ever initialized status of {:?}", init_path_map[move_path_index]);
+            state.kill_all(init_path_map[move_path_index].iter().copied());
         }
     }
 
diff --git a/compiler/rustc_mir_dataflow/src/rustc_peek.rs b/compiler/rustc_mir_dataflow/src/rustc_peek.rs
index 303fc767b9a..1682f332857 100644
--- a/compiler/rustc_mir_dataflow/src/rustc_peek.rs
+++ b/compiler/rustc_mir_dataflow/src/rustc_peek.rs
@@ -135,12 +135,11 @@ fn value_assigned_to_local<'a, 'tcx>(
     stmt: &'a mir::Statement<'tcx>,
     local: Local,
 ) -> Option<&'a mir::Rvalue<'tcx>> {
-    if let mir::StatementKind::Assign(box (place, rvalue)) = &stmt.kind {
-        if let Some(l) = place.as_local() {
-            if local == l {
-                return Some(&*rvalue);
-            }
-        }
+    if let mir::StatementKind::Assign(box (place, rvalue)) = &stmt.kind
+        && let Some(l) = place.as_local()
+        && local == l
+    {
+        return Some(&*rvalue);
     }
 
     None
@@ -178,31 +177,30 @@ impl PeekCall {
         let span = terminator.source_info.span;
         if let mir::TerminatorKind::Call { func: Operand::Constant(func), args, .. } =
             &terminator.kind
+            && let ty::FnDef(def_id, fn_args) = *func.const_.ty().kind()
         {
-            if let ty::FnDef(def_id, fn_args) = *func.const_.ty().kind() {
-                if tcx.intrinsic(def_id)?.name != sym::rustc_peek {
-                    return None;
-                }
+            if tcx.intrinsic(def_id)?.name != sym::rustc_peek {
+                return None;
+            }
 
-                assert_eq!(fn_args.len(), 1);
-                let kind = PeekCallKind::from_arg_ty(fn_args.type_at(0));
-                let arg = match &args[0].node {
-                    Operand::Copy(place) | Operand::Move(place) => {
-                        if let Some(local) = place.as_local() {
-                            local
-                        } else {
-                            tcx.dcx().emit_err(PeekMustBeNotTemporary { span });
-                            return None;
-                        }
-                    }
-                    _ => {
+            assert_eq!(fn_args.len(), 1);
+            let kind = PeekCallKind::from_arg_ty(fn_args.type_at(0));
+            let arg = match &args[0].node {
+                Operand::Copy(place) | Operand::Move(place) => {
+                    if let Some(local) = place.as_local() {
+                        local
+                    } else {
                         tcx.dcx().emit_err(PeekMustBeNotTemporary { span });
                         return None;
                     }
-                };
+                }
+                _ => {
+                    tcx.dcx().emit_err(PeekMustBeNotTemporary { span });
+                    return None;
+                }
+            };
 
-                return Some(PeekCall { arg, kind, span });
-            }
+            return Some(PeekCall { arg, kind, span });
         }
 
         None
diff --git a/compiler/rustc_mir_dataflow/src/value_analysis.rs b/compiler/rustc_mir_dataflow/src/value_analysis.rs
index 83fd8ccba60..005e7973130 100644
--- a/compiler/rustc_mir_dataflow/src/value_analysis.rs
+++ b/compiler/rustc_mir_dataflow/src/value_analysis.rs
@@ -215,10 +215,10 @@ impl<V: Clone + HasBottom> State<V> {
         // If both places are tracked, we copy the value to the target.
         // If the target is tracked, but the source is not, we do nothing, as invalidation has
         // already been performed.
-        if let Some(target_value) = map.places[target].value_index {
-            if let Some(source_value) = map.places[source].value_index {
-                values.insert(target_value, values.get(source_value).clone());
-            }
+        if let Some(target_value) = map.places[target].value_index
+            && let Some(source_value) = map.places[source].value_index
+        {
+            values.insert(target_value, values.get(source_value).clone());
         }
         for target_child in map.children(target) {
             // Try to find corresponding child and recurse. Reasoning is similar as above.