diff options
| author | xFrednet <xFrednet@gmail.com> | 2021-08-06 23:28:58 +0200 |
|---|---|---|
| committer | xFrednet <xFrednet@gmail.com> | 2022-03-02 17:46:07 +0100 |
| commit | 2ca9037b6154227306d9b40a87d79e691f1c9126 (patch) | |
| tree | eb09c4b3292e8d8195719aab9c80d4e9b84da6d2 /compiler/rustc_errors | |
| parent | f467a58b7bdc330a5af3962df40ad11fe2f05165 (diff) | |
| download | rust-2ca9037b6154227306d9b40a87d79e691f1c9126.tar.gz rust-2ca9037b6154227306d9b40a87d79e691f1c9126.zip | |
Set `LintExpectationId` in level and collect fulfilled ones (RFC-2383)
* Collect lint expectations and set expectation ID in level (RFC-2383) * Collect IDs of fulfilled lint expectations from diagnostics (RFC 2383)
Diffstat (limited to 'compiler/rustc_errors')
| -rw-r--r-- | compiler/rustc_errors/src/diagnostic.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_errors/src/lib.rs | 19 |
2 files changed, 19 insertions, 6 deletions
diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index 802f2560601..a59d91ea789 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -133,11 +133,7 @@ impl Diagnostic { | Level::Error { .. } | Level::FailureNote => true, - Level::Warning - | Level::Note - | Level::Help - | Level::Allow - | Level::Expect(_) => false, + Level::Warning | Level::Note | Level::Help | Level::Allow | Level::Expect(_) => false, } } diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 41d2b285997..83e52e002ae 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -451,6 +451,15 @@ struct HandlerInner { deduplicated_warn_count: usize, future_breakage_diagnostics: Vec<Diagnostic>, + + /// Lint [`Diagnostic`]s can be expected as described in [RFC-2383]. An + /// expected diagnostic will have the level `Expect` which additionally + /// carries the [`LintExpectationId`] of the expectation that can be + /// marked as fulfilled. This is a collection of all [`LintExpectationId`]s + /// that have been marked as fulfilled this way. + /// + /// [RFC-2383]: https://rust-lang.github.io/rfcs/2383-lint-reasons.html + fulfilled_expectations: FxHashSet<LintExpectationId>, } /// A key denoting where from a diagnostic was stashed. @@ -571,6 +580,7 @@ impl Handler { emitted_diagnostics: Default::default(), stashed_diagnostics: Default::default(), future_breakage_diagnostics: Vec::new(), + fulfilled_expectations: Default::default(), }), } } @@ -912,6 +922,12 @@ impl Handler { pub fn emit_unused_externs(&self, lint_level: &str, unused_externs: &[&str]) { self.inner.borrow_mut().emit_unused_externs(lint_level, unused_externs) } + + /// This methods steals all [`LintExpectationId`]s that are stored inside + /// [`HandlerInner`] and indicate that the linked expectation has been fulfilled. + pub fn steal_fulfilled_expectation_ids(&self) -> FxHashSet<LintExpectationId> { + std::mem::take(&mut self.inner.borrow_mut().fulfilled_expectations) + } } impl HandlerInner { @@ -959,7 +975,8 @@ impl HandlerInner { (*TRACK_DIAGNOSTICS)(diagnostic); - if let Level::Expect(_) = diagnostic.level { + if let Level::Expect(expectation_id) = diagnostic.level { + self.fulfilled_expectations.insert(expectation_id); return; } else if diagnostic.level == Allow { return; |
