Move #[do_not_recommend] to the #[diagnostic] namespace

This commit moves the `#[do_not_recommend]` attribute to the
`#[diagnostic]` namespace. It still requires
`#![feature(do_not_recommend)]` to work.
This commit is contained in:
Georg Semmler 2024-05-10 14:12:30 +02:00
parent e8ada6ab25
commit 2cff3e90bc
No known key found for this signature in database
GPG key ID: A87BCEE5205CE489
22 changed files with 228 additions and 209 deletions

View file

@ -380,7 +380,10 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
source: CandidateSource::Impl(impl_def_id),
result: _,
} = candidate.kind()
&& goal.infcx().tcx.has_attr(impl_def_id, sym::do_not_recommend)
&& goal
.infcx()
.tcx
.has_attrs_with_path(impl_def_id, &[sym::diagnostic, sym::do_not_recommend])
{
return ControlFlow::Break(self.obligation.clone());
}

View file

@ -1012,7 +1012,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
let mut base_cause = obligation.cause.code().clone();
loop {
if let ObligationCauseCode::ImplDerived(ref c) = base_cause {
if self.tcx.has_attr(c.impl_or_alias_def_id, sym::do_not_recommend) {
if self.tcx.has_attrs_with_path(
c.impl_or_alias_def_id,
&[sym::diagnostic, sym::do_not_recommend],
) {
let code = (*c.derived.parent_code).clone();
obligation.cause.map_code(|_| code);
obligation.predicate = c.derived.parent_trait_pred.upcast(self.tcx);