Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
varkor committed Jul 22, 2019
1 parent 1455d73 commit 0558246
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 5 additions & 4 deletions src/librustc_lint/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
}
ty::Array(ty, mut len) => {
// Try to evaluate the length if it's unevaluated.
// FIXME(59369): we should be able to remove this once we merge
// https://github.com/rust-lang/rust/pull/59369.
if let ConstValue::Unevaluated(def_id, substs) = len.val {
let instance = ty::Instance::resolve(
cx.tcx.global_tcx(),
Expand All @@ -261,17 +263,16 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
}

match len.assert_usize(cx.tcx) {
// If the array is definitely non-empty, we can do `#[must_use]` checking.
Some(n) if n != 0 => {
Some(0) => false, // Empty arrays won't contain any `#[must_use]` types.
// If the array may be non-empty, we do `#[must_use]` checking.
_ => {
let descr_pre = &format!(
"{}array{} of ",
descr_pre,
plural_suffix,
);
check_must_use_ty(cx, ty, expr, span, descr_pre, descr_post, true)
}
// Otherwise, we don't lint, to avoid false positives.
_ => false,
}
}
_ => false,
Expand Down
4 changes: 1 addition & 3 deletions src/libstd/panicking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ pub fn set_hook(hook: Box<dyn Fn(&PanicInfo<'_>) + 'static + Sync + Send>) {
HOOK_LOCK.write_unlock();

if let Hook::Custom(ptr) = old_hook {
#[allow(unused_must_use)] {
Box::from_raw(ptr);
}
mem::drop(Box::from_raw(ptr));
}
}
}
Expand Down

0 comments on commit 0558246

Please sign in to comment.