Do not construct def_path_str for MustNotSuspend.
This commit is contained in:
parent
3050938abd
commit
9450b75986
2 changed files with 29 additions and 8 deletions
|
@ -4,7 +4,9 @@ use rustc_errors::{
|
||||||
};
|
};
|
||||||
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
||||||
use rustc_middle::mir::{AssertKind, UnsafetyViolationDetails};
|
use rustc_middle::mir::{AssertKind, UnsafetyViolationDetails};
|
||||||
|
use rustc_middle::ty::TyCtxt;
|
||||||
use rustc_session::lint::{self, Lint};
|
use rustc_session::lint::{self, Lint};
|
||||||
|
use rustc_span::def_id::DefId;
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
|
@ -237,20 +239,38 @@ pub(crate) struct FnItemRef {
|
||||||
pub ident: String,
|
pub ident: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
pub(crate) struct MustNotSupend<'tcx, 'a> {
|
||||||
#[diag(mir_transform_must_not_suspend)]
|
pub tcx: TyCtxt<'tcx>,
|
||||||
pub(crate) struct MustNotSupend<'a> {
|
|
||||||
#[label]
|
|
||||||
pub yield_sp: Span,
|
pub yield_sp: Span,
|
||||||
#[subdiagnostic]
|
|
||||||
pub reason: Option<MustNotSuspendReason>,
|
pub reason: Option<MustNotSuspendReason>,
|
||||||
#[help]
|
|
||||||
pub src_sp: Span,
|
pub src_sp: Span,
|
||||||
pub pre: &'a str,
|
pub pre: &'a str,
|
||||||
pub def_path: String,
|
pub def_id: DefId,
|
||||||
pub post: &'a str,
|
pub post: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Needed for def_path_str
|
||||||
|
impl<'a> DecorateLint<'a, ()> for MustNotSupend<'_, '_> {
|
||||||
|
fn decorate_lint<'b>(
|
||||||
|
self,
|
||||||
|
diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>,
|
||||||
|
) -> &'b mut rustc_errors::DiagnosticBuilder<'a, ()> {
|
||||||
|
diag.span_label(self.yield_sp, crate::fluent_generated::_subdiag::label);
|
||||||
|
if let Some(reason) = self.reason {
|
||||||
|
diag.subdiagnostic(reason);
|
||||||
|
}
|
||||||
|
diag.span_help(self.src_sp, crate::fluent_generated::_subdiag::help);
|
||||||
|
diag.set_arg("pre", self.pre);
|
||||||
|
diag.set_arg("def_path", self.tcx.def_path_str(self.def_id));
|
||||||
|
diag.set_arg("post", self.post);
|
||||||
|
diag
|
||||||
|
}
|
||||||
|
|
||||||
|
fn msg(&self) -> rustc_errors::DiagnosticMessage {
|
||||||
|
crate::fluent_generated::mir_transform_must_not_suspend
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Subdiagnostic)]
|
#[derive(Subdiagnostic)]
|
||||||
#[note(mir_transform_note)]
|
#[note(mir_transform_note)]
|
||||||
pub(crate) struct MustNotSuspendReason {
|
pub(crate) struct MustNotSuspendReason {
|
||||||
|
|
|
@ -1954,11 +1954,12 @@ fn check_must_not_suspend_def(
|
||||||
hir_id,
|
hir_id,
|
||||||
data.source_span,
|
data.source_span,
|
||||||
errors::MustNotSupend {
|
errors::MustNotSupend {
|
||||||
|
tcx,
|
||||||
yield_sp: data.yield_span,
|
yield_sp: data.yield_span,
|
||||||
reason,
|
reason,
|
||||||
src_sp: data.source_span,
|
src_sp: data.source_span,
|
||||||
pre: data.descr_pre,
|
pre: data.descr_pre,
|
||||||
def_path: tcx.def_path_str(def_id),
|
def_id,
|
||||||
post: data.descr_post,
|
post: data.descr_post,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue