Skip to content

Commit 173b950

Browse files
committed
catch pinned must_use types in unused_must_use
1 parent ea6b131 commit 173b950

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

compiler/rustc_lint/src/unused.rs

+18
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
251251
/// The root of the normal must_use lint with an optional message.
252252
Def(Span, DefId, Option<Symbol>),
253253
Boxed(Box<Self>),
254+
Pinned(Box<Self>),
254255
Opaque(Box<Self>),
255256
TraitObject(Box<Self>),
256257
TupleElement(Vec<(usize, Self)>),
@@ -284,6 +285,11 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
284285
is_ty_must_use(cx, boxed_ty, expr, span)
285286
.map(|inner| MustUsePath::Boxed(Box::new(inner)))
286287
}
288+
ty::Adt(def, args) if cx.tcx.lang_items().pin_type() == Some(def.did()) => {
289+
let pinned_ty = args.type_at(0);
290+
is_ty_must_use(cx, pinned_ty, expr, span)
291+
.map(|inner| MustUsePath::Pinned(Box::new(inner)))
292+
}
287293
ty::Adt(def, _) => is_def_must_use(cx, def.did(), span),
288294
ty::Alias(ty::Opaque, ty::AliasTy { def_id: def, .. }) => {
289295
elaborate(
@@ -425,6 +431,18 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
425431
expr_is_from_block,
426432
);
427433
}
434+
MustUsePath::Pinned(path) => {
435+
let descr_pre = &format!("{descr_pre}pinned ");
436+
emit_must_use_untranslated(
437+
cx,
438+
path,
439+
descr_pre,
440+
descr_post,
441+
plural_len,
442+
true,
443+
expr_is_from_block,
444+
);
445+
}
428446
MustUsePath::Opaque(path) => {
429447
let descr_pre = &format!("{descr_pre}implementer{plural_suffix} of ");
430448
emit_must_use_untranslated(

0 commit comments

Comments
 (0)