Delay formatting trimmed path until lint/error is emitted
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
use std::fmt::Display;
|
||||
|
||||
use rustc_errors::IntoDiagnosticArg;
|
||||
use rustc_macros::{LintDiagnostic, SessionDiagnostic, SessionSubdiagnostic};
|
||||
use rustc_span::{Span, Symbol};
|
||||
|
||||
@@ -35,7 +38,7 @@ pub struct ItemIsPrivate<'a> {
|
||||
#[label]
|
||||
pub span: Span,
|
||||
pub kind: &'a str,
|
||||
pub descr: String,
|
||||
pub descr: FromDisplay<'a>,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
@@ -55,7 +58,7 @@ pub struct InPublicInterfaceTraits<'a> {
|
||||
pub span: Span,
|
||||
pub vis_descr: &'static str,
|
||||
pub kind: &'a str,
|
||||
pub descr: String,
|
||||
pub descr: FromDisplay<'a>,
|
||||
#[label(privacy::visibility_label)]
|
||||
pub vis_span: Span,
|
||||
}
|
||||
@@ -69,7 +72,7 @@ pub struct InPublicInterface<'a> {
|
||||
pub span: Span,
|
||||
pub vis_descr: &'static str,
|
||||
pub kind: &'a str,
|
||||
pub descr: String,
|
||||
pub descr: FromDisplay<'a>,
|
||||
#[label(privacy::visibility_label)]
|
||||
pub vis_span: Span,
|
||||
}
|
||||
@@ -78,7 +81,7 @@ pub struct InPublicInterface<'a> {
|
||||
#[lint(privacy::from_private_dep_in_public_interface)]
|
||||
pub struct FromPrivateDependencyInPublicInterface<'a> {
|
||||
pub kind: &'a str,
|
||||
pub descr: String,
|
||||
pub descr: FromDisplay<'a>,
|
||||
pub krate: Symbol,
|
||||
}
|
||||
|
||||
@@ -87,5 +90,13 @@ pub struct FromPrivateDependencyInPublicInterface<'a> {
|
||||
pub struct PrivateInPublicLint<'a> {
|
||||
pub vis_descr: &'static str,
|
||||
pub kind: &'a str,
|
||||
pub descr: String,
|
||||
pub descr: FromDisplay<'a>,
|
||||
}
|
||||
|
||||
pub struct FromDisplay<'a>(pub &'a dyn Display);
|
||||
|
||||
impl IntoDiagnosticArg for FromDisplay<'_> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
|
||||
self.0.to_string().into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user