about summary refs log tree commit diff
diff options
context:
space:
mode:
authormatthewjasper <20113453+matthewjasper@users.noreply.github.com>2020-02-09 10:16:57 +0000
committerMatthew Jasper <mjjasper1@gmail.com>2020-02-09 10:49:39 +0000
commit3eb524188451fcec6cd5ed7e3cba2404021b75eb (patch)
tree2247e8c2f89556b40922e67f657489bde6ae9c7d
parent465b86253ce828e215d564fde53adf8742f0e3f6 (diff)
downloadrust-3eb524188451fcec6cd5ed7e3cba2404021b75eb.tar.gz
rust-3eb524188451fcec6cd5ed7e3cba2404021b75eb.zip
Apply suggestions from code review
Co-Authored-By: varkor <github@varkor.com>
-rw-r--r--src/librustc/ty/mod.rs2
-rw-r--r--src/librustc/ty/util.rs4
-rw-r--r--src/librustc_ty/needs_drop.rs13
3 files changed, 10 insertions, 9 deletions
diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs
index 2b272d7fe08..85b9cbf3de1 100644
--- a/src/librustc/ty/mod.rs
+++ b/src/librustc/ty/mod.rs
@@ -2286,7 +2286,7 @@ impl<'tcx> AdtDef {
         self.flags.contains(AdtFlags::IS_BOX)
     }
 
-    /// Returns `true` if this is ManuallyDrop<T>.
+    /// Returns `true` if this is `ManuallyDrop<T>`.
     #[inline]
     pub fn is_manually_drop(&self) -> bool {
         self.flags.contains(AdtFlags::IS_MANUALLY_DROP)
diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs
index 6191d304719..4011c010c03 100644
--- a/src/librustc/ty/util.rs
+++ b/src/librustc/ty/util.rs
@@ -1013,12 +1013,12 @@ pub fn needs_drop_components(
         | ty::Ref(..)
         | ty::Str => Ok(SmallVec::new()),
 
-        // Foreign types can never have destructors
+        // Foreign types can never have destructors.
         ty::Foreign(..) => Ok(SmallVec::new()),
 
         // Pessimistically assume that all generators will require destructors
         // as we don't know if a destructor is a noop or not until after the MIR
-        // state transformation pass
+        // state transformation pass.
         ty::Generator(..) | ty::Dynamic(..) | ty::Error => Err(AlwaysRequiresDrop),
 
         ty::Slice(ty) => needs_drop_components(ty, target_layout),
diff --git a/src/librustc_ty/needs_drop.rs b/src/librustc_ty/needs_drop.rs
index c01b3e384ae..0f71246c737 100644
--- a/src/librustc_ty/needs_drop.rs
+++ b/src/librustc_ty/needs_drop.rs
@@ -12,9 +12,9 @@ type NeedsDropResult<T> = Result<T, AlwaysRequiresDrop>;
 fn needs_drop_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
     let adt_fields =
         move |adt_def: &ty::AdtDef| tcx.adt_drop_tys(adt_def.did).map(|tys| tys.iter().copied());
-    // If we don't know a type doesn't need drop, say it's a type parameter
-    // without a `Copy` bound, then we conservatively return that it needs
-    // drop.
+    // If we don't know a type doesn't need drop, for example if it's a type
+    // parameter without a `Copy` bound, then we conservatively return that it
+    // needs drop.
     let res = NeedsDropTypes::new(tcx, query.param_env, query.value, adt_fields).next().is_some();
     debug!("needs_drop_raw({:?}) = {:?}", query, res);
     res
@@ -25,9 +25,10 @@ struct NeedsDropTypes<'tcx, F> {
     param_env: ty::ParamEnv<'tcx>,
     query_ty: Ty<'tcx>,
     seen_tys: FxHashSet<Ty<'tcx>>,
-    /// A stack of types left to process. Each round, we pop something from the
-    /// stack and check if it needs drop. If the result depends on whether some
-    /// other types need drop we push them onto the stack.
+    /// A stack of types left to process, and the recursion depth when we
+    /// pushed that type. Each round, we pop something from the stack and check
+    /// if it needs drop. If the result depends on whether some other types
+    /// need drop we push them onto the stack.
     unchecked_tys: Vec<(Ty<'tcx>, usize)>,
     recursion_limit: usize,
     adt_components: F,