Add an internal lint that warns when accessing untracked data
This commit is contained in:
@@ -17,8 +17,8 @@ use tracing::debug;
|
||||
|
||||
use crate::lints::{
|
||||
BadOptAccessDiag, DefaultHashTypesDiag, DiagOutOfImpl, LintPassByHand, NonExistentDocKeyword,
|
||||
NonGlobImportTypeIrInherent, QueryInstability, SpanUseEqCtxtDiag, TyQualified, TykindDiag,
|
||||
TykindKind, TypeIrInherentUsage, UntranslatableDiag,
|
||||
NonGlobImportTypeIrInherent, QueryInstability, QueryUntracked, SpanUseEqCtxtDiag, TyQualified,
|
||||
TykindDiag, TykindKind, TypeIrInherentUsage, UntranslatableDiag,
|
||||
};
|
||||
use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
|
||||
|
||||
@@ -88,7 +88,18 @@ declare_tool_lint! {
|
||||
report_in_external_macro: true
|
||||
}
|
||||
|
||||
declare_lint_pass!(QueryStability => [POTENTIAL_QUERY_INSTABILITY]);
|
||||
declare_tool_lint! {
|
||||
/// The `untracked_query_information` lint detects use of methods which leak information not
|
||||
/// tracked by the query system, such as whether a `Steal<T>` value has already been stolen. In
|
||||
/// order not to break incremental compilation, such methods must be used very carefully or not
|
||||
/// at all.
|
||||
pub rustc::UNTRACKED_QUERY_INFORMATION,
|
||||
Allow,
|
||||
"require explicit opt-in when accessing information not tracked by the query system",
|
||||
report_in_external_macro: true
|
||||
}
|
||||
|
||||
declare_lint_pass!(QueryStability => [POTENTIAL_QUERY_INSTABILITY, UNTRACKED_QUERY_INFORMATION]);
|
||||
|
||||
impl LateLintPass<'_> for QueryStability {
|
||||
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
|
||||
@@ -102,6 +113,13 @@ impl LateLintPass<'_> for QueryStability {
|
||||
QueryInstability { query: cx.tcx.item_name(def_id) },
|
||||
);
|
||||
}
|
||||
if cx.tcx.has_attr(def_id, sym::rustc_lint_untracked_query_information) {
|
||||
cx.emit_span_lint(
|
||||
UNTRACKED_QUERY_INFORMATION,
|
||||
span,
|
||||
QueryUntracked { method: cx.tcx.item_name(def_id) },
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user