From 6d956a228b9808d0eb78300e988c260887a1f88e Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sun, 29 Oct 2023 22:33:29 +1100 Subject: coverage: Replace impossible `coverage::Error` with assertions Historically, these errors existed so that the coverage debug code could dump additional information before reporting a compiler bug. That debug code was removed by #115962, so we can now simplify these methods by making them panic when they detect a bug. --- compiler/rustc_mir_transform/src/coverage/mod.rs | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) (limited to 'compiler/rustc_mir_transform/src/coverage/mod.rs') diff --git a/compiler/rustc_mir_transform/src/coverage/mod.rs b/compiler/rustc_mir_transform/src/coverage/mod.rs index c9b36ba25ac..97e4468a0e8 100644 --- a/compiler/rustc_mir_transform/src/coverage/mod.rs +++ b/compiler/rustc_mir_transform/src/coverage/mod.rs @@ -26,18 +26,6 @@ use rustc_span::def_id::DefId; use rustc_span::source_map::SourceMap; use rustc_span::{ExpnKind, SourceFile, Span, Symbol}; -/// A simple error message wrapper for `coverage::Error`s. -#[derive(Debug)] -struct Error { - message: String, -} - -impl Error { - pub fn from_string(message: String) -> Result { - Err(Self { message }) - } -} - /// Inserts `StatementKind::Coverage` statements that either instrument the binary with injected /// counters, via intrinsic `llvm.instrprof.increment`, and/or inject metadata used during codegen /// to construct the coverage map. @@ -167,10 +155,7 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> { // `BasicCoverageBlock`s not already associated with a coverage span. let bcb_has_coverage_spans = |bcb| coverage_spans.bcb_has_coverage_spans(bcb); self.coverage_counters - .make_bcb_counters(&mut self.basic_coverage_blocks, bcb_has_coverage_spans) - .unwrap_or_else(|e| { - bug!("Error processing: {:?}: {:?}", self.mir_body.source.def_id(), e.message) - }); + .make_bcb_counters(&self.basic_coverage_blocks, bcb_has_coverage_spans); let mappings = self.create_mappings_and_inject_coverage_statements(&coverage_spans); -- cgit 1.4.1-3-g733a5