+use crate::lints::{DropGlue, DropTraitConstraintsDiag};
use crate::LateContext;
use crate::LateLintPass;
use crate::LintContext;
-use rustc_errors::fluent;
use rustc_hir as hir;
use rustc_span::symbol::sym;
if trait_predicate.trait_ref.self_ty().is_impl_trait() {
continue;
}
- let Some(needs_drop) = cx.tcx.get_diagnostic_item(sym::needs_drop) else {
- continue;
+ let Some(def_id) = cx.tcx.get_diagnostic_item(sym::needs_drop) else {
+ return
};
- cx.struct_span_lint(
+ cx.emit_spanned_lint(
DROP_BOUNDS,
span,
- fluent::lint_drop_trait_constraints,
- |lint| {
- lint.set_arg("predicate", predicate)
- .set_arg("needs_drop", cx.tcx.def_path_str(needs_drop))
- },
+ DropTraitConstraintsDiag { predicate, tcx: cx.tcx, def_id },
);
}
}
};
for bound in &bounds[..] {
let def_id = bound.trait_ref.trait_def_id();
- if cx.tcx.lang_items().drop_trait() == def_id
- && let Some(needs_drop) = cx.tcx.get_diagnostic_item(sym::needs_drop)
- {
- cx.struct_span_lint(DYN_DROP, bound.span, fluent::lint_drop_glue, |lint| {
- lint.set_arg("needs_drop", cx.tcx.def_path_str(needs_drop))
- });
+ if cx.tcx.lang_items().drop_trait() == def_id {
+ let Some(def_id) = cx.tcx.get_diagnostic_item(sym::needs_drop) else {
+ return
+ };
+ cx.emit_spanned_lint(DYN_DROP, bound.span, DropGlue { tcx: cx.tcx, def_id });
}
}
}