Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit a8f7075

Browse files
committed
Auto merge of rust-lang#80692 - Aaron1011:feature/query-result-debug, r=estebank
Enforce that query results implement Debug Currently, we require that query keys implement `Debug`, but we do not do the same for query values. This can make incremental compilation bugs difficult to debug - there isn't a good place to print out the result loaded from disk. This PR adds `Debug` bounds to several query-related functions, allowing us to debug-print the query value when an 'unstable fingerprint' error occurs. This required adding `#[derive(Debug)]` to a fairly large number of types - hopefully, this doesn't have much of an impact on compiler bootstrapping times.
2 parents ff6ee2a + 056fbbf commit a8f7075

File tree

23 files changed

+46
-34
lines changed

23 files changed

+46
-34
lines changed

compiler/rustc_attr/src/builtin.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,21 @@ fn handle_errors(sess: &ParseSess, span: Span, error: AttrError) {
6666
}
6767
}
6868

69-
#[derive(Copy, Clone, PartialEq, Encodable, Decodable)]
69+
#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug)]
7070
pub enum InlineAttr {
7171
None,
7272
Hint,
7373
Always,
7474
Never,
7575
}
7676

77-
#[derive(Clone, Encodable, Decodable)]
77+
#[derive(Clone, Encodable, Decodable, Debug)]
7878
pub enum InstructionSetAttr {
7979
ArmA32,
8080
ArmT32,
8181
}
8282

83-
#[derive(Clone, Encodable, Decodable)]
83+
#[derive(Clone, Encodable, Decodable, Debug)]
8484
pub enum OptimizeAttr {
8585
None,
8686
Speed,

compiler/rustc_data_structures/src/stable_hasher.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ pub fn hash_stable_hashmap<HCX, K, V, R, SK, F>(
552552

553553
/// A vector container that makes sure that its items are hashed in a stable
554554
/// order.
555+
#[derive(Debug)]
555556
pub struct StableVec<T>(Vec<T>);
556557

557558
impl<T> StableVec<T> {

compiler/rustc_data_structures/src/steal.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use crate::sync::{MappedReadGuard, ReadGuard, RwLock};
2121
/// -- once the value is stolen -- it will never be read from again.
2222
//
2323
// FIXME(#41710): what is the best way to model linear queries?
24+
#[derive(Debug)]
2425
pub struct Steal<T> {
2526
value: RwLock<Option<T>>,
2627
}

compiler/rustc_feature/src/active.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ macro_rules! declare_features {
3636
),+];
3737

3838
/// A set of features to be used by later passes.
39-
#[derive(Clone, Default)]
39+
#[derive(Clone, Default, Debug)]
4040
pub struct Features {
4141
/// `#![feature]` attrs for language features, for error reporting.
4242
pub declared_lang_features: Vec<(Symbol, Span, Option<Symbol>)>,

compiler/rustc_hir/src/lang_items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ macro_rules! language_item_table {
6767
}
6868
}
6969

70-
#[derive(HashStable_Generic)]
70+
#[derive(HashStable_Generic, Debug)]
7171
pub struct LanguageItems {
7272
/// Mappings from lang items to their possibly found `DefId`s.
7373
/// The index corresponds to the order in `LangItem`.

compiler/rustc_middle/src/hir/map/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,13 @@ fn is_body_owner<'hir>(node: Node<'hir>, hir_id: HirId) -> bool {
8585
}
8686
}
8787

88+
#[derive(Debug)]
8889
pub(super) struct HirOwnerData<'hir> {
8990
pub(super) signature: Option<&'hir Owner<'hir>>,
9091
pub(super) with_bodies: Option<&'hir mut OwnerNodes<'hir>>,
9192
}
9293

94+
#[derive(Debug)]
9395
pub struct IndexedHir<'hir> {
9496
/// The SVH of the local crate.
9597
pub crate_hash: Svh,

compiler/rustc_middle/src/hir/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use rustc_hir::*;
1717
use rustc_index::vec::IndexVec;
1818
use rustc_span::DUMMY_SP;
1919

20+
#[derive(Debug)]
2021
pub struct Owner<'tcx> {
2122
parent: HirId,
2223
node: Node<'tcx>,
@@ -32,12 +33,13 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for Owner<'tcx> {
3233
}
3334
}
3435

35-
#[derive(Clone)]
36+
#[derive(Clone, Debug)]
3637
pub struct ParentedNode<'tcx> {
3738
parent: ItemLocalId,
3839
node: Node<'tcx>,
3940
}
4041

42+
#[derive(Debug)]
4143
pub struct OwnerNodes<'tcx> {
4244
hash: Fingerprint,
4345
nodes: IndexVec<ItemLocalId, Option<ParentedNode<'tcx>>>,

compiler/rustc_middle/src/lint.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_span::source_map::{DesugaringKind, ExpnKind, MultiSpan};
1212
use rustc_span::{symbol, Span, Symbol, DUMMY_SP};
1313

1414
/// How a lint level was set.
15-
#[derive(Clone, Copy, PartialEq, Eq, HashStable)]
15+
#[derive(Clone, Copy, PartialEq, Eq, HashStable, Debug)]
1616
pub enum LintLevelSource {
1717
/// Lint is at the default level as declared
1818
/// in rustc or a plugin.
@@ -48,11 +48,13 @@ impl LintLevelSource {
4848
/// A tuple of a lint level and its source.
4949
pub type LevelAndSource = (Level, LintLevelSource);
5050

51+
#[derive(Debug)]
5152
pub struct LintLevelSets {
5253
pub list: Vec<LintSet>,
5354
pub lint_cap: Level,
5455
}
5556

57+
#[derive(Debug)]
5658
pub enum LintSet {
5759
CommandLine {
5860
// -A,-W,-D flags, a `Symbol` for the flag itself and `Level` for which
@@ -139,6 +141,7 @@ impl LintLevelSets {
139141
}
140142
}
141143

144+
#[derive(Debug)]
142145
pub struct LintLevelMap {
143146
pub sets: LintLevelSets,
144147
pub id_to_set: FxHashMap<HirId, u32>,

compiler/rustc_middle/src/middle/codegen_fn_attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use rustc_attr::{InlineAttr, InstructionSetAttr, OptimizeAttr};
33
use rustc_session::config::SanitizerSet;
44
use rustc_span::symbol::Symbol;
55

6-
#[derive(Clone, TyEncodable, TyDecodable, HashStable)]
6+
#[derive(Clone, TyEncodable, TyDecodable, HashStable, Debug)]
77
pub struct CodegenFnAttrs {
88
pub flags: CodegenFnAttrFlags,
99
/// Parsed representation of the `#[inline]` attribute

compiler/rustc_middle/src/middle/cstore.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ pub struct NativeLib {
9696
pub wasm_import_module: Option<Symbol>,
9797
}
9898

99-
#[derive(Clone, TyEncodable, TyDecodable, HashStable)]
99+
#[derive(Clone, TyEncodable, TyDecodable, HashStable, Debug)]
100100
pub struct ForeignModule {
101101
pub foreign_items: Vec<DefId>,
102102
pub def_id: DefId,

0 commit comments

Comments
 (0)