Auto merge of #120242 - matthiaskrgr:rollup-a93yj3i, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - #117910 (Refactor uses of `objc_msgSend` to no longer have clashing definitions) - #118639 (Undeprecate lint `unstable_features` and make use of it in the compiler) - #119801 (Fix deallocation with wrong allocator in (A)Rc::from_box_in) - #120058 (bootstrap: improvements for compiler builds) - #120059 (Make generic const type mismatches not hide trait impls from the trait solver) - #120097 (Report unreachable subpatterns consistently) - #120137 (Validate AggregateKind types in MIR) - #120164 (`maybe_lint_impl_trait`: separate `is_downgradable` from `is_object_safe`) - #120181 (Allow any `const` expression blocks in `thread_local!`) - #120218 (rustfmt: Check that a token can begin a nonterminal kind before parsing it as a macro arg) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
d5fd099729
31 changed files with 557 additions and 227 deletions
|
@ -94,15 +94,17 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
return false;
|
||||
};
|
||||
let impl_sugg = vec![(self_ty.span.shrink_to_lo(), "impl ".to_string())];
|
||||
let mut is_downgradable = true;
|
||||
let is_object_safe = match self_ty.kind {
|
||||
hir::TyKind::TraitObject(objects, ..) => {
|
||||
objects.iter().all(|o| match o.trait_ref.path.res {
|
||||
Res::Def(DefKind::Trait, id) if Some(id) == owner => {
|
||||
// When we're dealing with a recursive trait, we don't want to downgrade
|
||||
// the error, so we consider them to be object safe always. (#119652)
|
||||
true
|
||||
Res::Def(DefKind::Trait, id) => {
|
||||
if Some(id) == owner {
|
||||
// For recursive traits, don't downgrade the error. (#119652)
|
||||
is_downgradable = false;
|
||||
}
|
||||
tcx.check_is_object_safe(id)
|
||||
}
|
||||
Res::Def(DefKind::Trait, id) => tcx.check_is_object_safe(id),
|
||||
_ => false,
|
||||
})
|
||||
}
|
||||
|
@ -130,7 +132,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
],
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
} else if diag.is_error() {
|
||||
} else if diag.is_error() && is_downgradable {
|
||||
// We'll emit the object safety error already, with a structured suggestion.
|
||||
diag.downgrade_to_delayed_bug();
|
||||
}
|
||||
|
@ -156,7 +158,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
}
|
||||
if !is_object_safe {
|
||||
diag.note(format!("`{trait_name}` it is not object safe, so it can't be `dyn`"));
|
||||
if diag.is_error() {
|
||||
if diag.is_error() && is_downgradable {
|
||||
// We'll emit the object safety error already, with a structured suggestion.
|
||||
diag.downgrade_to_delayed_bug();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue