Split LintExpectationId

`LintExpectationId` has two variants, `Unstable` and `Stable`. There are
some places where both variants are possible, but there are also places
where only one of `Unstable` or `Stable` is possible.

This commit encodes this into the type system by introducing
new types `UnstableLintExpectationId` and `StableLintExpectationId`. The
variants of `LintExpectationId` now enclose these. This makes it clearer
what values are possible where.

Other things of note:
- `LintLevelsProvider` gets an associated type and some method changes.
- `LintContext` gets an associated type.
- `LevelSpec` is made generic. `UnstableLevelSpec` and `StableLevelSpec`
  typedefs are added.
- The unstable types are now guaranteed by the type system to never be
  stably hashed. Previously this was a runtime check.
This commit is contained in:
Nicholas Nethercote
2026-05-15 17:58:21 +10:00
parent 40332688e0
commit 22cf1fb6fe
9 changed files with 210 additions and 160 deletions
+3 -3
View File
@@ -26,7 +26,7 @@
use rustc_macros::{Decodable, Encodable};
use rustc_metadata::EncodedMetadata;
use rustc_middle::dep_graph::WorkProduct;
use rustc_middle::lint::LevelSpec;
use rustc_middle::lint::StableLevelSpec;
use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile;
use rustc_middle::middle::dependency_format::Dependencies;
use rustc_middle::middle::exported_symbols::SymbolExportKind;
@@ -342,8 +342,8 @@ pub fn deserialize_rlink(
/// Instead, encode exactly the information we need.
#[derive(Copy, Clone, Debug, Encodable, Decodable)]
pub struct CodegenLintLevelSpecs {
linker_messages: LevelSpec,
linker_info: LevelSpec,
linker_messages: StableLevelSpec,
linker_info: StableLevelSpec,
}
impl CodegenLintLevelSpecs {