Exclude mir::coverage
types from TypeFoldable/TypeVisitable
These types are unlikely to ever contain type information in the foreseeable future, so excluding them from TypeFoldable/TypeVisitable avoids some unhelpful derive boilerplate.
This commit is contained in:
parent
1c9837df1d
commit
8a6e06fecb
3 changed files with 26 additions and 15 deletions
|
@ -4,7 +4,7 @@ use std::fmt::{self, Debug, Formatter};
|
||||||
|
|
||||||
use rustc_index::IndexVec;
|
use rustc_index::IndexVec;
|
||||||
use rustc_index::bit_set::DenseBitSet;
|
use rustc_index::bit_set::DenseBitSet;
|
||||||
use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
|
use rustc_macros::{HashStable, TyDecodable, TyEncodable};
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
rustc_index::newtype_index! {
|
rustc_index::newtype_index! {
|
||||||
|
@ -72,7 +72,7 @@ impl ConditionId {
|
||||||
/// Enum that can hold a constant zero value, the ID of an physical coverage
|
/// Enum that can hold a constant zero value, the ID of an physical coverage
|
||||||
/// counter, or the ID of a coverage-counter expression.
|
/// counter, or the ID of a coverage-counter expression.
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
#[derive(TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable, TypeVisitable)]
|
#[derive(TyEncodable, TyDecodable, Hash, HashStable)]
|
||||||
pub enum CovTerm {
|
pub enum CovTerm {
|
||||||
Zero,
|
Zero,
|
||||||
Counter(CounterId),
|
Counter(CounterId),
|
||||||
|
@ -89,7 +89,7 @@ impl Debug for CovTerm {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable, TypeVisitable)]
|
#[derive(Clone, PartialEq, TyEncodable, TyDecodable, Hash, HashStable)]
|
||||||
pub enum CoverageKind {
|
pub enum CoverageKind {
|
||||||
/// Marks a span that might otherwise not be represented in MIR, so that
|
/// Marks a span that might otherwise not be represented in MIR, so that
|
||||||
/// coverage instrumentation can associate it with its enclosing block/BCB.
|
/// coverage instrumentation can associate it with its enclosing block/BCB.
|
||||||
|
@ -151,7 +151,7 @@ impl Debug for CoverageKind {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, HashStable)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, HashStable)]
|
||||||
#[derive(TyEncodable, TyDecodable, TypeFoldable, TypeVisitable)]
|
#[derive(TyEncodable, TyDecodable)]
|
||||||
pub enum Op {
|
pub enum Op {
|
||||||
Subtract,
|
Subtract,
|
||||||
Add,
|
Add,
|
||||||
|
@ -168,7 +168,7 @@ impl Op {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
#[derive(TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable, TypeVisitable)]
|
#[derive(TyEncodable, TyDecodable, Hash, HashStable)]
|
||||||
pub struct Expression {
|
pub struct Expression {
|
||||||
pub lhs: CovTerm,
|
pub lhs: CovTerm,
|
||||||
pub op: Op,
|
pub op: Op,
|
||||||
|
@ -176,7 +176,7 @@ pub struct Expression {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
#[derive(TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable, TypeVisitable)]
|
#[derive(TyEncodable, TyDecodable, Hash, HashStable)]
|
||||||
pub enum MappingKind {
|
pub enum MappingKind {
|
||||||
/// Associates a normal region of code with a counter/expression/zero.
|
/// Associates a normal region of code with a counter/expression/zero.
|
||||||
Code(CovTerm),
|
Code(CovTerm),
|
||||||
|
@ -208,7 +208,7 @@ impl MappingKind {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
#[derive(TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable, TypeVisitable)]
|
#[derive(TyEncodable, TyDecodable, Hash, HashStable)]
|
||||||
pub struct Mapping {
|
pub struct Mapping {
|
||||||
pub kind: MappingKind,
|
pub kind: MappingKind,
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
|
@ -218,7 +218,7 @@ pub struct Mapping {
|
||||||
/// to be used in conjunction with the individual coverage statements injected
|
/// to be used in conjunction with the individual coverage statements injected
|
||||||
/// into the function's basic blocks.
|
/// into the function's basic blocks.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
#[derive(TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable, TypeVisitable)]
|
#[derive(TyEncodable, TyDecodable, Hash, HashStable)]
|
||||||
pub struct FunctionCoverageInfo {
|
pub struct FunctionCoverageInfo {
|
||||||
pub function_source_hash: u64,
|
pub function_source_hash: u64,
|
||||||
pub body_span: Span,
|
pub body_span: Span,
|
||||||
|
@ -238,7 +238,7 @@ pub struct FunctionCoverageInfo {
|
||||||
/// ("Hi" indicates that this is "high-level" information collected at the
|
/// ("Hi" indicates that this is "high-level" information collected at the
|
||||||
/// THIR/MIR boundary, before the MIR-based coverage instrumentation pass.)
|
/// THIR/MIR boundary, before the MIR-based coverage instrumentation pass.)
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
#[derive(TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable, TypeVisitable)]
|
#[derive(TyEncodable, TyDecodable, Hash, HashStable)]
|
||||||
pub struct CoverageInfoHi {
|
pub struct CoverageInfoHi {
|
||||||
/// 1 more than the highest-numbered [`CoverageKind::BlockMarker`] that was
|
/// 1 more than the highest-numbered [`CoverageKind::BlockMarker`] that was
|
||||||
/// injected into the MIR body. This makes it possible to allocate per-ID
|
/// injected into the MIR body. This makes it possible to allocate per-ID
|
||||||
|
@ -252,7 +252,7 @@ pub struct CoverageInfoHi {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
#[derive(TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable, TypeVisitable)]
|
#[derive(TyEncodable, TyDecodable, Hash, HashStable)]
|
||||||
pub struct BranchSpan {
|
pub struct BranchSpan {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub true_marker: BlockMarkerId,
|
pub true_marker: BlockMarkerId,
|
||||||
|
@ -260,7 +260,7 @@ pub struct BranchSpan {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
#[derive(TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable, TypeVisitable)]
|
#[derive(TyEncodable, TyDecodable, Hash, HashStable)]
|
||||||
pub struct ConditionInfo {
|
pub struct ConditionInfo {
|
||||||
pub condition_id: ConditionId,
|
pub condition_id: ConditionId,
|
||||||
pub true_next_id: Option<ConditionId>,
|
pub true_next_id: Option<ConditionId>,
|
||||||
|
@ -268,7 +268,7 @@ pub struct ConditionInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
#[derive(TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable, TypeVisitable)]
|
#[derive(TyEncodable, TyDecodable, Hash, HashStable)]
|
||||||
pub struct MCDCBranchSpan {
|
pub struct MCDCBranchSpan {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub condition_info: ConditionInfo,
|
pub condition_info: ConditionInfo,
|
||||||
|
@ -277,14 +277,14 @@ pub struct MCDCBranchSpan {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
#[derive(TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable, TypeVisitable)]
|
#[derive(TyEncodable, TyDecodable, Hash, HashStable)]
|
||||||
pub struct DecisionInfo {
|
pub struct DecisionInfo {
|
||||||
pub bitmap_idx: u32,
|
pub bitmap_idx: u32,
|
||||||
pub num_conditions: u16,
|
pub num_conditions: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
#[derive(TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable, TypeVisitable)]
|
#[derive(TyEncodable, TyDecodable, Hash, HashStable)]
|
||||||
pub struct MCDCDecisionSpan {
|
pub struct MCDCDecisionSpan {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub end_markers: Vec<BlockMarkerId>,
|
pub end_markers: Vec<BlockMarkerId>,
|
||||||
|
|
|
@ -358,6 +358,8 @@ pub struct Body<'tcx> {
|
||||||
///
|
///
|
||||||
/// Only present if coverage is enabled and this function is eligible.
|
/// Only present if coverage is enabled and this function is eligible.
|
||||||
/// Boxed to limit space overhead in non-coverage builds.
|
/// Boxed to limit space overhead in non-coverage builds.
|
||||||
|
#[type_foldable(identity)]
|
||||||
|
#[type_visitable(ignore)]
|
||||||
pub coverage_info_hi: Option<Box<coverage::CoverageInfoHi>>,
|
pub coverage_info_hi: Option<Box<coverage::CoverageInfoHi>>,
|
||||||
|
|
||||||
/// Per-function coverage information added by the `InstrumentCoverage`
|
/// Per-function coverage information added by the `InstrumentCoverage`
|
||||||
|
@ -366,6 +368,8 @@ pub struct Body<'tcx> {
|
||||||
///
|
///
|
||||||
/// If `-Cinstrument-coverage` is not active, or if an individual function
|
/// If `-Cinstrument-coverage` is not active, or if an individual function
|
||||||
/// is not eligible for coverage, then this should always be `None`.
|
/// is not eligible for coverage, then this should always be `None`.
|
||||||
|
#[type_foldable(identity)]
|
||||||
|
#[type_visitable(ignore)]
|
||||||
pub function_coverage_info: Option<Box<coverage::FunctionCoverageInfo>>,
|
pub function_coverage_info: Option<Box<coverage::FunctionCoverageInfo>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -417,7 +417,14 @@ pub enum StatementKind<'tcx> {
|
||||||
///
|
///
|
||||||
/// Interpreters and codegen backends that don't support coverage instrumentation
|
/// Interpreters and codegen backends that don't support coverage instrumentation
|
||||||
/// can usually treat this as a no-op.
|
/// can usually treat this as a no-op.
|
||||||
Coverage(CoverageKind),
|
Coverage(
|
||||||
|
// Coverage statements are unlikely to ever contain type information in
|
||||||
|
// the foreseeable future, so excluding them from TypeFoldable/TypeVisitable
|
||||||
|
// avoids some unhelpful derive boilerplate.
|
||||||
|
#[type_foldable(identity)]
|
||||||
|
#[type_visitable(ignore)]
|
||||||
|
CoverageKind,
|
||||||
|
),
|
||||||
|
|
||||||
/// Denotes a call to an intrinsic that does not require an unwind path and always returns.
|
/// Denotes a call to an intrinsic that does not require an unwind path and always returns.
|
||||||
/// This avoids adding a new block and a terminator for simple intrinsics.
|
/// This avoids adding a new block and a terminator for simple intrinsics.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue