about summary refs log tree commit diff
path: root/compiler/rustc_passes/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-01-30 10:50:16 +0000
committerbors <bors@rust-lang.org>2021-01-30 10:50:16 +0000
commit7ce1b3b24491cbe10669cbe2b5733c2fe7cfe5b7 (patch)
treeb4bc76e37d133d24df1e8a93a0a2a0fa4aa74e7a /compiler/rustc_passes/src
parentebaea9e850648dfeaeec353fd66c155c80de5ded (diff)
parent31e7634749a737be8118ec8fe92c2dfcd2d10046 (diff)
downloadrust-7ce1b3b24491cbe10669cbe2b5733c2fe7cfe5b7.tar.gz
rust-7ce1b3b24491cbe10669cbe2b5733c2fe7cfe5b7.zip
Auto merge of #81545 - JohnTitor:rollup-zlt3tn6, r=JohnTitor
Rollup of 16 pull requests

Successful merges:

 - #79023 (Add `core::stream::Stream`)
 - #80562 (Consider Scalar to be a bool only if its unsigned)
 - #80886 (Stabilize raw ref macros)
 - #80959 (Stabilize `unsigned_abs`)
 - #81291 (Support FRU pattern with `[feature(capture_disjoint_fields)]`)
 - #81409 (Slight simplification of chars().count())
 - #81468 (cfg(version): treat nightlies as complete)
 - #81473 (Warn write-only fields)
 - #81495 (rustdoc: Remove unnecessary optional)
 - #81499 (Updated Vec::splice documentation)
 - #81501 (update rustfmt to v1.4.34)
 - #81505 (`fn cold_path` doesn't need to be pub)
 - #81512 (Add missing variants in match binding)
 - #81515 (Fix typo in pat.rs)
 - #81519 (Don't print error output from rustup when detecting default build triple)
 - #81520 (Don't clone LLVM submodule when download-ci-llvm is set)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_passes/src')
-rw-r--r--compiler/rustc_passes/src/dead.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs
index 3b1b53553d5..0d096a0556b 100644
--- a/compiler/rustc_passes/src/dead.rs
+++ b/compiler/rustc_passes/src/dead.rs
@@ -37,6 +37,15 @@ fn should_explore(tcx: TyCtxt<'_>, hir_id: hir::HirId) -> bool {
     )
 }
 
+fn base_expr<'a>(mut expr: &'a hir::Expr<'a>) -> &'a hir::Expr<'a> {
+    loop {
+        match expr.kind {
+            hir::ExprKind::Field(base, ..) => expr = base,
+            _ => return expr,
+        }
+    }
+}
+
 struct MarkSymbolVisitor<'tcx> {
     worklist: Vec<hir::HirId>,
     tcx: TyCtxt<'tcx>,
@@ -263,6 +272,12 @@ impl<'tcx> Visitor<'tcx> for MarkSymbolVisitor<'tcx> {
             hir::ExprKind::MethodCall(..) => {
                 self.lookup_and_handle_method(expr.hir_id);
             }
+            hir::ExprKind::Assign(ref left, ref right, ..) => {
+                // Ignore write to field
+                self.visit_expr(base_expr(left));
+                self.visit_expr(right);
+                return;
+            }
             hir::ExprKind::Field(ref lhs, ..) => {
                 self.handle_field_access(&lhs, expr.hir_id);
             }