1
Fork 0

Rollup merge of #124218 - Xiretza:subsubdiagnostics, r=davidtwco

Allow nesting subdiagnostics in #[derive(Subdiagnostic)]
This commit is contained in:
León Orell Valerian Liehr 2024-04-23 17:25:17 +02:00 committed by GitHub
commit 6e423e1651
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 145 additions and 114 deletions

View file

@ -1,4 +1,4 @@
use rustc_errors::{codes::*, Applicability, MultiSpan};
use rustc_errors::{codes::*, Applicability, ElidedLifetimeInPathSubdiag, MultiSpan};
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_span::{
symbol::{Ident, Symbol},
@ -907,6 +907,8 @@ pub(crate) struct ExplicitAnonymousLivetimeReportError {
pub(crate) struct ImplicitElidedLifetimeNotAllowedHere {
#[primary_span]
pub(crate) span: Span,
#[subdiagnostic]
pub(crate) subdiag: ElidedLifetimeInPathSubdiag,
}
#[derive(Diagnostic)]

View file

@ -1883,20 +1883,18 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
// async fn foo(_: std::cell::Ref<u32>) { ... }
LifetimeRibKind::AnonymousCreateParameter { report_in_path: true, .. }
| LifetimeRibKind::AnonymousWarn(_) => {
let mut err =
self.r.dcx().create_err(errors::ImplicitElidedLifetimeNotAllowedHere {
span: path_span,
});
let sess = self.r.tcx.sess;
rustc_errors::add_elided_lifetime_in_path_suggestion(
let subdiag = rustc_errors::elided_lifetime_in_path_suggestion(
sess.source_map(),
&mut err,
expected_lifetimes,
path_span,
!segment.has_generic_args,
elided_lifetime_span,
);
err.emit();
self.r.dcx().emit_err(errors::ImplicitElidedLifetimeNotAllowedHere {
span: path_span,
subdiag,
});
should_lint = false;
for id in node_ids {