Skip to content

Commit 7afb325

Browse files
committed
Enforce that query results implement Debug
1 parent 492b83c commit 7afb325

File tree

22 files changed

+45
-33
lines changed

22 files changed

+45
-33
lines changed

compiler/rustc_attr/src/builtin.rs

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

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

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

84-
#[derive(Clone, Encodable, Decodable)]
84+
#[derive(Clone, Encodable, Decodable, Debug)]
8585
pub enum OptimizeAttr {
8686
None,
8787
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
@@ -86,11 +86,13 @@ fn is_body_owner<'hir>(node: Node<'hir>, hir_id: HirId) -> bool {
8686
}
8787
}
8888

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

95+
#[derive(Debug)]
9496
pub struct IndexedHir<'hir> {
9597
/// The SVH of the local crate.
9698
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
@@ -16,6 +16,7 @@ use rustc_hir::def_id::{LocalDefId, LOCAL_CRATE};
1616
use rustc_hir::*;
1717
use rustc_index::vec::IndexVec;
1818

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

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

41+
#[derive(Debug)]
4042
pub struct OwnerNodes<'tcx> {
4143
hash: Fingerprint,
4244
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,

compiler/rustc_middle/src/middle/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub mod lib_features {
77
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
88
use rustc_span::symbol::Symbol;
99

10-
#[derive(HashStable)]
10+
#[derive(HashStable, Debug)]
1111
pub struct LibFeatures {
1212
// A map from feature to stabilisation version.
1313
pub stable: FxHashMap<Symbol, Symbol>,

compiler/rustc_middle/src/middle/resolve_lifetime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pub type ObjectLifetimeDefault = Set1<Region>;
6868

6969
/// Maps the id of each lifetime reference to the lifetime decl
7070
/// that it corresponds to.
71-
#[derive(Default, HashStable)]
71+
#[derive(Default, HashStable, Debug)]
7272
pub struct ResolveLifetimes {
7373
/// Maps from every use of a named (not anonymous) lifetime to a
7474
/// `Region` describing how that region is bound

compiler/rustc_middle/src/middle/stability.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl StabilityLevel {
3636
}
3737

3838
/// An entry in the `depr_map`.
39-
#[derive(Clone, HashStable)]
39+
#[derive(Clone, HashStable, Debug)]
4040
pub struct DeprecationEntry {
4141
/// The metadata of the attribute associated with this entry.
4242
pub attr: Deprecation,
@@ -63,7 +63,7 @@ impl DeprecationEntry {
6363
}
6464

6565
/// A stability index, giving the stability level for items and methods.
66-
#[derive(HashStable)]
66+
#[derive(HashStable, Debug)]
6767
pub struct Index<'tcx> {
6868
/// This is mostly a cache, except the stabilities of local items
6969
/// are filled by the annotator.

compiler/rustc_middle/src/mir/interpret/value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::ty::{ParamEnv, ScalarInt, Ty, TyCtxt};
1313
use super::{AllocId, Allocation, InterpResult, Pointer, PointerArithmetic};
1414

1515
/// Represents the result of const evaluation via the `eval_to_allocation` query.
16-
#[derive(Clone, HashStable, TyEncodable, TyDecodable)]
16+
#[derive(Clone, HashStable, TyEncodable, TyDecodable, Debug)]
1717
pub struct ConstAlloc<'tcx> {
1818
// the value lives here, at offset 0, and that allocation definitely is a `AllocKind::Memory`
1919
// (so you can use `AllocMap::unwrap_memory`).

compiler/rustc_middle/src/mir/mono.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ impl<'tcx> fmt::Display for MonoItem<'tcx> {
216216
}
217217
}
218218

219+
#[derive(Debug)]
219220
pub struct CodegenUnit<'tcx> {
220221
/// A name for this CGU. Incremental compilation requires that
221222
/// name be unique amongst **all** crates. Therefore, it should

compiler/rustc_middle/src/mir/query.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use std::fmt::{self, Debug};
1717

1818
use super::{Field, SourceInfo};
1919

20-
#[derive(Copy, Clone, PartialEq, TyEncodable, TyDecodable, HashStable)]
20+
#[derive(Copy, Clone, PartialEq, TyEncodable, TyDecodable, HashStable, Debug)]
2121
pub enum UnsafetyViolationKind {
2222
/// Only permitted in regular `fn`s, prohibited in `const fn`s.
2323
General,
@@ -36,7 +36,7 @@ pub enum UnsafetyViolationKind {
3636
UnsafeFnBorrowPacked,
3737
}
3838

39-
#[derive(Copy, Clone, PartialEq, TyEncodable, TyDecodable, HashStable)]
39+
#[derive(Copy, Clone, PartialEq, TyEncodable, TyDecodable, HashStable, Debug)]
4040
pub enum UnsafetyViolationDetails {
4141
CallToUnsafeFunction,
4242
UseOfInlineAssembly,
@@ -121,15 +121,15 @@ impl UnsafetyViolationDetails {
121121
}
122122
}
123123

124-
#[derive(Copy, Clone, PartialEq, TyEncodable, TyDecodable, HashStable)]
124+
#[derive(Copy, Clone, PartialEq, TyEncodable, TyDecodable, HashStable, Debug)]
125125
pub struct UnsafetyViolation {
126126
pub source_info: SourceInfo,
127127
pub lint_root: hir::HirId,
128128
pub kind: UnsafetyViolationKind,
129129
pub details: UnsafetyViolationDetails,
130130
}
131131

132-
#[derive(Clone, TyEncodable, TyDecodable, HashStable)]
132+
#[derive(Clone, TyEncodable, TyDecodable, HashStable, Debug)]
133133
pub struct UnsafetyCheckResult {
134134
/// Violations that are propagated *upwards* from this function.
135135
pub violations: Lrc<[UnsafetyViolation]>,

compiler/rustc_middle/src/traits/specialization_graph.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use rustc_span::symbol::Ident;
2323
/// parents of a given specializing impl, which is needed for extracting
2424
/// default items amongst other things. In the simple "chain" rule, every impl
2525
/// has at most one parent.
26-
#[derive(TyEncodable, TyDecodable, HashStable)]
26+
#[derive(TyEncodable, TyDecodable, HashStable, Debug)]
2727
pub struct Graph {
2828
/// All impls have a parent; the "root" impls have as their parent the `def_id`
2929
/// of the trait.
@@ -50,7 +50,7 @@ impl Graph {
5050

5151
/// Children of a given impl, grouped into blanket/non-blanket varieties as is
5252
/// done in `TraitDef`.
53-
#[derive(Default, TyEncodable, TyDecodable)]
53+
#[derive(Default, TyEncodable, TyDecodable, Debug)]
5454
pub struct Children {
5555
// Impls of a trait (or specializations of a given impl). To allow for
5656
// quicker lookup, the impls are indexed by a simplified version of their

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ pub struct ImplHeader<'tcx> {
183183
pub predicates: Vec<Predicate<'tcx>>,
184184
}
185185

186-
#[derive(Copy, Clone, PartialEq, TyEncodable, TyDecodable, HashStable)]
186+
#[derive(Copy, Clone, PartialEq, TyEncodable, TyDecodable, HashStable, Debug)]
187187
pub enum ImplPolarity {
188188
/// `impl Trait for Type`
189189
Positive,
@@ -433,7 +433,7 @@ pub enum Variance {
433433
/// HIR of every item in the local crate. Instead, use
434434
/// `tcx.variances_of()` to get the variance for a *particular*
435435
/// item.
436-
#[derive(HashStable)]
436+
#[derive(HashStable, Debug)]
437437
pub struct CrateVariancesMap<'tcx> {
438438
/// For each item with generics, maps to a vector of the variance
439439
/// of its generics. If an item has no generics, it will have no
@@ -1208,7 +1208,7 @@ impl<'tcx> Binder<PredicateAtom<'tcx>> {
12081208
/// HIR of every item in the local crate. Instead, use
12091209
/// `tcx.inferred_outlives_of()` to get the outlives for a *particular*
12101210
/// item.
1211-
#[derive(HashStable)]
1211+
#[derive(HashStable, Debug)]
12121212
pub struct CratePredicatesMap<'tcx> {
12131213
/// For each struct with outlive bounds, maps to a vector of the
12141214
/// predicate of its outlive bounds. If an item has no outlives
@@ -3150,7 +3150,7 @@ impl<'tcx> TyCtxt<'tcx> {
31503150
}
31513151
}
31523152

3153-
#[derive(Clone, HashStable)]
3153+
#[derive(Clone, HashStable, Debug)]
31543154
pub struct AdtSizedConstraint<'tcx>(pub &'tcx [Ty<'tcx>]);
31553155

31563156
/// Yields the parent function's `DefId` if `def_id` is an `impl Trait` definition.

compiler/rustc_middle/src/ty/trait_def.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub enum TraitSpecializationKind {
6363
AlwaysApplicable,
6464
}
6565

66-
#[derive(Default)]
66+
#[derive(Default, Debug)]
6767
pub struct TraitImpls {
6868
blanket_impls: Vec<DefId>,
6969
/// Impls indexed by their simplified self type, for fast lookup.

compiler/rustc_query_system/src/query/caches.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub trait CacheSelector<K, V> {
1515
}
1616

1717
pub trait QueryStorage: Default {
18-
type Value;
18+
type Value: Debug;
1919
type Stored: Clone;
2020

2121
/// Store a value without putting it in the cache.
@@ -75,7 +75,7 @@ impl<K, V> Default for DefaultCache<K, V> {
7575
}
7676
}
7777

78-
impl<K: Eq + Hash, V: Clone> QueryStorage for DefaultCache<K, V> {
78+
impl<K: Eq + Hash, V: Clone + Debug> QueryStorage for DefaultCache<K, V> {
7979
type Value = V;
8080
type Stored = V;
8181

@@ -89,7 +89,7 @@ impl<K: Eq + Hash, V: Clone> QueryStorage for DefaultCache<K, V> {
8989
impl<K, V> QueryCache for DefaultCache<K, V>
9090
where
9191
K: Eq + Hash + Clone + Debug,
92-
V: Clone,
92+
V: Clone + Debug,
9393
{
9494
type Key = K;
9595
type Sharded = FxHashMap<K, (V, DepNodeIndex)>;
@@ -156,7 +156,7 @@ impl<'tcx, K, V> Default for ArenaCache<'tcx, K, V> {
156156
}
157157
}
158158

159-
impl<'tcx, K: Eq + Hash, V: 'tcx> QueryStorage for ArenaCache<'tcx, K, V> {
159+
impl<'tcx, K: Eq + Hash, V: Debug + 'tcx> QueryStorage for ArenaCache<'tcx, K, V> {
160160
type Value = V;
161161
type Stored = &'tcx V;
162162

@@ -171,6 +171,7 @@ impl<'tcx, K: Eq + Hash, V: 'tcx> QueryStorage for ArenaCache<'tcx, K, V> {
171171
impl<'tcx, K, V: 'tcx> QueryCache for ArenaCache<'tcx, K, V>
172172
where
173173
K: Eq + Hash + Clone + Debug,
174+
V: Debug
174175
{
175176
type Key = K;
176177
type Sharded = FxHashMap<K, &'tcx (V, DepNodeIndex)>;

compiler/rustc_query_system/src/query/plumbing.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use rustc_span::source_map::DUMMY_SP;
2121
use rustc_span::Span;
2222
use std::collections::hash_map::Entry;
2323
use std::hash::{Hash, Hasher};
24+
use std::fmt::Debug;
2425
use std::mem;
2526
use std::num::NonZeroU32;
2627
use std::ptr;
@@ -478,7 +479,7 @@ where
478479
result
479480
}
480481

481-
fn load_from_disk_and_cache_in_memory<CTX, K, V>(
482+
fn load_from_disk_and_cache_in_memory<CTX, K, V: Debug>(
482483
tcx: CTX,
483484
key: K,
484485
prev_dep_node_index: SerializedDepNodeIndex,
@@ -539,7 +540,7 @@ where
539540

540541
#[inline(never)]
541542
#[cold]
542-
fn incremental_verify_ich<CTX, K, V>(
543+
fn incremental_verify_ich<CTX, K, V: Debug>(
543544
tcx: CTX,
544545
result: &V,
545546
dep_node: &DepNode<CTX::DepKind>,

compiler/rustc_session/src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ impl Default for TrimmedDefPaths {
361361
/// Use tree-based collections to cheaply get a deterministic `Hash` implementation.
362362
/// *Do not* switch `BTreeMap` out for an unsorted container type! That would break
363363
/// dependency tracking for command-line arguments.
364-
#[derive(Clone, Hash)]
364+
#[derive(Clone, Hash, Debug)]
365365
pub struct OutputTypes(BTreeMap<OutputType, Option<PathBuf>>);
366366

367367
impl_stable_hash_via_hash!(OutputTypes);
@@ -538,7 +538,7 @@ impl Input {
538538
}
539539
}
540540

541-
#[derive(Clone, Hash)]
541+
#[derive(Clone, Hash, Debug)]
542542
pub struct OutputFilenames {
543543
pub out_directory: PathBuf,
544544
filestem: String,

0 commit comments

Comments
 (0)