Remove DelayDm

With the removal of `LintDiagnostic::msg` / the `msg` param from
lint diag APIs, primary messages for lint diags are always constructed
lazily inside decorator fns rendering this wrapper type unused / useless.
This commit is contained in:
León Orell Valerian Liehr 2024-05-23 03:50:43 +02:00
parent 06bc4fc671
commit 9f67c50128
No known key found for this signature in database
GPG Key ID: D17A07215F68E713
3 changed files with 4 additions and 15 deletions

View File

@ -367,17 +367,6 @@ fn from(s: Cow<'static, str>) -> Self {
} }
} }
/// A workaround for must_produce_diag ICEs when formatting types in disabled lints.
///
/// Delays formatting until `.into(): DiagMessage` is used.
pub struct DelayDm<F>(pub F);
impl<F: FnOnce() -> String> From<DelayDm<F>> for DiagMessage {
fn from(DelayDm(f): DelayDm<F>) -> Self {
DiagMessage::from(f())
}
}
/// Translating *into* a subdiagnostic message from a diagnostic message is a little strange - but /// Translating *into* a subdiagnostic message from a diagnostic message is a little strange - but
/// the subdiagnostic functions (e.g. `span_label`) take a `SubdiagMessage` and the /// the subdiagnostic functions (e.g. `span_label`) take a `SubdiagMessage` and the
/// subdiagnostic derive refers to typed identifiers that are `DiagMessage`s, so need to be /// subdiagnostic derive refers to typed identifiers that are `DiagMessage`s, so need to be

View File

@ -39,7 +39,7 @@
}; };
pub use emitter::ColorConfig; pub use emitter::ColorConfig;
pub use rustc_error_messages::{ pub use rustc_error_messages::{
fallback_fluent_bundle, fluent_bundle, DelayDm, DiagMessage, FluentBundle, LanguageIdentifier, fallback_fluent_bundle, fluent_bundle, DiagMessage, FluentBundle, LanguageIdentifier,
LazyFallbackBundle, MultiSpan, SpanLabel, SubdiagMessage, LazyFallbackBundle, MultiSpan, SpanLabel, SubdiagMessage,
}; };
pub use rustc_lint_defs::{pluralize, Applicability}; pub use rustc_lint_defs::{pluralize, Applicability};
@ -572,7 +572,7 @@ fn drop(&mut self) {
if let Some(backtrace) = &self.must_produce_diag { if let Some(backtrace) = &self.must_produce_diag {
panic!( panic!(
"must_produce_diag: `trimmed_def_paths` called but no diagnostics emitted; \ "must_produce_diag: `trimmed_def_paths` called but no diagnostics emitted; \
use `DelayDm` for lints or `with_no_trimmed_paths` for debugging. \ `with_no_trimmed_paths` for debugging. \
called at: {backtrace}" called at: {backtrace}"
); );
} }

View File

@ -3327,7 +3327,7 @@ fn for_each_def(tcx: TyCtxt<'_>, mut collect_fn: impl for<'b> FnMut(&'b Ident, N
/// ///
/// The implementation uses similar import discovery logic to that of 'use' suggestions. /// The implementation uses similar import discovery logic to that of 'use' suggestions.
/// ///
/// See also [`DelayDm`](rustc_error_messages::DelayDm) and [`with_no_trimmed_paths!`]. /// See also [`with_no_trimmed_paths!`].
// this is pub to be able to intra-doc-link it // this is pub to be able to intra-doc-link it
pub fn trimmed_def_paths(tcx: TyCtxt<'_>, (): ()) -> DefIdMap<Symbol> { pub fn trimmed_def_paths(tcx: TyCtxt<'_>, (): ()) -> DefIdMap<Symbol> {
// Trimming paths is expensive and not optimized, since we expect it to only be used for error // Trimming paths is expensive and not optimized, since we expect it to only be used for error