diff options
| author | xFrednet <xFrednet@gmail.com> | 2022-03-29 00:10:45 +0200 | 
|---|---|---|
| committer | xFrednet <xFrednet@gmail.com> | 2022-05-08 14:37:14 +0200 | 
| commit | 2c5e85249f8b10b5fb0caf608d8b2537620285c6 (patch) | |
| tree | 8d3d6e7b8e79d54df8b5eda69dbe45923b666a47 /compiler/rustc_middle/src | |
| parent | 7f03681cd941c7e18ee99549148b8aa6f468d7c2 (diff) | |
| download | rust-2c5e85249f8b10b5fb0caf608d8b2537620285c6.tar.gz rust-2c5e85249f8b10b5fb0caf608d8b2537620285c6.zip | |
Move lint expectation checking into a separate query (RFC 2383)
Diffstat (limited to 'compiler/rustc_middle/src')
| -rw-r--r-- | compiler/rustc_middle/src/lint.rs | 7 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/query/mod.rs | 19 | 
2 files changed, 25 insertions, 1 deletions
| diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs index e55b0454eef..c7c5f56867a 100644 --- a/compiler/rustc_middle/src/lint.rs +++ b/compiler/rustc_middle/src/lint.rs @@ -210,6 +210,10 @@ pub struct LintExpectation { /// adjusted to include an additional note. Therefore, we have to track if /// the expectation is for the lint. pub is_unfulfilled_lint_expectations: bool, + /// This will hold the name of the tool that this lint belongs to. For + /// the lint `clippy::some_lint` the tool would be `clippy`, the same + /// goes for `rustdoc`. This will be `None` for rustc lints + pub lint_tool: Option<Symbol>, } impl LintExpectation { @@ -217,8 +221,9 @@ impl LintExpectation { reason: Option<Symbol>, emission_span: Span, is_unfulfilled_lint_expectations: bool, + lint_tool: Option<Symbol>, ) -> Self { - Self { reason, emission_span, is_unfulfilled_lint_expectations } + Self { reason, emission_span, is_unfulfilled_lint_expectations, lint_tool } } } diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index e439d128dbc..3936b3f0d68 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -157,6 +157,25 @@ rustc_queries! { desc { "running analysis passes on this crate" } } + /// This query checks the fulfillment of collected lint expectations. + /// All lint emitting queries have to be done before this is executed + /// to ensure that all expectations can be fulfilled. + /// + /// This is an extra query to enable other drivers (like rustdoc) to + /// only execute a small subset of the [`analysis`] query, while allowing + /// lints to be expected. In rustc, this query will be executed as part of + /// the [`analysis`] query and doesn't have to be called a second time. + /// + /// Tools can additionally pass in a tool filter. That will restrict the + /// expectations to only trigger for lints starting with the listed tool + /// name. This is useful for cases were not all linting code from rustc + /// was called. With the default `none` all registered lints will also + /// be checked for expectation fulfillment. + query check_expectations(key: Option<Symbol>) -> () { + eval_always + desc { "checking lint expectations (RFC 2383)" } + } + /// Maps from the `DefId` of an item (trait/struct/enum/fn) to its /// associated generics. query generics_of(key: DefId) -> ty::Generics { | 
