Skip to content

Commit 0558246

Browse files
committed
Address review comments
1 parent 1455d73 commit 0558246

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/librustc_lint/unused.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
244244
}
245245
ty::Array(ty, mut len) => {
246246
// Try to evaluate the length if it's unevaluated.
247+
// FIXME(59369): we should be able to remove this once we merge
248+
// https://github.com/rust-lang/rust/pull/59369.
247249
if let ConstValue::Unevaluated(def_id, substs) = len.val {
248250
let instance = ty::Instance::resolve(
249251
cx.tcx.global_tcx(),
@@ -261,17 +263,16 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
261263
}
262264

263265
match len.assert_usize(cx.tcx) {
264-
// If the array is definitely non-empty, we can do `#[must_use]` checking.
265-
Some(n) if n != 0 => {
266+
Some(0) => false, // Empty arrays won't contain any `#[must_use]` types.
267+
// If the array may be non-empty, we do `#[must_use]` checking.
268+
_ => {
266269
let descr_pre = &format!(
267270
"{}array{} of ",
268271
descr_pre,
269272
plural_suffix,
270273
);
271274
check_must_use_ty(cx, ty, expr, span, descr_pre, descr_post, true)
272275
}
273-
// Otherwise, we don't lint, to avoid false positives.
274-
_ => false,
275276
}
276277
}
277278
_ => false,

src/libstd/panicking.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,7 @@ pub fn set_hook(hook: Box<dyn Fn(&PanicInfo<'_>) + 'static + Sync + Send>) {
103103
HOOK_LOCK.write_unlock();
104104

105105
if let Hook::Custom(ptr) = old_hook {
106-
#[allow(unused_must_use)] {
107-
Box::from_raw(ptr);
108-
}
106+
mem::drop(Box::from_raw(ptr));
109107
}
110108
}
111109
}

0 commit comments

Comments
 (0)