Rollup merge of #120530 - trevyn:issue-116434, r=compiler-errors

Be less confident when `dyn` suggestion is not checked for object safety

#120275 no longer checks bare traits for object safety when making a `dyn` suggestion on Rust < 2021. In this case, qualify the suggestion with a note that the trait must be object safe, to prevent user confusion as seen in #116434

r? ```@fmease```
This commit is contained in:
Oli Scherer 2024-02-14 11:53:39 +01:00 committed by GitHub
commit c4371a79de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 189 additions and 42 deletions

View file

@ -243,7 +243,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
tcx.node_span_lint(BARE_TRAIT_OBJECTS, self_ty.hir_id, self_ty.span, msg, |lint| {
if self_ty.span.can_be_used_for_suggestions() {
lint.multipart_suggestion_verbose(
"use `dyn`",
"if this is an object-safe trait, use `dyn`",
sugg,
Applicability::MachineApplicable,
);