1 #![deny(rustc::untranslatable_diagnostic)]
2 #![deny(rustc::diagnostic_outside_of_impl)]
3 use crate::lints::Expectation;
4 use rustc_middle::ty::query::Providers;
5 use rustc_middle::ty::TyCtxt;
6 use rustc_session::lint::builtin::UNFULFILLED_LINT_EXPECTATIONS;
7 use rustc_session::lint::LintExpectationId;
8 use rustc_span::symbol::sym;
9 use rustc_span::Symbol;
11 pub(crate) fn provide(providers: &mut Providers) {
12 *providers = Providers { check_expectations, ..*providers };
15 fn check_expectations(tcx: TyCtxt<'_>, tool_filter: Option<Symbol>) {
16 if !tcx.sess.features_untracked().enabled(sym::lint_reasons) {
20 let lint_expectations = tcx.lint_expectations(());
21 let fulfilled_expectations = tcx.sess.diagnostic().steal_fulfilled_expectation_ids();
23 tracing::debug!(?lint_expectations, ?fulfilled_expectations);
25 for (id, expectation) in lint_expectations {
26 // This check will always be true, since `lint_expectations` only
28 if let LintExpectationId::Stable { hir_id, .. } = id {
29 if !fulfilled_expectations.contains(&id)
30 && tool_filter.map_or(true, |filter| expectation.lint_tool == Some(filter))
32 tcx.emit_spanned_lint(
33 UNFULFILLED_LINT_EXPECTATIONS,
35 expectation.emission_span,
36 Expectation { expectation },
40 unreachable!("at this stage all `LintExpectationId`s are stable");