Auto merge of #115093 - Zalathar:smir-coverage, r=cjgillot,oli-obk
Treat `StatementKind::Coverage` as completely opaque for SMIR purposes Coverage statements in MIR are heavily tied to internal details of the coverage implementation that are likely to change, and are unlikely to be useful to third-party tools for the foreseeable future.
This commit is contained in:
commit
738df13e8a
@ -15,7 +15,6 @@ use crate::stable_mir::ty::{
|
|||||||
};
|
};
|
||||||
use crate::stable_mir::{self, Context};
|
use crate::stable_mir::{self, Context};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_middle::mir::coverage::CodeRegion;
|
|
||||||
use rustc_middle::mir::interpret::alloc_range;
|
use rustc_middle::mir::interpret::alloc_range;
|
||||||
use rustc_middle::mir::{self, ConstantKind};
|
use rustc_middle::mir::{self, ConstantKind};
|
||||||
use rustc_middle::ty::{self, Ty, TyCtxt, Variance};
|
use rustc_middle::ty::{self, Ty, TyCtxt, Variance};
|
||||||
@ -192,10 +191,7 @@ impl<'tcx> Stable<'tcx> for mir::Statement<'tcx> {
|
|||||||
variance: variance.stable(tables),
|
variance: variance.stable(tables),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Coverage(coverage) => stable_mir::mir::Statement::Coverage(stable_mir::mir::Coverage {
|
Coverage(coverage) => stable_mir::mir::Statement::Coverage(opaque(coverage)),
|
||||||
kind: coverage.kind.stable(tables),
|
|
||||||
code_region: coverage.code_region.as_ref().map(|reg| reg.stable(tables)),
|
|
||||||
}),
|
|
||||||
Intrinsic(intrinstic) => {
|
Intrinsic(intrinstic) => {
|
||||||
stable_mir::mir::Statement::Intrinsic(intrinstic.stable(tables))
|
stable_mir::mir::Statement::Intrinsic(intrinstic.stable(tables))
|
||||||
}
|
}
|
||||||
@ -496,30 +492,6 @@ impl<'tcx> Stable<'tcx> for mir::Place<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Stable<'tcx> for mir::coverage::CoverageKind {
|
|
||||||
type T = stable_mir::mir::CoverageKind;
|
|
||||||
fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
|
|
||||||
use rustc_middle::mir::coverage::CoverageKind;
|
|
||||||
match self {
|
|
||||||
CoverageKind::Counter { function_source_hash, id } => {
|
|
||||||
stable_mir::mir::CoverageKind::Counter {
|
|
||||||
function_source_hash: *function_source_hash as usize,
|
|
||||||
id: opaque(id),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CoverageKind::Expression { id, lhs, op, rhs } => {
|
|
||||||
stable_mir::mir::CoverageKind::Expression {
|
|
||||||
id: opaque(id),
|
|
||||||
lhs: opaque(lhs),
|
|
||||||
op: op.stable(tables),
|
|
||||||
rhs: opaque(rhs),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CoverageKind::Unreachable => stable_mir::mir::CoverageKind::Unreachable,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'tcx> Stable<'tcx> for mir::UserTypeProjection {
|
impl<'tcx> Stable<'tcx> for mir::UserTypeProjection {
|
||||||
type T = stable_mir::mir::UserTypeProjection;
|
type T = stable_mir::mir::UserTypeProjection;
|
||||||
|
|
||||||
@ -528,18 +500,6 @@ impl<'tcx> Stable<'tcx> for mir::UserTypeProjection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Stable<'tcx> for mir::coverage::Op {
|
|
||||||
type T = stable_mir::mir::Op;
|
|
||||||
|
|
||||||
fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
|
|
||||||
use rustc_middle::mir::coverage::Op::*;
|
|
||||||
match self {
|
|
||||||
Subtract => stable_mir::mir::Op::Subtract,
|
|
||||||
Add => stable_mir::mir::Op::Add,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'tcx> Stable<'tcx> for mir::Local {
|
impl<'tcx> Stable<'tcx> for mir::Local {
|
||||||
type T = stable_mir::mir::Local;
|
type T = stable_mir::mir::Local;
|
||||||
fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
|
fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
|
||||||
@ -586,20 +546,6 @@ impl<'tcx> Stable<'tcx> for ty::UserTypeAnnotationIndex {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Stable<'tcx> for CodeRegion {
|
|
||||||
type T = stable_mir::mir::CodeRegion;
|
|
||||||
|
|
||||||
fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
|
|
||||||
stable_mir::mir::CodeRegion {
|
|
||||||
file_name: self.file_name.as_str().to_string(),
|
|
||||||
start_line: self.start_line as usize,
|
|
||||||
start_col: self.start_col as usize,
|
|
||||||
end_line: self.end_line as usize,
|
|
||||||
end_col: self.end_col as usize,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'tcx> Stable<'tcx> for mir::UnwindAction {
|
impl<'tcx> Stable<'tcx> for mir::UnwindAction {
|
||||||
type T = stable_mir::mir::UnwindAction;
|
type T = stable_mir::mir::UnwindAction;
|
||||||
fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
|
fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
|
||||||
|
@ -135,9 +135,10 @@ pub enum AsyncGeneratorKind {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) type LocalDefId = Opaque;
|
pub(crate) type LocalDefId = Opaque;
|
||||||
pub(crate) type CounterValueReference = Opaque;
|
/// [`rustc_middle::mir::Coverage`] is heavily tied to internal details of the
|
||||||
pub(crate) type InjectedExpressionId = Opaque;
|
/// coverage implementation that are likely to change, and are unlikely to be
|
||||||
pub(crate) type ExpressionOperandId = Opaque;
|
/// useful to third-party tools for the foreseeable future.
|
||||||
|
pub(crate) type Coverage = Opaque;
|
||||||
|
|
||||||
/// The FakeReadCause describes the type of pattern why a FakeRead statement exists.
|
/// The FakeReadCause describes the type of pattern why a FakeRead statement exists.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
@ -166,42 +167,6 @@ pub enum Variance {
|
|||||||
Bivariant,
|
Bivariant,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub enum Op {
|
|
||||||
Subtract,
|
|
||||||
Add,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub enum CoverageKind {
|
|
||||||
Counter {
|
|
||||||
function_source_hash: usize,
|
|
||||||
id: CounterValueReference,
|
|
||||||
},
|
|
||||||
Expression {
|
|
||||||
id: InjectedExpressionId,
|
|
||||||
lhs: ExpressionOperandId,
|
|
||||||
op: Op,
|
|
||||||
rhs: ExpressionOperandId,
|
|
||||||
},
|
|
||||||
Unreachable,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct CodeRegion {
|
|
||||||
pub file_name: String,
|
|
||||||
pub start_line: usize,
|
|
||||||
pub start_col: usize,
|
|
||||||
pub end_line: usize,
|
|
||||||
pub end_col: usize,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct Coverage {
|
|
||||||
pub kind: CoverageKind,
|
|
||||||
pub code_region: Option<CodeRegion>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct CopyNonOverlapping {
|
pub struct CopyNonOverlapping {
|
||||||
pub src: Operand,
|
pub src: Operand,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user