Enforce that query results implement Debug

This commit is contained in:
Aaron Hill 2021-01-03 09:19:16 -05:00
parent 492b83c697
commit 7afb32557d
No known key found for this signature in database
GPG key ID: B4087E510E98B164
22 changed files with 45 additions and 33 deletions

View file

@ -67,7 +67,7 @@ fn handle_errors(sess: &ParseSess, span: Span, error: AttrError) {
} }
} }
#[derive(Copy, Clone, PartialEq, Encodable, Decodable)] #[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug)]
pub enum InlineAttr { pub enum InlineAttr {
None, None,
Hint, Hint,
@ -75,13 +75,13 @@ pub enum InlineAttr {
Never, Never,
} }
#[derive(Clone, Encodable, Decodable)] #[derive(Clone, Encodable, Decodable, Debug)]
pub enum InstructionSetAttr { pub enum InstructionSetAttr {
ArmA32, ArmA32,
ArmT32, ArmT32,
} }
#[derive(Clone, Encodable, Decodable)] #[derive(Clone, Encodable, Decodable, Debug)]
pub enum OptimizeAttr { pub enum OptimizeAttr {
None, None,
Speed, Speed,

View file

@ -552,6 +552,7 @@ pub fn hash_stable_hashmap<HCX, K, V, R, SK, F>(
/// A vector container that makes sure that its items are hashed in a stable /// A vector container that makes sure that its items are hashed in a stable
/// order. /// order.
#[derive(Debug)]
pub struct StableVec<T>(Vec<T>); pub struct StableVec<T>(Vec<T>);
impl<T> StableVec<T> { impl<T> StableVec<T> {

View file

@ -21,6 +21,7 @@ use crate::sync::{MappedReadGuard, ReadGuard, RwLock};
/// -- once the value is stolen -- it will never be read from again. /// -- once the value is stolen -- it will never be read from again.
// //
// FIXME(#41710): what is the best way to model linear queries? // FIXME(#41710): what is the best way to model linear queries?
#[derive(Debug)]
pub struct Steal<T> { pub struct Steal<T> {
value: RwLock<Option<T>>, value: RwLock<Option<T>>,
} }

View file

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

View file

@ -67,7 +67,7 @@ macro_rules! language_item_table {
} }
} }
#[derive(HashStable_Generic)] #[derive(HashStable_Generic, Debug)]
pub struct LanguageItems { pub struct LanguageItems {
/// Mappings from lang items to their possibly found `DefId`s. /// Mappings from lang items to their possibly found `DefId`s.
/// The index corresponds to the order in `LangItem`. /// The index corresponds to the order in `LangItem`.

View file

@ -86,11 +86,13 @@ fn is_body_owner<'hir>(node: Node<'hir>, hir_id: HirId) -> bool {
} }
} }
#[derive(Debug)]
pub(super) struct HirOwnerData<'hir> { pub(super) struct HirOwnerData<'hir> {
pub(super) signature: Option<&'hir Owner<'hir>>, pub(super) signature: Option<&'hir Owner<'hir>>,
pub(super) with_bodies: Option<&'hir mut OwnerNodes<'hir>>, pub(super) with_bodies: Option<&'hir mut OwnerNodes<'hir>>,
} }
#[derive(Debug)]
pub struct IndexedHir<'hir> { pub struct IndexedHir<'hir> {
/// The SVH of the local crate. /// The SVH of the local crate.
pub crate_hash: Svh, pub crate_hash: Svh,

View file

@ -16,6 +16,7 @@ use rustc_hir::def_id::{LocalDefId, LOCAL_CRATE};
use rustc_hir::*; use rustc_hir::*;
use rustc_index::vec::IndexVec; use rustc_index::vec::IndexVec;
#[derive(Debug)]
pub struct Owner<'tcx> { pub struct Owner<'tcx> {
parent: HirId, parent: HirId,
node: Node<'tcx>, node: Node<'tcx>,
@ -31,12 +32,13 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for Owner<'tcx> {
} }
} }
#[derive(Clone)] #[derive(Clone, Debug)]
pub struct ParentedNode<'tcx> { pub struct ParentedNode<'tcx> {
parent: ItemLocalId, parent: ItemLocalId,
node: Node<'tcx>, node: Node<'tcx>,
} }
#[derive(Debug)]
pub struct OwnerNodes<'tcx> { pub struct OwnerNodes<'tcx> {
hash: Fingerprint, hash: Fingerprint,
nodes: IndexVec<ItemLocalId, Option<ParentedNode<'tcx>>>, nodes: IndexVec<ItemLocalId, Option<ParentedNode<'tcx>>>,

View file

@ -12,7 +12,7 @@ use rustc_span::source_map::{DesugaringKind, ExpnKind, MultiSpan};
use rustc_span::{symbol, Span, Symbol, DUMMY_SP}; use rustc_span::{symbol, Span, Symbol, DUMMY_SP};
/// How a lint level was set. /// How a lint level was set.
#[derive(Clone, Copy, PartialEq, Eq, HashStable)] #[derive(Clone, Copy, PartialEq, Eq, HashStable, Debug)]
pub enum LintLevelSource { pub enum LintLevelSource {
/// Lint is at the default level as declared /// Lint is at the default level as declared
/// in rustc or a plugin. /// in rustc or a plugin.
@ -48,11 +48,13 @@ impl LintLevelSource {
/// A tuple of a lint level and its source. /// A tuple of a lint level and its source.
pub type LevelAndSource = (Level, LintLevelSource); pub type LevelAndSource = (Level, LintLevelSource);
#[derive(Debug)]
pub struct LintLevelSets { pub struct LintLevelSets {
pub list: Vec<LintSet>, pub list: Vec<LintSet>,
pub lint_cap: Level, pub lint_cap: Level,
} }
#[derive(Debug)]
pub enum LintSet { pub enum LintSet {
CommandLine { CommandLine {
// -A,-W,-D flags, a `Symbol` for the flag itself and `Level` for which // -A,-W,-D flags, a `Symbol` for the flag itself and `Level` for which
@ -139,6 +141,7 @@ impl LintLevelSets {
} }
} }
#[derive(Debug)]
pub struct LintLevelMap { pub struct LintLevelMap {
pub sets: LintLevelSets, pub sets: LintLevelSets,
pub id_to_set: FxHashMap<HirId, u32>, pub id_to_set: FxHashMap<HirId, u32>,

View file

@ -3,7 +3,7 @@ use rustc_attr::{InlineAttr, InstructionSetAttr, OptimizeAttr};
use rustc_session::config::SanitizerSet; use rustc_session::config::SanitizerSet;
use rustc_span::symbol::Symbol; use rustc_span::symbol::Symbol;
#[derive(Clone, TyEncodable, TyDecodable, HashStable)] #[derive(Clone, TyEncodable, TyDecodable, HashStable, Debug)]
pub struct CodegenFnAttrs { pub struct CodegenFnAttrs {
pub flags: CodegenFnAttrFlags, pub flags: CodegenFnAttrFlags,
/// Parsed representation of the `#[inline]` attribute /// Parsed representation of the `#[inline]` attribute

View file

@ -96,7 +96,7 @@ pub struct NativeLib {
pub wasm_import_module: Option<Symbol>, pub wasm_import_module: Option<Symbol>,
} }
#[derive(Clone, TyEncodable, TyDecodable, HashStable)] #[derive(Clone, TyEncodable, TyDecodable, HashStable, Debug)]
pub struct ForeignModule { pub struct ForeignModule {
pub foreign_items: Vec<DefId>, pub foreign_items: Vec<DefId>,
pub def_id: DefId, pub def_id: DefId,

View file

@ -7,7 +7,7 @@ pub mod lib_features {
use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_span::symbol::Symbol; use rustc_span::symbol::Symbol;
#[derive(HashStable)] #[derive(HashStable, Debug)]
pub struct LibFeatures { pub struct LibFeatures {
// A map from feature to stabilisation version. // A map from feature to stabilisation version.
pub stable: FxHashMap<Symbol, Symbol>, pub stable: FxHashMap<Symbol, Symbol>,

View file

@ -68,7 +68,7 @@ pub type ObjectLifetimeDefault = Set1<Region>;
/// Maps the id of each lifetime reference to the lifetime decl /// Maps the id of each lifetime reference to the lifetime decl
/// that it corresponds to. /// that it corresponds to.
#[derive(Default, HashStable)] #[derive(Default, HashStable, Debug)]
pub struct ResolveLifetimes { pub struct ResolveLifetimes {
/// Maps from every use of a named (not anonymous) lifetime to a /// Maps from every use of a named (not anonymous) lifetime to a
/// `Region` describing how that region is bound /// `Region` describing how that region is bound

View file

@ -36,7 +36,7 @@ impl StabilityLevel {
} }
/// An entry in the `depr_map`. /// An entry in the `depr_map`.
#[derive(Clone, HashStable)] #[derive(Clone, HashStable, Debug)]
pub struct DeprecationEntry { pub struct DeprecationEntry {
/// The metadata of the attribute associated with this entry. /// The metadata of the attribute associated with this entry.
pub attr: Deprecation, pub attr: Deprecation,
@ -63,7 +63,7 @@ impl DeprecationEntry {
} }
/// A stability index, giving the stability level for items and methods. /// A stability index, giving the stability level for items and methods.
#[derive(HashStable)] #[derive(HashStable, Debug)]
pub struct Index<'tcx> { pub struct Index<'tcx> {
/// This is mostly a cache, except the stabilities of local items /// This is mostly a cache, except the stabilities of local items
/// are filled by the annotator. /// are filled by the annotator.

View file

@ -13,7 +13,7 @@ use crate::ty::{ParamEnv, ScalarInt, Ty, TyCtxt};
use super::{AllocId, Allocation, InterpResult, Pointer, PointerArithmetic}; use super::{AllocId, Allocation, InterpResult, Pointer, PointerArithmetic};
/// Represents the result of const evaluation via the `eval_to_allocation` query. /// Represents the result of const evaluation via the `eval_to_allocation` query.
#[derive(Clone, HashStable, TyEncodable, TyDecodable)] #[derive(Clone, HashStable, TyEncodable, TyDecodable, Debug)]
pub struct ConstAlloc<'tcx> { pub struct ConstAlloc<'tcx> {
// the value lives here, at offset 0, and that allocation definitely is a `AllocKind::Memory` // the value lives here, at offset 0, and that allocation definitely is a `AllocKind::Memory`
// (so you can use `AllocMap::unwrap_memory`). // (so you can use `AllocMap::unwrap_memory`).

View file

@ -216,6 +216,7 @@ impl<'tcx> fmt::Display for MonoItem<'tcx> {
} }
} }
#[derive(Debug)]
pub struct CodegenUnit<'tcx> { pub struct CodegenUnit<'tcx> {
/// A name for this CGU. Incremental compilation requires that /// A name for this CGU. Incremental compilation requires that
/// name be unique amongst **all** crates. Therefore, it should /// name be unique amongst **all** crates. Therefore, it should

View file

@ -17,7 +17,7 @@ use std::fmt::{self, Debug};
use super::{Field, SourceInfo}; use super::{Field, SourceInfo};
#[derive(Copy, Clone, PartialEq, TyEncodable, TyDecodable, HashStable)] #[derive(Copy, Clone, PartialEq, TyEncodable, TyDecodable, HashStable, Debug)]
pub enum UnsafetyViolationKind { pub enum UnsafetyViolationKind {
/// Only permitted in regular `fn`s, prohibited in `const fn`s. /// Only permitted in regular `fn`s, prohibited in `const fn`s.
General, General,
@ -36,7 +36,7 @@ pub enum UnsafetyViolationKind {
UnsafeFnBorrowPacked, UnsafeFnBorrowPacked,
} }
#[derive(Copy, Clone, PartialEq, TyEncodable, TyDecodable, HashStable)] #[derive(Copy, Clone, PartialEq, TyEncodable, TyDecodable, HashStable, Debug)]
pub enum UnsafetyViolationDetails { pub enum UnsafetyViolationDetails {
CallToUnsafeFunction, CallToUnsafeFunction,
UseOfInlineAssembly, UseOfInlineAssembly,
@ -121,7 +121,7 @@ impl UnsafetyViolationDetails {
} }
} }
#[derive(Copy, Clone, PartialEq, TyEncodable, TyDecodable, HashStable)] #[derive(Copy, Clone, PartialEq, TyEncodable, TyDecodable, HashStable, Debug)]
pub struct UnsafetyViolation { pub struct UnsafetyViolation {
pub source_info: SourceInfo, pub source_info: SourceInfo,
pub lint_root: hir::HirId, pub lint_root: hir::HirId,
@ -129,7 +129,7 @@ pub struct UnsafetyViolation {
pub details: UnsafetyViolationDetails, pub details: UnsafetyViolationDetails,
} }
#[derive(Clone, TyEncodable, TyDecodable, HashStable)] #[derive(Clone, TyEncodable, TyDecodable, HashStable, Debug)]
pub struct UnsafetyCheckResult { pub struct UnsafetyCheckResult {
/// Violations that are propagated *upwards* from this function. /// Violations that are propagated *upwards* from this function.
pub violations: Lrc<[UnsafetyViolation]>, pub violations: Lrc<[UnsafetyViolation]>,

View file

@ -23,7 +23,7 @@ use rustc_span::symbol::Ident;
/// parents of a given specializing impl, which is needed for extracting /// parents of a given specializing impl, which is needed for extracting
/// default items amongst other things. In the simple "chain" rule, every impl /// default items amongst other things. In the simple "chain" rule, every impl
/// has at most one parent. /// has at most one parent.
#[derive(TyEncodable, TyDecodable, HashStable)] #[derive(TyEncodable, TyDecodable, HashStable, Debug)]
pub struct Graph { pub struct Graph {
/// All impls have a parent; the "root" impls have as their parent the `def_id` /// All impls have a parent; the "root" impls have as their parent the `def_id`
/// of the trait. /// of the trait.
@ -50,7 +50,7 @@ impl Graph {
/// Children of a given impl, grouped into blanket/non-blanket varieties as is /// Children of a given impl, grouped into blanket/non-blanket varieties as is
/// done in `TraitDef`. /// done in `TraitDef`.
#[derive(Default, TyEncodable, TyDecodable)] #[derive(Default, TyEncodable, TyDecodable, Debug)]
pub struct Children { pub struct Children {
// Impls of a trait (or specializations of a given impl). To allow for // Impls of a trait (or specializations of a given impl). To allow for
// quicker lookup, the impls are indexed by a simplified version of their // quicker lookup, the impls are indexed by a simplified version of their

View file

@ -183,7 +183,7 @@ pub struct ImplHeader<'tcx> {
pub predicates: Vec<Predicate<'tcx>>, pub predicates: Vec<Predicate<'tcx>>,
} }
#[derive(Copy, Clone, PartialEq, TyEncodable, TyDecodable, HashStable)] #[derive(Copy, Clone, PartialEq, TyEncodable, TyDecodable, HashStable, Debug)]
pub enum ImplPolarity { pub enum ImplPolarity {
/// `impl Trait for Type` /// `impl Trait for Type`
Positive, Positive,
@ -433,7 +433,7 @@ pub enum Variance {
/// HIR of every item in the local crate. Instead, use /// HIR of every item in the local crate. Instead, use
/// `tcx.variances_of()` to get the variance for a *particular* /// `tcx.variances_of()` to get the variance for a *particular*
/// item. /// item.
#[derive(HashStable)] #[derive(HashStable, Debug)]
pub struct CrateVariancesMap<'tcx> { pub struct CrateVariancesMap<'tcx> {
/// For each item with generics, maps to a vector of the variance /// For each item with generics, maps to a vector of the variance
/// of its generics. If an item has no generics, it will have no /// of its generics. If an item has no generics, it will have no
@ -1208,7 +1208,7 @@ impl<'tcx> Binder<PredicateAtom<'tcx>> {
/// HIR of every item in the local crate. Instead, use /// HIR of every item in the local crate. Instead, use
/// `tcx.inferred_outlives_of()` to get the outlives for a *particular* /// `tcx.inferred_outlives_of()` to get the outlives for a *particular*
/// item. /// item.
#[derive(HashStable)] #[derive(HashStable, Debug)]
pub struct CratePredicatesMap<'tcx> { pub struct CratePredicatesMap<'tcx> {
/// For each struct with outlive bounds, maps to a vector of the /// For each struct with outlive bounds, maps to a vector of the
/// predicate of its outlive bounds. If an item has no outlives /// predicate of its outlive bounds. If an item has no outlives
@ -3150,7 +3150,7 @@ impl<'tcx> TyCtxt<'tcx> {
} }
} }
#[derive(Clone, HashStable)] #[derive(Clone, HashStable, Debug)]
pub struct AdtSizedConstraint<'tcx>(pub &'tcx [Ty<'tcx>]); pub struct AdtSizedConstraint<'tcx>(pub &'tcx [Ty<'tcx>]);
/// Yields the parent function's `DefId` if `def_id` is an `impl Trait` definition. /// Yields the parent function's `DefId` if `def_id` is an `impl Trait` definition.

View file

@ -63,7 +63,7 @@ pub enum TraitSpecializationKind {
AlwaysApplicable, AlwaysApplicable,
} }
#[derive(Default)] #[derive(Default, Debug)]
pub struct TraitImpls { pub struct TraitImpls {
blanket_impls: Vec<DefId>, blanket_impls: Vec<DefId>,
/// Impls indexed by their simplified self type, for fast lookup. /// Impls indexed by their simplified self type, for fast lookup.

View file

@ -15,7 +15,7 @@ pub trait CacheSelector<K, V> {
} }
pub trait QueryStorage: Default { pub trait QueryStorage: Default {
type Value; type Value: Debug;
type Stored: Clone; type Stored: Clone;
/// Store a value without putting it in the cache. /// Store a value without putting it in the cache.
@ -75,7 +75,7 @@ impl<K, V> Default for DefaultCache<K, V> {
} }
} }
impl<K: Eq + Hash, V: Clone> QueryStorage for DefaultCache<K, V> { impl<K: Eq + Hash, V: Clone + Debug> QueryStorage for DefaultCache<K, V> {
type Value = V; type Value = V;
type Stored = V; type Stored = V;
@ -89,7 +89,7 @@ impl<K: Eq + Hash, V: Clone> QueryStorage for DefaultCache<K, V> {
impl<K, V> QueryCache for DefaultCache<K, V> impl<K, V> QueryCache for DefaultCache<K, V>
where where
K: Eq + Hash + Clone + Debug, K: Eq + Hash + Clone + Debug,
V: Clone, V: Clone + Debug,
{ {
type Key = K; type Key = K;
type Sharded = FxHashMap<K, (V, DepNodeIndex)>; type Sharded = FxHashMap<K, (V, DepNodeIndex)>;
@ -156,7 +156,7 @@ impl<'tcx, K, V> Default for ArenaCache<'tcx, K, V> {
} }
} }
impl<'tcx, K: Eq + Hash, V: 'tcx> QueryStorage for ArenaCache<'tcx, K, V> { impl<'tcx, K: Eq + Hash, V: Debug + 'tcx> QueryStorage for ArenaCache<'tcx, K, V> {
type Value = V; type Value = V;
type Stored = &'tcx V; type Stored = &'tcx V;
@ -171,6 +171,7 @@ impl<'tcx, K: Eq + Hash, V: 'tcx> QueryStorage for ArenaCache<'tcx, K, V> {
impl<'tcx, K, V: 'tcx> QueryCache for ArenaCache<'tcx, K, V> impl<'tcx, K, V: 'tcx> QueryCache for ArenaCache<'tcx, K, V>
where where
K: Eq + Hash + Clone + Debug, K: Eq + Hash + Clone + Debug,
V: Debug
{ {
type Key = K; type Key = K;
type Sharded = FxHashMap<K, &'tcx (V, DepNodeIndex)>; type Sharded = FxHashMap<K, &'tcx (V, DepNodeIndex)>;

View file

@ -21,6 +21,7 @@ use rustc_span::source_map::DUMMY_SP;
use rustc_span::Span; use rustc_span::Span;
use std::collections::hash_map::Entry; use std::collections::hash_map::Entry;
use std::hash::{Hash, Hasher}; use std::hash::{Hash, Hasher};
use std::fmt::Debug;
use std::mem; use std::mem;
use std::num::NonZeroU32; use std::num::NonZeroU32;
use std::ptr; use std::ptr;
@ -478,7 +479,7 @@ where
result result
} }
fn load_from_disk_and_cache_in_memory<CTX, K, V>( fn load_from_disk_and_cache_in_memory<CTX, K, V: Debug>(
tcx: CTX, tcx: CTX,
key: K, key: K,
prev_dep_node_index: SerializedDepNodeIndex, prev_dep_node_index: SerializedDepNodeIndex,
@ -539,7 +540,7 @@ where
#[inline(never)] #[inline(never)]
#[cold] #[cold]
fn incremental_verify_ich<CTX, K, V>( fn incremental_verify_ich<CTX, K, V: Debug>(
tcx: CTX, tcx: CTX,
result: &V, result: &V,
dep_node: &DepNode<CTX::DepKind>, dep_node: &DepNode<CTX::DepKind>,

View file

@ -361,7 +361,7 @@ impl Default for TrimmedDefPaths {
/// Use tree-based collections to cheaply get a deterministic `Hash` implementation. /// Use tree-based collections to cheaply get a deterministic `Hash` implementation.
/// *Do not* switch `BTreeMap` out for an unsorted container type! That would break /// *Do not* switch `BTreeMap` out for an unsorted container type! That would break
/// dependency tracking for command-line arguments. /// dependency tracking for command-line arguments.
#[derive(Clone, Hash)] #[derive(Clone, Hash, Debug)]
pub struct OutputTypes(BTreeMap<OutputType, Option<PathBuf>>); pub struct OutputTypes(BTreeMap<OutputType, Option<PathBuf>>);
impl_stable_hash_via_hash!(OutputTypes); impl_stable_hash_via_hash!(OutputTypes);
@ -538,7 +538,7 @@ impl Input {
} }
} }
#[derive(Clone, Hash)] #[derive(Clone, Hash, Debug)]
pub struct OutputFilenames { pub struct OutputFilenames {
pub out_directory: PathBuf, pub out_directory: PathBuf,
filestem: String, filestem: String,