Add #[track_caller]
to lint related diagnostic functions
This commit is contained in:
parent
f0580df0d5
commit
3dd5413bfd
@ -978,6 +978,7 @@ fn add(&mut self, attrs: &[ast::Attribute], is_crate_node: bool, source_hir_id:
|
||||
/// Returns `true` if the lint's feature is enabled.
|
||||
// FIXME only emit this once for each attribute, instead of repeating it 4 times for
|
||||
// pre-expansion lints, post-expansion lints, `shallow_lint_levels_on` and `lint_expectations`.
|
||||
#[track_caller]
|
||||
fn check_gated_lint(&self, lint_id: LintId, span: Span) -> bool {
|
||||
if let Some(feature) = lint_id.lint.feature_gate {
|
||||
if !self.sess.features_untracked().enabled(feature) {
|
||||
@ -1015,6 +1016,7 @@ pub fn lint_level(&self, lint: &'static Lint) -> LevelAndSource {
|
||||
///
|
||||
/// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub(crate) fn struct_lint(
|
||||
&self,
|
||||
lint: &'static Lint,
|
||||
@ -1028,6 +1030,7 @@ pub(crate) fn struct_lint(
|
||||
struct_lint_level(self.sess, lint, level, src, span, msg, decorate)
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn emit_spanned_lint(
|
||||
&self,
|
||||
lint: &'static Lint,
|
||||
@ -1040,6 +1043,7 @@ pub fn emit_spanned_lint(
|
||||
});
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn emit_lint(&self, lint: &'static Lint, decorate: impl for<'a> DecorateLint<'a, ()>) {
|
||||
let (level, src) = self.lint_level(lint);
|
||||
struct_lint_level(self.sess, lint, level, src, None, decorate.msg(), |lint| {
|
||||
|
@ -278,6 +278,7 @@ pub fn explain_lint_level_source(
|
||||
/// // ^^^^^^^^^^^^^^^^^^^^^ returns `&mut DiagnosticBuilder` by default
|
||||
/// )
|
||||
/// ```
|
||||
#[track_caller]
|
||||
pub fn struct_lint_level(
|
||||
sess: &Session,
|
||||
lint: &'static Lint,
|
||||
@ -291,6 +292,7 @@ pub fn struct_lint_level(
|
||||
) {
|
||||
// Avoid codegen bloat from monomorphization by immediately doing dyn dispatch of `decorate` to
|
||||
// the "real" work.
|
||||
#[track_caller]
|
||||
fn struct_lint_level_impl(
|
||||
sess: &Session,
|
||||
lint: &'static Lint,
|
||||
|
@ -1860,6 +1860,7 @@ pub fn mk_bound_variable_kinds_from_iter<I, T>(self, iter: I) -> T::Output
|
||||
|
||||
/// Emit a lint at `span` from a lint struct (some type that implements `DecorateLint`,
|
||||
/// typically generated by `#[derive(LintDiagnostic)]`).
|
||||
#[track_caller]
|
||||
pub fn emit_spanned_lint(
|
||||
self,
|
||||
lint: &'static Lint,
|
||||
@ -1880,6 +1881,7 @@ pub fn emit_spanned_lint(
|
||||
///
|
||||
/// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn struct_span_lint_hir(
|
||||
self,
|
||||
lint: &'static Lint,
|
||||
@ -1896,6 +1898,7 @@ pub fn struct_span_lint_hir(
|
||||
|
||||
/// Emit a lint from a lint struct (some type that implements `DecorateLint`, typically
|
||||
/// generated by `#[derive(LintDiagnostic)]`).
|
||||
#[track_caller]
|
||||
pub fn emit_lint(
|
||||
self,
|
||||
lint: &'static Lint,
|
||||
@ -1911,6 +1914,7 @@ pub fn emit_lint(
|
||||
///
|
||||
/// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn struct_lint_node(
|
||||
self,
|
||||
lint: &'static Lint,
|
||||
|
@ -117,6 +117,7 @@ pub fn feature_err_issue(
|
||||
/// Construct a future incompatibility diagnostic for a feature gate.
|
||||
///
|
||||
/// This diagnostic is only a warning and *does not cause compilation to fail*.
|
||||
#[track_caller]
|
||||
pub fn feature_warn(sess: &ParseSess, feature: Symbol, span: Span, explain: &'static str) {
|
||||
feature_warn_issue(sess, feature, span, GateIssue::Language, explain);
|
||||
}
|
||||
@ -129,6 +130,7 @@ pub fn feature_warn(sess: &ParseSess, feature: Symbol, span: Span, explain: &'st
|
||||
/// Almost always, you want to use this for a language feature. If so, prefer `feature_warn`.
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
#[track_caller]
|
||||
pub fn feature_warn_issue(
|
||||
sess: &ParseSess,
|
||||
feature: Symbol,
|
||||
@ -351,6 +353,7 @@ pub fn emit_warning<'a>(&'a self, warning: impl IntoDiagnostic<'a, ()>) {
|
||||
self.create_warning(warning).emit()
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn create_note<'a>(
|
||||
&'a self,
|
||||
note: impl IntoDiagnostic<'a, Noted>,
|
||||
@ -358,10 +361,12 @@ pub fn create_note<'a>(
|
||||
note.into_diagnostic(&self.span_diagnostic)
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn emit_note<'a>(&'a self, note: impl IntoDiagnostic<'a, Noted>) -> Noted {
|
||||
self.create_note(note).emit()
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn create_fatal<'a>(
|
||||
&'a self,
|
||||
fatal: impl IntoDiagnostic<'a, !>,
|
||||
@ -369,6 +374,7 @@ pub fn create_fatal<'a>(
|
||||
fatal.into_diagnostic(&self.span_diagnostic)
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn emit_fatal<'a>(&'a self, fatal: impl IntoDiagnostic<'a, !>) -> ! {
|
||||
self.create_fatal(fatal).emit()
|
||||
}
|
||||
@ -383,16 +389,19 @@ pub fn struct_err(
|
||||
}
|
||||
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn struct_warn(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, ()> {
|
||||
self.span_diagnostic.struct_warn(msg)
|
||||
}
|
||||
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn struct_fatal(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, !> {
|
||||
self.span_diagnostic.struct_fatal(msg)
|
||||
}
|
||||
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn struct_diagnostic<G: EmissionGuarantee>(
|
||||
&self,
|
||||
msg: impl Into<DiagnosticMessage>,
|
||||
|
Loading…
Reference in New Issue
Block a user