about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan MacKenzie <ecstaticmorse@gmail.com>2019-10-13 12:27:11 -0700
committerDylan MacKenzie <ecstaticmorse@gmail.com>2019-10-13 14:39:57 -0700
commit061b906683eccd01b59f848a7941f3fd7aff8b00 (patch)
tree88bda9b49112f317aad25530627ad28427941fd9
parentc27f7568bc74c418996892028a629eed5a7f5f00 (diff)
downloadrust-061b906683eccd01b59f848a7941f3fd7aff8b00.tar.gz
rust-061b906683eccd01b59f848a7941f3fd7aff8b00.zip
Return `false` from `needs_drop` for all zero-sized arrays
-rw-r--r--src/librustc/ty/util.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs
index 5ddf15317a3..b6e8b8b92e6 100644
--- a/src/librustc/ty/util.rs
+++ b/src/librustc/ty/util.rs
@@ -1096,6 +1096,9 @@ fn needs_drop_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>
 
         ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"),
 
+        // Zero-length arrays never contain anything to drop.
+        ty::Array(_, len) if len.try_eval_usize(tcx, param_env) == Some(0) => false,
+
         // Structural recursion.
         ty::Array(ty, _) | ty::Slice(ty) => needs_drop(ty),