Skip to content

Commit

Permalink
catch pinned must_use types in unused_must_use
Browse files Browse the repository at this point in the history
  • Loading branch information
max-niederman committed Nov 19, 2023
1 parent ea6b131 commit 173b950
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions compiler/rustc_lint/src/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
/// The root of the normal must_use lint with an optional message.
Def(Span, DefId, Option<Symbol>),
Boxed(Box<Self>),
Pinned(Box<Self>),
Opaque(Box<Self>),
TraitObject(Box<Self>),
TupleElement(Vec<(usize, Self)>),
Expand Down Expand Up @@ -284,6 +285,11 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
is_ty_must_use(cx, boxed_ty, expr, span)
.map(|inner| MustUsePath::Boxed(Box::new(inner)))
}
ty::Adt(def, args) if cx.tcx.lang_items().pin_type() == Some(def.did()) => {
let pinned_ty = args.type_at(0);
is_ty_must_use(cx, pinned_ty, expr, span)
.map(|inner| MustUsePath::Pinned(Box::new(inner)))
}
ty::Adt(def, _) => is_def_must_use(cx, def.did(), span),
ty::Alias(ty::Opaque, ty::AliasTy { def_id: def, .. }) => {
elaborate(
Expand Down Expand Up @@ -425,6 +431,18 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
expr_is_from_block,
);
}
MustUsePath::Pinned(path) => {
let descr_pre = &format!("{descr_pre}pinned ");
emit_must_use_untranslated(
cx,
path,
descr_pre,
descr_post,
plural_len,
true,
expr_is_from_block,
);
}
MustUsePath::Opaque(path) => {
let descr_pre = &format!("{descr_pre}implementer{plural_suffix} of ");
emit_must_use_untranslated(
Expand Down

0 comments on commit 173b950

Please sign in to comment.